Skip to content
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

Permissions cleanup (part 1) #5489

Merged
merged 18 commits into from Jul 8, 2016

Conversation

czpython
Copy link
Contributor

@czpython czpython commented Jul 1, 2016

This PR introduces multiple bug fixes for the permissions system, as well as small cleanups and a complete overhaul of permission related tests.

As the title suggests, this is not a finished product but it's the "core" of the cleanup, future efforts will be based on this.

High level overview:

  • Moved plugin add request validation logic to placeholder admin.
    This is because plugins should have no logic aside from the builtin admin logic
    to validate and allow an add request. Placeholders on the other hand provide a way
    to extend these checks in third party apps.
  • Moved all (I hope) admin related tests from test_placeholder, test_admin and test_page
    into the more specific test_page_admin module.
  • Created a test_page_user_admin module for tests that interact with the PageUser admin
  • Created a test_page_user_group_admin module for tests that interact with the PageUserGroup
    admin.
  • Created a test_placeholder_app_admin module for tests that interact with the PlaceholderAdminMixin class.
  • Refactored page & placeholder tests to account for permissions.
  • Removed logic to display unsaved (ghost) plugins in structure board.

Most of the additions/changes are tests, there's several bug fixes but usually one liners.
/cc @divio/django-cms-core

@czpython czpython added this to the 3.4 milestone Jul 1, 2016
@czpython czpython self-assigned this Jul 1, 2016
if get_cms_setting('PERMISSION'):
can_add = super(PageAdmin, self).has_add_permission(request)

if can_add and get_cms_setting('PERMISSION'):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does it make sense to put something like: CMS_PERMISSION = get_cms_setting('PERMISSION') at the top of this file and then use the "constant": CMS_PERMISSION everywhere instead? Its unlikely to change between requests =)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup. I'll keep it in mind for the next PR, to avoid re-running tests, etc.. on this one.

@mkoistinen
Copy link
Contributor

Great work... and long overdue!

I see now why you had to write so many tests. In the end, to we go up or down in tests count and test coverage?

@mkoistinen
Copy link
Contributor

OK to merge. Looking forward to part 2.

@czpython
Copy link
Contributor Author

czpython commented Jul 1, 2016

Thanks, test count has gone up over 100 new tests. We'll have to wait on coverage to run and give us the verdict.

@czpython czpython force-pushed the feature/permissions-cleanup branch 2 times, most recently from b867fc2 to 01c763a Compare July 2, 2016 02:44
@czpython czpython force-pushed the feature/permissions-cleanup branch from 01c763a to 1ec6ef7 Compare July 2, 2016 03:13
@coveralls
Copy link

coveralls commented Jul 2, 2016

Coverage Status

Coverage increased (+0.5%) to 89.135% when pulling 1ec6ef7 on czpython:feature/permissions-cleanup into d735c45 on divio:develop.

@czpython
Copy link
Contributor Author

czpython commented Jul 7, 2016

@yakky Please review :)

@yakky
Copy link
Member

yakky commented Jul 7, 2016

Sorry, terrible week. Ok to merge

@czpython czpython merged commit eef8578 into django-cms:develop Jul 8, 2016
@czpython
Copy link
Contributor Author

czpython commented Jul 8, 2016

The next PR will have the changelog entries.
Another PR will be created in cooperation with @evildmp to update any outdated documentation.

@czpython czpython deleted the feature/permissions-cleanup branch August 18, 2016 01:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants