8000 Log operations by Aiky30 · Pull Request #6419 · django-cms/django-cms · GitHub
[go: up one dir, main page]

Skip to content

Log operations #6419

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

Merged
merged 39 commits into from
Jul 2, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
c393d73
Logging helper, page operation logs and page operation tests implemented
Jun 15, 2018
8309bac
Amended the logs to contain the correct action flag
Jun 18, 2018
3365d4f
Added tests for the action flag, changed the page log messages and te…
Jun 18, 2018
e18af96
Updated the messages and tests to cover more of the log entry fields …
Jun 18, 2018
41af0c5
Added new check for get_change_message to ensure that the view functi…
Jun 18, 2018
8ca4740
Cleaning the comments in the code
Jun 18, 2018
e39fbb5
All tests now passing although the method of getting the page admin w…
Jun 18, 2018
d7677df
Cleaned comments and Todo message
Jun 19, 2018
721948e
Cleaned out and organised better for pep 8 compliance
Jun 19, 2018
d92ba32
Cleaned out comments
Jun 19, 2018
8b79b72
logging page creation shared tests renamed
Jun 19, 2018
27bb832
Clean code to pass py flakes tests
Jun 19, 2018
2c0df27
Added various changes to the logging including changing to a signals …
Jun 21, 2018
801a901
committing progress for discussion
Jun 22, 2018
32a91db
Changed the logging message format and the object of all placeholder …
Jun 22, 2018
322181d
Removed the log creation from the form. Amended logs to treat the pag…
Jun 25, 2018
467ea74
Added all tests, disabled the standard Admin log created, changed and…
Jun 25, 2018
b0d90be
Comment the disabled log entry overrides and remove Manual LogEntry c…
Jun 25, 2018
84c6aa5
Reverse changes to the form file
Jun 25, 2018
6ccfb02
Prepare for the form signal handler via operations. Failing tests.
Jun 26, 2018
d707ce8
Added fake request to continue dev. Amended tests and code to work as…
Jun 26, 2018
c5c032d
Amended the logs to fire for edit title fieldgit status
Jun 26, 2018
9bd9902
Add a page changed flag for when fields on page are changed
Jun 26, 2018
ccc6354
Repair changes made to other files
Jun 26, 2018
e741e04
Removed unused plugin
Jun 26, 2018
e723bd1
Remove space that I've added
Jun 26, 2018
81f9024
Amendments from PR feedback
Jun 27, 2018
9f0a770
Merge branch 'release/4.0.x' of github.com:divio/django-cms into rele…
Jun 27, 2018
6030a71
Repair merge of latest test failure
Jun 27, 2018
b82416d
Removed failing test that checks for publishing logs in the test_admi…
Jun 27, 2018
8bed9d0
Amend the admin form to send through the correct request object and r…
Jun 27, 2018
c192dce
Removed redundnant LogEntry import from test_admin
Jun 27, 2018
89b0249
Format the code as per Paulos PR feedback
Jun 28, 2018
4e4d331
fixed failing test due to cleaning too far
Jun 28, 2018
b57802c
cosmetics
czpython Jun 28, 2018
3b4e002
Updated all of the test docstrings to better describe the purpose of …
Jun 28, 2018
4bf6ce9
Add tests that the correct user is attached to each log
Jun 29, 2018
153a60b
Amended log entry tests by ensuring the correct users are configured …
Jun 29, 2018
2c0a1c6
Changed the users id to pk on the tests£
Jul 2, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Added fake request to continue dev. Amended tests and code to work as…
… intended
  • Loading branch information
Andrew Aikman committed Jun 26, 2018
commit d707ce8b57a00201bb1c1d8fe9c124364224db4a
14 changes: 9 additions & 5 deletions cms/admin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
)
from menus.menu_pool import menu_pool

# FIXME: REMOVEME:
from attrdict import AttrDict


def get_permission_accessor(obj):
User = get_user_model()
Expand Down Expand Up @@ -136,6 +139,9 @@ class BasePageForm(forms.ModelForm):
help_text=_('A description of the page used by search engines.'),
max_length=320)

# FIXME: REMOVEME: Waiting for request to be passed through, temp hack for testing in the UI
request = AttrDict({'user': {'pk': 1 }})

class Meta:
model = Page
fields = []
Expand Down Expand Up @@ -268,7 +274,6 @@ def save(self, *args, **kwargs):

operation_token = operation_helpers.send_pre_page_operation(
request=self.request,
sender=self.model,
operation=ADD_PAGE_TRANSLATION,
)

Expand Down Expand Up @@ -308,9 +313,9 @@ def save(self, *args, **kwargs):

operation_helpers.send_post_page_operation(
request=self.request,
sender=self.model,
operation=ADD_PAGE_TRANSLATION,
token=operation_token,
obj=new_page,
)

Copy link
Contributor

Choose a reason for hiding this comment

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

remove newline

return new_page
Expand Down Expand Up @@ -465,7 +470,6 @@ def save(self, commit=True):

Copy link
Contributor

Choose a reason for hiding this comment

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

remove newline

operation_token = operation_helpers.send_pre_page_operation(
request=self.request,
sender=self.model,
operation=CHANGE_PAGE_TRANSLATION
)

Copy link
Contributor

Choose a reason for hiding this 8000 comment

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

remove newline

Expand Down Expand Up @@ -496,9 +500,9 @@ def save(self, commit=True):

Copy link
Contributor

Choose a reason for hiding this comment

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

remove newline

operation_helpers.send_post_page_operation(
request=self.request,
sender=self.model,
operation=CHANGE_PAGE_TRANSLATION,
token=operation_token
token=operation_token,
obj=cms_page,
)

Copy link
Contributor

Choose a reason for hiding this comment

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

remove newline

return cms_page
Expand Down
6 changes: 2 additions & 4 deletions cms/operations/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,23 @@
from cms.signals import pre_obj_operation, post_obj_operation


def send_pre_page_operation(request, sender, operation, obj=Page, **kwargs):
def send_pre_page_operation(request, operation, sender=Page, **kwargs):
token = str(uuid.uuid4())
pre_obj_operation.send(
sender=sender,
operation=operation,
request=request,
token=token,
obj=obj,
**kwargs
)
return token


def send_post_page_operation(request, sender, operation, token, obj=Page, **kwargs):
def send_post_page_operation(request, operation, token, sender=Page, **kwargs):
post_obj_operation.send(
sender=sender,
operation=operation,
request=request,
token=token,
obj=obj,
**kwargs
)
Copy link
Contributor

Choose a reason for hiding this comment

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

add newline at end of file

2 changes: 1 addition & 1 deletion cms/signals/log_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
},
operations.ADD_PAGE_TRANSLATION: {
'message': _("Added Page Translation"),
'flag': CHANGE,
'flag': ADDITION,
},
operations.CHANGE_PAGE_TRANSLATION: {
'message': _("Changed Page Translation"),
Expand Down
37 changes: 3 additions & 34 deletions cms/tests/test_log_entries.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def _assert_page_addition_log_created(self, page):
log_entry = LogEntry.objects.all()[0]

# Check that the contents of the log message is correct
self.assertEqual('[{"added": {}}]', log_entry.change_message)
self.assertEqual('Added Page Translation', log_entry.change_message)

# Check the action flag is set correctly
self.assertEqual(ADDITION, log_entry.action_flag)
Expand Down Expand Up @@ -123,7 +123,7 @@ def test_log_for_change_admin_page(self):
log_entry = LogEntry.objects.all()[0]

# Check that the contents of the log message is correct
self.assertEqual('[{"changed": {"fields": ["slug"]}}]', log_entry.change_message)
self.assertEqual('Changed Page Translation', log_entry.change_message)

# Check the action flag is set correctly
self.assertEqual(CHANGE, log_entry.action_flag)
Expand Down Expand Up @@ -198,37 +198,6 @@ def test_log_for_delete_admin_page(self):
# Check the object_repr is set correctly
self.assertEqual(pre_delete_repr, log_entry.object_repr)

def test_log_for_create_page_translation(self):
"""
Test that a page translation creation is logged correctly
"""

page_data = self.get_new_page_data()

with self.login_user_context(self._admin_user):

response = self.client.post(URL_CMS_PAGE_ADD, page_data)
self.assertEqual(response.status_code, 302)

page = Page.objects.get(title_set__slug=page_data['slug'], publisher_is_draft=True)

# Test that the log count is correct
self.assertEqual(1, LogEntry.objects.count())

log_entry = LogEntry.objects.all()[0]

# Check that the contents of the log message is correct
self.assertEqual(_("Changed Page Translation"), log_entry.change_message)

# Check the action flag is set correctly
self.assertEqual(CHANGE, log_entry.action_flag)

# Check the object id is set correctly
self.assertEqual(str(page.pk), log_entry.object_id)

# Check the object_repr is set correctly
self.assertEqual(str(page), log_entry.object_repr)

def test_log_for_change_translation(self):
"""
Test that a page translation change is logged correctly
Expand All @@ -253,7 +222,7 @@ def test_log_for_change_translation(self):
log_entry = LogEntry.objects.all()[0]

# Check that the contents of the log message is correct
self.assertEqual(_("Changed Page Translation"), log_entry.change_message)
self.assertEqual(_("Added Page Translation"), log_entry.change_message)

# Check the action flag is set correctly
self.assertEqual(CHANGE, log_entry.action_flag)
Expand Down
0