-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more explanation to public view related code #1451
Comments
It's relevant to all views. It's in that pull request because that's where it was encountered. (Otherwise I need to yank out the code and make yet another pull request with just that code. I already did that with the selected datasets so it makes use of the session variable, which is the only way for public view -- see pull request #1425, as well as repairs to protected media so anonymous users can view the new kinds of video -- see pull request #1435 -- the branch was created before the issue was created, it was fixed for the public view, then the code extracted to make another pull request) If the form hasn't been initialized with the languages yet, the search does not work yet. (The language fields are not in the form. They are put in the form once they are in the request from the selected dataset languages. Everything used to end up defaulting to NGT and it was not possible to browse in Kata Kolok public glosses because the languages had been set to Dutch and English, as for NGT. It couldn't load the page because it had the wrong languages in the form.) it's a result of cascading bugs related to the selected datasets getting set to NGT. For public view, the dataset selected is in the session variable. But that was not being used in the original code. (I was working on that together with @vanlummelhuizen last week.) This has something to do with the order of evaluation of Django when it loads a view. The The normal list views have a big "form your query" area at the top. Initially no results are shown. |
I will add comments! I can see from my explanation, I understand what is going on with the code, but I can't describe it concisely. I really don't want to extract the code for yet another pull request. There is likely going to be another issue about the other session variables. For search type. Recently a new kind of search type was added for annotated sentences. (I removed the text about that because it was distracting.) |
For what I understand, the The
At the time of writing I see 6 lines of comments for each instance of the code @Woseseltops mentions. E.g. Global-signbank/signbank/dictionary/adminviews.py Lines 367 to 374 in da05c74
is_bound should be clear to Django-developers (see above). And since set_up_language_fields has some documentation and your IDE (PyCharm, VSCode, etc.) should be able to display that documentation when you hover over the function name in the calling line, we could get rid of these comments all together. At most we could add something like "Add language dependent fields dynamically". Or change the function name to add_language_dependent_fields .
Question for @susanodd : is it necessary that the search form is bound for the language dependent fields to be added? I think it could be an unbound form that gets fields added to it based on the dataset selection in the user session. Correct? |
Can you guys fight it out? I was fine with the original ONE-LINE comment! (See issue description.) The search form is in the " The Django Just yesterday, I had to move the initialization to the front of two views because it wasn't getting initialized yet. (See commits.) I'll happily change it back to the ONE LINE COMMENT. I was happy with that. |
@Woseseltops complained about the ONE LINE COMMENT. I changed it to be SIX LINES to be pedantic. Because he complained about the ONE LINE. I'm going to change it back to what it was, just ONE line. I am fine with the original ONE LINE. |
Sure. I talk to @Woseseltops on Thursday.
Please wait to change things (back) until we settle this. |
Ah didn't know, thanks :)
Even better!
I detect frustration here, sorry the Signbank project is giving you negative emotions! I appreciate your attempt to improve the understandability of the code! Having said that, if you read my original request, I'm not asking for more comments to the code immediately, I asked to start with formulating a short explanation together, here in this issue :). Short, for similar reasons I ask you to use the Would the proposal by @vanlummelhuizen work for you? |
Yes. My suggestion would be to let the short explanation we come up with be reflected in the function name and function docstring. Then, if the function name is still unclear to the reader, he/she can hover it in the IDE to see the docstring. This way we wouldn´t need comments at all. Rule of thumb: code should be self explanatory, by using good names and docstrings, and with the help of a good IDE. |
When reviewing #1419 , I noticed there was a lot of code related to searching and 'dynamic languagues', which left me confused. As an example of a frequent piece of code that confused me:
Why is the search form relevant to the public view? What does it mean for a search from 'to be bound'? What are dynamic language fields? What do they need to be set up, but only when the search from is bound?
Perhaps we can use this issue to
The text was updated successfully, but these errors were encountered: