-
Notifications
You must be signed in to change notification settings - Fork 46
Refactor get in page_form_view
#4067
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
base: develop
Are you sure you want to change the base?
Conversation
MizukiTemma
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good 😸
3bfe591 to
860f305
Compare
860f305 to
ddba6ce
Compare
|
@jonbulz This PR is ready for review again :) |
jonbulz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your work, I think this makes things a lot cleaner! I approve because I agree with the concepts and separation of logic. However, I have a few comments regarding the naming. But naming is hard and always subjective, so I wouldn't say that my suggestions are better. I just wanted to give some food for thought :)
| }, | ||
| ), | ||
| ) | ||
| disabled = self.get_initial_disable_state(request, page) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value that is returned here is never used. If this is just to handle warning messages if the page is archived, I'd prefer renaming the method to something more fitting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I'm not understand the code correctly, but the way I see it is, that the value is given to the PageForm in line 112 to disable the form :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be check_if_initially_disabled be a better name? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The disable variable that is declared here is never used and completely overruled by the disabled that is later declared by check_is_disabled
IMO, there are 2 possible conclusions:
- What we want is actually not what's happening: Say
get_initial_disable_statereturnsTruebecause the page is archived, butcheck_is_disabledreturnsFalsebecause the user has the appropriate permissions, thendisabledwill just beFalseafter line 110. If it should still beTruebecause the page is archived, we need some kind ofandto ensure this behavior. - If what happens currently in the above mentioned case IS what we want, then what is returned by
get_initial_disable_statedoesn't matter, it does not affect the state of the page form, but instead only adds some extra messages. If that is the case, then we should rename the method accordingly
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, now I get it. I'm sorry it took me a minute. I think this should be fixed now :). Could you please have another look at it? :)
|
@jonbulz do you think you could have another look at this? :) |
| }, | ||
| ), | ||
| ) | ||
| disabled = self.get_initial_disable_state(request, page) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The disable variable that is declared here is never used and completely overruled by the disabled that is later declared by check_is_disabled
IMO, there are 2 possible conclusions:
- What we want is actually not what's happening: Say
get_initial_disable_statereturnsTruebecause the page is archived, butcheck_is_disabledreturnsFalsebecause the user has the appropriate permissions, thendisabledwill just beFalseafter line 110. If it should still beTruebecause the page is archived, we need some kind ofandto ensure this behavior. - If what happens currently in the above mentioned case IS what we want, then what is returned by
get_initial_disable_statedoesn't matter, it does not affect the state of the page form, but instead only adds some extra messages. If that is the case, then we should rename the method accordingly
Short description
After refactoring the
postmethod of the thepage_form_view, I decided to also refactor thegetmethod.Similarly to the previous PR, I also used the cyclomatic complexity as a metric to track progress. This time I was able to reduce the CC by half (from 18 (=C) to 9 (=B)).
Proposed changes
getmethod inpage_form_viewSide effects
Faithfulness to issue description and design
There are no intended deviations from the issue and design.
How to test
Resolved issues
Fixes: /
Pull Request Review Guidelines