Opened 17 years ago
Closed 15 years ago
#6991 closed (fixed)
Omit redundant "if" judgements
Description (last modified by ) ¶
django/contrib/admin/views/decorators.py: if request.user.is_authenticated() and request.user.is_staff:
### COMMENT: request.user.is_staff is True
implied that request.user.is_authenticated()
is True, so request.user.is_authenticated()
could be omitted.
docs/authentication.txt: if not (request.user.is_authenticated() and request.user.has_perm('polls.can_vote')):
### COMMENT: request.user.has_perm('polls.can_vote') is True
implied that request.user.is_authenticated()
is True, so request.user.is_authenticated()
could be omitted.
p.s. may save some precious cpu cycles on Google App Engine. :P
Change History (10)
comment:1 by , 17 years ago
Description: | modified (diff) |
---|
comment:2 by , 17 years ago
Keywords: | nfa-someday added; Omit redundant "if" judgements removed |
---|---|
Triage Stage: | Unreviewed → Design decision needed |
Version: | SVN → newforms-admin |
comment:3 by , 17 years ago
Owner: | changed from | to
---|
comment:4 by , 17 years ago
Has patch: | set |
---|---|
Keywords: | ep2008 added |
Patch needs improvement: | set |
Triage Stage: | Design decision needed → Accepted |
After #3032 being fixed, this is really trivial, all tests pass. Just make sure to catch every occurrence of this behavior.
comment:5 by , 17 years ago
Patch needs improvement: | unset |
---|
Catched couple more places. Looks like they're all here.
Honza mentioned create_update.py in generic views but there are only standalone request.user.is_authenticated() checks that are all needed.
comment:7 by , 17 years ago
Keywords: | yandex-sprint added |
---|
comment:8 by , 15 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Like #6990, these checks were not redundant before the fix for #3032. They are still there in newforms-admin so someone needs to decide if it is worth removing them.