`default_access_fn` always returns True for forked apps
See original GitHub issueIssue Summary
I’ve managed to reproduce this for any dashboard app and will use the Pages dashboard app as the example in this ticket.
I’ve narrowed the issue down to apps.get_containing_app_config
returning Shop when it should return PagesDashboardConfig
.
https://github.com/django-oscar/django-oscar/blob/fe983bf7140457d06094d843da0b94ebaea4d6c8/src/oscar/apps/dashboard/nav.py#L98
I’ve tried changing the check on line 99 to
if app_config_instance is None or not isinstance(app_config_instance, OscarDashboardConfig):
But then, get_app_config_class
will return the base OscarDashboardConfig
class which is also not what we want.
Steps to Reproduce
- Fork the Pages dashboard app
./manage.py oscar_fork_app pages_dashboard . oscar_forks.dashboard.pages
- Log into the dashboard with a user with
partner.dashboard_access
- Notice the Content submenu is visible while the whole Pages app has this default permission https://github.com/django-oscar/django-oscar/blob/fe983bf7140457d06094d843da0b94ebaea4d6c8/src/oscar/apps/dashboard/pages/apps.py#L13
Technical details
- Python version: 3.7.4
- Django version: 2.2.3
- Oscar version: 2.0
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (12 by maintainers)
Top Results From Across the Web
os — Miscellaneous operating system interfaces — Python ...
Return the value of the environment variable key as a string if it exists, or default if it doesn't. key is a string....
Read more >The fork() System Call
System call fork() is used to create processes. It takes no arguments and returns a process ID. The purpose of fork() is to...
Read more >Set the default form that appears when you open an Access ...
Specify the default form in Access Options · Click the File tab, and then under Help, click Options. · Click Current Database. ·...
Read more >Maven Surefire Plugin – Fork Options and Parallel Test ...
Using reuseForks=true (by default) and forking the test classes in reusable JVMs may lead to the same problem with shared static code across...
Read more >Why do we need to fork to create new processes?
While both points are true, neither supports why forking method was chosen instead of reating a new process from given executable. – hellodanylo....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Here’s my PRs plan:
default_access_fn
https://github.com/django-oscar/django-oscar/pull/3087Simplify forking command to only override the
name
attribute https://github.com/django-oscar/django-oscar/pull/3084Document the need to fork top-level apps before nested apps Alternatively, we could change the command when forking a nested app to either:
But to keep things manageable, I’ll probably just document for now.
We have a bunch of forked apps in the
_site
project that is used for tests. One approach is to fork one of the dashboard apps into there, and then have integration tests that check that the forked app’s config is being used to determine permissions.This approach is not particularly pretty because the forking applies for the entire test suite, but we haven’t found a better alternative.
This would ideally be in addition to unit tests for
_dashboard_urls_to_config()
for whichget_app_configs()
can be mocked.