Skip to content

Commit

Permalink
Merge branch 'develop' into fix-3734
Browse files Browse the repository at this point in the history
  • Loading branch information
goutnet committed May 18, 2021
2 parents 60c303c + a8f2d9f commit 6dddf0a
Show file tree
Hide file tree
Showing 211 changed files with 255 additions and 79,006 deletions.
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@ Use 'x' to check each item: [x] I have ...
-->

* [ ] I have opened this pull request against ``develop``
* [ ] I have updated the **CHANGELOG.rst**
* [ ] I have added or modified the tests when changing logic
* [ ] I have followed [the conventionnal commits guidelines](http://conventionnalcommits.org/) to add meaningful information into the changelog
* [ ] I have read the [contribution guidelines ](https://github.com/django-cms/django-cms/blob/develop/CONTRIBUTING.rst) and I have joined #workgroup-pr-review on [Slack](https://www.django-cms.org/slack) to find a “pr review buddy” who is going to review my pull request.
1 change: 1 addition & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ jobs:
django-2.2.txt,
django-3.0.txt,
django-3.1.txt,
django-3.2.txt,
]
os: [
ubuntu-20.04,
Expand Down
6 changes: 6 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ Unreleased
* Remove debug print from apphook_reload
* Enforce use of coverage > 4 for python 3.8 support
* Fixed 66622 bad Title.path in multilingual sites when parent slug is created or modified
* Improved performance of ``cms list plugins`` command
* Temporarily pinned django-treebeard to < 4.5, this avoids breaking changes introduced
* Fix styles issues, caused by switching to the ``display: flex`` on the page tree renderer.
* Added django-treebeard 4.5.1 support, previously pinned django-treebeard<4.5 to avoid breaking changes introduced
Expand All @@ -22,6 +23,9 @@ Unreleased
* Fixed missing builtin arguments on main ``cms`` management command causing it to crash
* Fixed template label nested translation
* Few changes in docs/contributing/code.rst
* Add support for Django 3.2 LTS version
* removed zh and zh_hans translation (keep zh_CN and zh_TW)
* Cleaned-up unmaintained translations

3.8.0 (2020-10-28)
==================
Expand All @@ -35,6 +39,8 @@ Unreleased
* Fixed an issue in ``wizards/create.html`` where the error message did not use the plural form
* Improved documentation building
* Updated the content for django CMS’s development community
* Replaced all occurences of ``force_text`` and ``smart_text`` against
``force_str``and ``smart_str``.


3.7.4 (2020-07-21)
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.rst
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ Here’s what the pull request process looks like in brief:

To learn more about basic requirements and standards of code contribution, please familiarize yourself with our comprehensive `documentation <https://docs.django-cms.org/en/latest/contributing/code.html#>`_.

django CMS commits follow the [Conventionnal Commits Guideline](http://conventionnalcommits.org/), please try to follow the Guidelines in your commit messages to ease our review&merge process.

Receive rewards for submitting pull requests
--------------------------------------------

Expand Down
8 changes: 4 additions & 4 deletions cms/admin/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.forms.utils import ErrorList
from django.forms.widgets import HiddenInput
from django.template.defaultfilters import slugify
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.translation import gettext, gettext_lazy as _

from cms import api
Expand Down Expand Up @@ -582,7 +582,7 @@ def __init__(self, *args, **kwargs):

if page_data.get('application_urls', False) and page_data['application_urls'] in app_configs:
configs = app_configs[page_data['application_urls']].get_configs()
self.fields['application_configs'].widget.choices = [(config.pk, force_text(config)) for config in configs]
self.fields['application_configs'].widget.choices = [(config.pk, force_str(config)) for config in configs]

try:
config = configs.get(namespace=self.initial['application_namespace'])
Expand Down Expand Up @@ -852,7 +852,7 @@ def clean(self):
cleaned_data = super().clean()

if self.page.is_home and cleaned_data.get('target'):
self.add_error('target', force_text(_('You can\'t move the home page inside another page')))
self.add_error('target', force_str(_('You can\'t move the home page inside another page')))
return cleaned_data

def get_tree_options(self):
Expand Down Expand Up @@ -1308,7 +1308,7 @@ def clean(self):
template=template
)
except PluginLimitReached as error:
self.add_error(None, force_text(error))
self.add_error(None, force_str(error))
return self.cleaned_data


Expand Down
62 changes: 33 additions & 29 deletions cms/admin/pageadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
from django.template.defaultfilters import escape
from django.template.loader import get_template
from django.template.response import SimpleTemplateResponse, TemplateResponse
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.translation import gettext, gettext_lazy as _, get_language
from django.utils.decorators import method_decorator
from django.views.decorators.http import require_POST
Expand Down Expand Up @@ -74,6 +74,7 @@
from cms.utils.admin import jsonify_request
from cms.utils.conf import get_cms_setting
from cms.utils.urlutils import admin_reverse
from cms.utils.compat.response import get_response_headers

require_POST = method_decorator(require_POST)

Expand Down Expand Up @@ -416,11 +417,14 @@ def change_view(self, request, object_id, form_url='', extra_context=None):

response = super().change_view(
request, object_id, form_url=form_url, extra_context=extra_context)
if tab_language and response.status_code == 302 and response._headers['location'][1] == request.path_info:
location = response._headers['location']
response._headers['location'] = (location[0], "%s?language=%s" % (location[1], tab_language))
response_headers = get_response_headers(response)
if tab_language and response.status_code == 302 and response_headers['location'][1] == request.path_info:
location = response_headers['location']
response_headers['location'] = (location[0], "%s?language=%s" % (location[1], tab_language))

return response


@transaction.atomic
def delete_view(self, request, object_id, extra_context=None):
# This is an unfortunate copy/paste from django's delete view.
Expand Down Expand Up @@ -451,13 +455,13 @@ def delete_view(self, request, object_id, extra_context=None):
if request.POST and not protected: # The user has confirmed the deletion.
if perms_needed:
raise PermissionDenied
obj_display = force_text(obj)
obj_display = force_str(obj)
obj_id = obj.serializable_value(opts.pk.attname)
self.log_deletion(request, obj, obj_display)
self.delete_model(request, obj)
return self.response_delete(request, obj_display, obj_id)

object_name = force_text(opts.verbose_name)
object_name = force_str(opts.verbose_name)

if perms_needed or protected:
title = _("Cannot delete %(name)s") % {"name": object_name}
Expand Down Expand Up @@ -617,7 +621,7 @@ def get_preserved_filters(self, request):

def _get_404_exception(self, object_id):
exception = Http404(_('%(name)s object with primary key %(key)r does not exist.') % {
'name': force_text(self.opts.verbose_name),
'name': force_str(self.opts.verbose_name),
'key': escape(object_id),
})
return exception
Expand Down Expand Up @@ -811,7 +815,7 @@ def changelist_view(self, request, extra_context=None):
'changelist_form': changelist_form,
'cms_current_site': site,
'has_add_permission': self.has_add_permission(request),
'module_name': force_text(self.model._meta.verbose_name_plural),
'module_name': force_str(self.model._meta.verbose_name_plural),
'admin': self,
'tree': {
'site': site,
Expand Down Expand Up @@ -842,11 +846,11 @@ def change_template(self, request, object_id):
to_template = request.POST.get("template", None)

if to_template not in dict(get_cms_setting('TEMPLATES')):
return HttpResponseBadRequest(force_text(_("Template not valid")))
return HttpResponseBadRequest(force_str(_("Template not valid")))

page.template = to_template
page.save()
return HttpResponse(force_text(_("The template was successfully changed")))
return HttpResponse(force_str(_("The template was successfully changed")))

@require_POST
@transaction.atomic
Expand Down Expand Up @@ -888,7 +892,7 @@ def move_page(self, request, page_id, extra_context=None):

# Does the user have permissions to do this...?
if not can_move_page or (target and not target.has_add_permission(user)):
message = force_text(_("Error! You don't have permissions "
message = force_str(_("Error! You don't have permissions "
"to move this page. Please reload the page"))
return jsonify_request(HttpResponseForbidden(message))

Expand Down Expand Up @@ -974,13 +978,13 @@ def copy_language(self, request, page_id):
raise self._get_404_exception(page_id)

if not target_language or not target_language in get_language_list(site_id=page.node.site_id):
return HttpResponseBadRequest(force_text(_("Language must be set to a supported language!")))
return HttpResponseBadRequest(force_str(_("Language must be set to a supported language!")))

for placeholder in page.get_placeholders():
plugins = list(
placeholder.get_plugins(language=source_language).order_by('path'))
if not placeholder.has_add_plugins_permission(request.user, plugins):
return HttpResponseForbidden(force_text(_('You do not have permission to copy these plugins.')))
return HttpResponseForbidden(force_str(_('You do not have permission to copy these plugins.')))
copy_plugins.copy_plugins_to(plugins, placeholder, target_language)
return HttpResponse("ok")

Expand Down Expand Up @@ -1018,14 +1022,14 @@ def copy_page(self, request, page_id):
can_copy_page = page_permissions.user_can_add_page(user, site)

if not can_copy_page:
message = force_text(_("Error! You don't have permissions to copy this page."))
message = force_str(_("Error! You don't have permissions to copy this page."))
return jsonify_request(HttpResponseForbidden(message))

page_languages = page.get_languages()
site_languages = get_language_list(site_id=site.pk)

if not any(lang in page_languages for lang in site_languages):
message = force_text(_("Error! The page you're pasting is not "
message = force_str(_("Error! The page you're pasting is not "
"translated in any of the languages configured by the target site."))
return jsonify_request(HttpResponseBadRequest(message))

Expand All @@ -1041,7 +1045,7 @@ def revert_to_live(self, request, page_id, language):
page = self.get_object(request, object_id=page_id)

if not self.has_revert_to_live_permission(request, language, obj=page):
return HttpResponseForbidden(force_text(_("You do not have permission to revert this page.")))
return HttpResponseForbidden(force_str(_("You do not have permission to revert this page.")))

if page is None:
raise self._get_404_exception(page_id)
Expand Down Expand Up @@ -1084,7 +1088,7 @@ def publish_page(self, request, page_id, language):
page = self.get_object(request, object_id=page_id)

if page and not self.has_publish_permission(request, obj=page):
return HttpResponseForbidden(force_text(_("You do not have permission to publish this page")))
return HttpResponseForbidden(force_str(_("You do not have permission to publish this page")))

if page:
translation = page.get_title_obj(language, fallback=False)
Expand Down Expand Up @@ -1208,13 +1212,13 @@ def unpublish(self, request, page_id, language):
page = self.get_object(request, object_id=page_id)

if not self.has_publish_permission(request, obj=page):
return HttpResponseForbidden(force_text(_("You do not have permission to unpublish this page")))
return HttpResponseForbidden(force_str(_("You do not have permission to unpublish this page")))

if page is None:
raise self._get_404_exception(page_id)

if not page.publisher_public_id:
return HttpResponseBadRequest(force_text(_("This page was never published")))
return HttpResponseBadRequest(force_str(_("This page was never published")))

has_translation = page.publisher_public.title_set.filter(language=language).exists()

Expand Down Expand Up @@ -1260,7 +1264,7 @@ def delete_translation(self, request, object_id, extra_context=None):
)

if not self.has_delete_translation_permission(request, language, page):
return HttpResponseForbidden(force_text(_("You do not have permission to delete this page")))
return HttpResponseForbidden(force_str(_("You do not have permission to delete this page")))

if page is None:
raise self._get_404_exception(object_id)
Expand Down Expand Up @@ -1306,7 +1310,7 @@ def delete_translation(self, request, object_id, extra_context=None):
)

message = _('Title and plugins with language %(language)s was deleted') % {
'language': force_text(get_language_object(language)['name'])
'language': force_str(get_language_object(language)['name'])
}
self.log_change(request, translation, message)
messages.success(request, message)
Expand Down Expand Up @@ -1334,7 +1338,7 @@ def delete_translation(self, request, object_id, extra_context=None):

context = {
"title": _("Are you sure?"),
"object_name": force_text(titleopts.verbose_name),
"object_name": force_str(titleopts.verbose_name),
"object": translation,
"deleted_objects": deleted_objects,
"perms_lacking": perms_needed,
Expand Down Expand Up @@ -1375,7 +1379,7 @@ def preview_page(self, request, object_id, language):

if not can_see_page:
message = gettext('You don\'t have permissions to see page "%(title)s"')
message = message % {'title': force_text(page)}
message = message % {'title': force_str(page)}
self.message_user(request, message, level=messages.ERROR)
return HttpResponseRedirect(self.get_admin_url('changelist'))

Expand All @@ -1400,7 +1404,7 @@ def change_innavigation(self, request, page_id):

if not self.has_change_permission(request, obj=page):
message = _("You do not have permission to change this page's in_navigation status")
return HttpResponseForbidden(force_text(message))
return HttpResponseForbidden(force_str(message))

if page is None:
raise self._get_404_exception(page_id)
Expand Down Expand Up @@ -1541,7 +1545,7 @@ def resolve(self, request):
# This is a test if the object url can be retrieved
# In case it can't, object it's not taken into account
try:
force_text(obj.get_absolute_url())
force_str(obj.get_absolute_url())
except:
obj = None
else:
Expand All @@ -1558,7 +1562,7 @@ def resolve(self, request):
except ctype.model_class().DoesNotExist:
obj = None
try:
force_text(obj.get_absolute_url())
force_str(obj.get_absolute_url())
except:
obj = None
if obj:
Expand All @@ -1576,7 +1580,7 @@ def resolve(self, request):
else:
url = obj.get_absolute_url()
if url:
return HttpResponse(force_text(url), content_type='text/plain')
return HttpResponse(force_str(url), content_type='text/plain')
return HttpResponse('', content_type='text/plain')

def edit_title_fields(self, request, page_id, language):
Expand All @@ -1587,7 +1591,7 @@ def edit_title_fields(self, request, page_id, language):
)

if not self.has_change_permission(request, obj=page):
return HttpResponseForbidden(force_text(_("You do not have permission to edit this page")))
return HttpResponseForbidden(force_str(_("You do not have permission to edit this page")))

if page is None:
raise self._get_404_exception(page_id)
Expand Down Expand Up @@ -1702,7 +1706,7 @@ def set_home(self, request, object_id):
raise self._get_404_exception(object_id)

if not page.is_potential_home():
return HttpResponseBadRequest(force_text(_("The page is not eligible to be home.")))
return HttpResponseBadRequest(force_str(_("The page is not eligible to be home.")))

new_home_tree, old_home_tree = page.set_as_homepage(request.user)

Expand Down

0 comments on commit 6dddf0a

Please sign in to comment.