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 |
-
-
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
-
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:
-
8d52386cace9a4b8fbe18b6b598b0a0f59bfa5d6665cbeb63e91ebd99879681f69000a58061b6990
- Commit:
-
665cbeb63e91ebd99879681f69000a58061b6990b5e2e80e6e556ff483a7c7ba1c6c63dac3ab912f
Checks run (2 succeeded)
- Change Summary:
-
Add more unit tests and fix some failures that were missed.
- Commit:
-
b5e2e80e6e556ff483a7c7ba1c6c63dac3ab912f9e58d39c18dbd01798925a22fd0d13b9a3a0375e
Checks run (2 succeeded)
- Change Summary:
-
Addressed David's issues
- Description:
-
~ When browing a non-LocalSite specific page, if any LocalSite the user is
~ 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. - Commit:
-
9e58d39c18dbd01798925a22fd0d13b9a3a0375e87ac911f2d01922b7e73135f584336757363b188