Check for enabled features on local sites when on a global site
Review Request #9705 — Created Feb. 26, 2018 and submitted
When browsing a non-LocalSite specific page, if any LocalSite the user is
a member of has a feature enabled then it should be enabled for that
user while browsing the non-LocalSite page. Previously, this was not
taken into account and features that a user should otherwise have access
to would be disabled if they were enabled only for their LocalSites.
This has been corrected.
Ran unit tests.
Description | From | Last Updated |
---|---|---|
Typo in the description: "browing" -> "browsing" |
chipx86 | |
We can simplify this, reducing the code paths for checking a value and returning and code paths with: if local_site: … |
chipx86 | |
I don't like this returning None as an optional, and don't like not having an explicit return. This way leads … |
chipx86 | |
No trailing comma. |
chipx86 | |
E501 line too long (86 > 79 characters) |
reviewbot | |
This would be better as: if getattr(request, 'local_site', None): ... |
chipx86 | |
These two if statements should be combined: if (local_site.extra_data and local_site.extra_data.get(...)): |
chipx86 | |
Extra space before "but". |
chipx86 |
-
-
reviewboard/features/checkers.py (Diff revision 1) We can simplify this, reducing the code paths for checking a value and returning and code paths with:
if local_site: local_sites = [local_site] elif request is not None and request.user.is_authenticated(): local_sites = request.user.local_site.all() else: local_sites = [] for local_site in local_sites: if self._is_enabled_for_local_site(...): return True return False
-
reviewboard/features/checkers.py (Diff revision 1) I don't like this returning
None
as an optional, and don't like not having an explicit return. This way leads to confusing problems down the road. This can easily return a boolean explicitly using basically what we had before:if local_site.extra_data: try: return local_site.extra_data[self.EXTRA_DATA_KEY][feature_id] except KeyError: pass return False
-
Change Summary:
Addressed Christian's comments.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 2 (+84 -26) |
Checks run (1 failed, 1 succeeded)
flake8
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 3 (+85 -26) |
Checks run (2 succeeded)
Change Summary:
Add more unit tests and fix some failures that were missed.
Commit: |
|
||||
---|---|---|---|---|---|
Diff: |
Revision 4 (+217 -53) |
Checks run (2 succeeded)
-
-
-
reviewboard/features/checkers.py (Diff revision 4) This would be better as:
if getattr(request, 'local_site', None): ...
-
reviewboard/features/checkers.py (Diff revision 4) These two
if
statements should be combined:if (local_site.extra_data and local_site.extra_data.get(...)):
-
Change Summary:
Addressed David's issues
Description: |
|
|||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Commit: |
|
|||||||||||||||||||||
Diff: |
Revision 5 (+216 -53) |