Skip to content

Commit

Permalink
Added language to Page translation operations
Browse files Browse the repository at this point in the history
  • Loading branch information
czpython committed Sep 5, 2018
1 parent 4981c62 commit ca16415
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cms/admin/forms.py
Expand Up @@ -300,6 +300,7 @@ def save(self, *args, **kwargs):
operation_token = send_pre_page_operation(
request=self._request,
operation=ADD_PAGE_TRANSLATION,
language=self._language,
)

if page:
Expand Down Expand Up @@ -345,6 +346,7 @@ def save(self, *args, **kwargs):
operation=ADD_PAGE_TRANSLATION,
token=operation_token,
obj=new_page,
language=self._language,
)
return translation

Expand Down Expand Up @@ -552,6 +554,7 @@ def save(self, commit=True):
operation_token = send_pre_page_operation(
request=self._request,
operation=CHANGE_PAGE_TRANSLATION,
language=self._language,
)

data = self.cleaned_data.copy()
Expand Down Expand Up @@ -582,6 +585,7 @@ def save(self, commit=True):
operation=CHANGE_PAGE_TRANSLATION,
token=operation_token,
obj=page,
language=self._language,
)
return page_content

Expand Down
12 changes: 12 additions & 0 deletions cms/admin/pageadmin.py
Expand Up @@ -872,6 +872,18 @@ def log_change(self, request, object, message):
# Block the admin log for change. A signal takes care of this!
return

def get_object(self, request, object_id, from_field=None):
"""
Return an instance matching the field and value provided, the primary
key is used if no field is provided. Return ``None`` if no match is
found or the object_id fails validation.
"""
obj = super(PageContentAdmin, self).get_object(request, object_id, from_field)

if obj:
obj.page.title_cache[obj.language] = obj
return obj

def get_admin_url(self, action, *args):
url_name = "{}_{}_{}".format(
self.opts.app_label,
Expand Down

1 comment on commit ca16415

@Aiky30
Copy link
Contributor

@Aiky30 Aiky30 commented on ca16415 Nov 5, 2018

Choose a reason for hiding this comment

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

@czpython, I hope you are well. Is there a reason why the page object is not sent in pre page operations? I'm currently working on getting djangocms-history working with CMS 4.0, not having the obj sent in the pre page operations breaks the app. History needs a lot of work due to the Plugin architecture changes.

ca16415#diff-1ecc0e79e2d97f07715ccf2726b548e8R300

Please sign in to comment.