8000 Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks" · django-cms/django-cms@aafe18d · GitHub
[go: up one dir, main page]

Skip to content

Commit aafe18d

Browse files
committed
Revert "[pre-commit.ci] auto fixes from pre-commit.com hooks"
This reverts commit 09ac4b7.
1 parent 09ac4b7 commit aafe18d

File tree

216 files changed

+759
-718
lines changed
  • nl/LC_MESSAGES
  • pl/LC_MESSAGES
  • pt_BR/LC_MESSAGES
  • pt/LC_MESSAGES
  • ru/LC_MESSAGES
  • sq/LC_MESSAGES
  • sv/LC_MESSAGES
  • ta/LC_MESSAGES
  • tr/LC_MESSAGES
  • uk/LC_MESSAGES
  • zh_CN/LC_MESSAGES
  • zh_TW/LC_MESSAGES
  • management/commands/subcommands
  • migrations
  • models
  • signals
  • sitemaps
  • static/cms/js/select2
  • templatetags
  • test_utils
  • tests
  • toolbar
  • utils
  • wizards
  • docs
  • scripts
  • Some content is hidden

    Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

    216 files changed

    +759
    -718
    lines changed

    .github/ISSUE_TEMPLATE/---bug-report.md

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -57,9 +57,9 @@ CMS/Python/Django versions, logs etc. here.
    5757

    5858
    ## Do you want to help fix this issue?
    5959

    60-
    <!--
    60+
    <!--
    6161
    The django CMS project is managed and kept alive by its open source community and is backed by the [django CMS Association](https://www.django-cms.org/en/about-us/). We therefore welcome any help and are grateful if people contribute to the project. Please use 'x' to check the items below.
    6262
    -->
    6363

    64-
    * [ ] Yes, I want to help fix this issue and I will join #workgroup-pr-review on [Slack](https://www.django-cms.org/slack) to confirm with the community that a PR is welcome.
    64+
    * [ ] Yes, I want to help fix this issue and I will join #workgroup-pr-review on [Slack](https://www.django-cms.org/slack) to confirm with the community that a PR is welcome.
    6565
    * [ ] No, I only want to report the issue.

    .github/ISSUE_TEMPLATE/---documentation-report.md

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -35,9 +35,9 @@ CMS/Python/Django versions, logs etc. here.
    3535

    3636
    ## Do you want to help fix this documentation issue?
    3737

    38-
    <!--
    38+
    <!--
    3939
    The django CMS project is managed and kept alive by its open source community and is backed by the [django CMS Association](https://www.django-cms.org/en/about-us/). We therefore welcome any help and are grateful if people contribute to the project. Please use 'x' to check the items below.
    4040
    -->
    4141

    42-
    * [ ] Yes, I want to help fix this issue and I will join #workgroup-documentation on [Slack](https://www.django-cms.org/slack) to confirm with the team that a PR is welcome.
    42+
    * [ ] Yes, I want to help fix this issue and I will join #workgroup-documentation on [Slack](https://www.django-cms.org/slack) to confirm with the team that a PR is welcome.
    4343
    * [ ] No, I only want to report the issue.

    cms/admin/forms.py

    Lines changed: 8 additions & 7 deletions
    Original file line numberDiff line numberDiff line change
    @@ -72,7 +72,8 @@ def get_page_changed_by_filter_choices():
    7272
    def get_page_template_filter_choices():
    7373
    yield ('', _('All'))
    7474

    75-
    yield from get_cms_setting('TEMPLATES')
    75+
    for value, name in get_cms_setting('TEMPLATES'):
    76+
    yield (value, name)
    7677

    7778

    7879
    def save_permissions(data, obj):
    @@ -95,7 +96,7 @@ def save_permissions(data, obj):
    9596
    # add permission `key` for model `model`
    9697
    codename = get_permission_codename(key, model._meta)
    9798
    permission = Permission.objects.get(content_type=content_type, codename=codename)
    98-
    field = f'can_{key}_{name}'
    99+
    field = 'can_%s_%s' % (key, name)
    99100

    100101
    if data.get(field):
    101102
    permission_accessor.add(permission)
    @@ -147,7 +148,7 @@ def clean_slug(self):
    147148

    148149
    class AddPageForm(BasePageForm):
    149150
    source = forms.ModelChoiceField(
    150-
    label=_('Page type'),
    151+
    label=_(u'Page type'),
    151152
    queryset=Page.objects.filter(
    152153
    is_page_type=True,
    153154
    publisher_is_draft=True,
    @@ -200,7 +201,7 @@ def clean(self):
    200201
    if parent_node:
    201202
    slug = data['slug']
    202203
    parent_path = parent_node.item.get_path(self._language)
    203-
    path = f'{parent_path}/{slug}' if parent_path else slug
    204+
    path = u'%s/%s' % (parent_path, slug) if parent_path else slug
    204205
    else:
    205206
    path = data['slug']
    206207

    @@ -432,7 +433,7 @@ def clean(self):
    432433
    if page.parent_page:
    433434
    slug = data['slug']
    434435
    parent_path = page.parent_page.get_path(self._language)
    435-
    path = f'{parent_path}/{slug}' if parent_path else slug
    436+
    path = u'%s/%s' % (parent_path, slug) if parent_path else slug
    436437
    else:
    437438
    path = data['slug']
    438439

    @@ -956,7 +957,7 @@ def get_filter_items(self):
    956957

    957958
    def run_filters(self, queryset):
    958959
    for field, value in self.get_filter_items():
    959-
    query = {f'{field}__exact': value}
    960+
    query = {'{}__exact'.format(field): value}
    960961
    queryset = queryset.filter(**query)
    961962
    return queryset
    962963

    @@ -1174,7 +1175,7 @@ def populate_initials(self, obj):
    11741175
    permissions = permission_accessor.filter(content_type=content_type).values_list('codename', flat=True)
    11751176
    for key in ('add', 'change', 'delete'):
    11761177
    codename = get_permission_codename(key, model._meta)
    1177-
    initials[f'can_{key}_{name}'] = codename in permissions
    1178+
    initials['can_%s_%s' % (key, name)] = codename in permissions
    11781179
    return initials
    11791180

    11801181
    def save(self, commit=True):

    cms/admin/pageadmin.py

    Lines changed: 17 additions & 17 deletions
    Original file line numberDiff line numberDiff line change
    @@ -160,10 +160,10 @@ def get_site(self, request):
    160160
    def get_urls(self):
    161161
    """Get the admin urls
    162162
    """
    163-
    info = f"{self.model._meta.app_label}_{self.model._meta.model_name}"
    163+
    info = "%s_%s" % (self.model._meta.app_label, self.model._meta.model_name)
    164164

    165165
    def pat(regex, fn):
    166-
    return re_path(regex, self.admin_site.admin_view(fn), name=f'{info}_{fn.__name__}')
    166+
    return re_path(regex, self.admin_site.admin_view(fn), name='%s_%s' % (info, fn.__name__))
    167167

    168168
    url_patterns = [
    169169
    pat(r'^([0-9]+)/advanced-settings/$', self.advanced),
    @@ -300,7 +300,7 @@ def advanced(self, request, object_id):
    300300
    message = message % {'language': language_obj['name']}
    301301
    self.message_user(request, message, level=messages.ERROR)
    302302
    path = self.get_admin_url('change', object_id)
    303-
    return HttpResponseRedirect(f"{path}?language={language}")
    303+
    return HttpResponseRedirect("%s?language=%s" % (path, language))
    304304
    return self.change_view(request, object_id, extra_context={'advanced_settings': True, 'title': _("Advanced Settings")})
    305305

    306306
    def actions_menu(self, request, object_id, extra_context=None):
    @@ -354,8 +354,8 @@ def get_unihandecode_context(self, language):
    354354
    uhd_version = get_cms_setting('UNIHANDECODE_VERSION')
    355355
    if uhd_lang and uhd_host and uhd_version:
    356356
    uhd_urls = [
    357-
    f'{uhd_host}unihandecode-{uhd_version}.core.min.js',
    358-
    f'{uhd_host}unihandecode-{uhd_version}.{uhd_lang}.min.js',
    357+
    '%sunihandecode-%s.core.min.js' % (uhd_host, uhd_version),
    358+
    '%sunihandecode-%s.%s.min.js' % (uhd_host, uhd_version, uhd_lang),
    359359
    ]
    360360
    else:
    361361
    uhd_urls = []
    @@ -409,7 +409,7 @@ def change_view(self, request, object_id, form_url='', extra_context=None):
    409409
    response_headers = get_response_headers(response)
    410410
    if tab_language and response.status_code == 302 and response_headers['location'][1] == request.path_info:
    411411
    location = response_headers['location']
    412-
    response_headers['location'] = (location[0], f"{location[1]}?language={tab_language}")
    412+
    response_headers['location'] = (location[0], "%s?language=%s" % (location[1], tab_language))
    413413

    414414
    return response
    415415

    @@ -1069,7 +1069,7 @@ def revert_to_live(self, request, page_id, language):
    10691069
    messages.info(request, _('"%s" was reverted to the live version.') % page)
    10701070

    10711071
    path = page.get_absolute_url(language=language)
    1072-
    path = '{}?{}'.format(path, get_cms_setting('CMS_TOOLBAR_URL__EDIT_OFF'))
    1072+
    path = '%s?%s' % (path, get_cms_setting('CMS_TOOLBAR_URL__EDIT_OFF'))
    10731073
    return HttpResponseRedirect(path)
    10741074

    10751075
    @require_POST
    @@ -1177,17 +1177,17 @@ def publish_page(self, request, page_id, language):
    11771177

    11781178
    path = admin_reverse("cms_page_changelist")
    11791179
    if request.GET.get('redirect_language'):
    1180-
    path = "{}?language={}&page_id={}".format(path, request.GET.get('redirect_language'), request.GET.get('redirect_page_id'))
    1180+
    path = "%s?language=%s&page_id=%s" % (path, request.GET.get('redirect_language'), request.GET.get('redirect_page_id'))
    11811181
    if admin_reverse('index') not in referrer:
    11821182
    if all_published:
    11831183
    if page:
    11841184
    if page.get_publisher_state(language) == PUBLISHER_STATE_PENDING:
    11851185
    path = page.get_absolute_url(language, fallback=True)
    11861186
    else:
    11871187
    public_page = Page.objects.get(publisher_public=page.pk)
    1188-
    path = '{}?preview&{}'.format(public_page.get_absolute_url(language, fallback=True), get_cms_setting('CMS_TOOLBAR_URL__EDIT_OFF'))
    1188+
    path = '%s?preview&%s' % (public_page.get_absolute_url(language, fallback=True), get_cms_setting('CMS_TOOLBAR_URL__EDIT_OFF'))
    11891189
    else:
    1190-
    path = '{}?preview&{}'.format(referrer, get_cms_setting('CMS_TOOLBAR_URL__EDIT_OFF'))
    1190+
    path = '%s?preview&%s' % (referrer, get_cms_setting('CMS_TOOLBAR_URL__EDIT_OFF'))
    11911191
    else:
    11921192
    path = '/?preview&%s' % get_cms_setting('CMS_TOOLBAR_URL__EDIT_OFF')
    11931193

    @@ -1238,7 +1238,7 @@ def unpublish(self, request, page_id, language):
    12381238
    messages.error(request, exc.message)
    12391239
    path = admin_reverse("cms_page_changelist")
    12401240
    if request.GET.get('redirect_language'):
    1241-
    path = "{}?language={}&page_id={}".format(path, request.GET.get('redirect_language'), request.GET.get('redirect_page_id'))
    1241+
    path = "%s?language=%s&page_id=%s" % (path, request.GET.get('redirect_language'), request.GET.get('redirect_page_id'))
    12421242
    return HttpResponseRedirect(path)
    12431243

    12441244
    def delete_translation(self, request, object_id, extra_context=None):
    @@ -1339,7 +1339,7 @@ def delete_translation(self, request, object_id, extra_context=None):
    13391339
    context.update(extra_context or {})
    13401340
    request.current_app = self.admin_site.name
    13411341
    return render(request, self.delete_confirmation_template or [
    1342-
    f"admin/{app_label}/{titleopts.object_name.lower()}/delete_confirmation.html",
    1342+
    "admin/%s/%s/delete_confirmation.html" % (app_label, titleopts.object_name.lower()),
    13431343
    "admin/%s/delete_confirmation.html" % app_label,
    13441344
    "admin/delete_confirmation.html"
    13451345
    ], context)
    @@ -1382,7 +1382,7 @@ def preview_page(self, request, object_id, language):
    13821382
    # and the page is not available on the current site's tree.
    13831383
    # Redirect to the page url in the selected site
    13841384
    proto = 'https' if request.is_secure() else 'http'
    1385-
    url = f"{proto}://{active_site.domain}{url}"
    1385+
    url = "{}://{}{}".format(proto, active_site.domain, url)
    13861386
    return HttpResponseRedirect(url)
    13871387

    13881388
    @require_POST
    @@ -1442,7 +1442,7 @@ def get_tree(self, request):
    14421442
    depth=(page.node.depth + 1 if page else 1),
    14431443
    follow_descendants=True,
    14441444
    )
    1445-
    return HttpResponse(''.join(rows))
    1445+
    return HttpResponse(u''.join(rows))
    14461446

    14471447
    def get_tree_rows(self, request, pages, language, depth=1,
    14481448
    follow_descendants=True):
    @@ -1561,7 +1561,7 @@ def resolve(self, request):
    15611561
    if obj.get_public_object():
    15621562
    url = obj.get_public_object().get_absolute_url()
    15631563
    else:
    1564-
    url = '{}?{}'.format(
    1564+
    url = '%s?%s' % (
    15651565
    obj.get_draft_object().get_absolute_url(),
    15661566
    get_cms_setting('CMS_TOOLBAR_URL__EDIT_ON')
    15671567
    )
    @@ -1672,10 +1672,10 @@ def get_urls(self):
    16721672
    """
    16731673
    Get the admin urls
    16741674
    """
    1675-
    info = f"{self.model._meta.app_label}_{self.model._meta.model_name}"
    1675+
    info = "%s_%s" % (self.model._meta.app_label, self.model._meta.model_name)
    16761676

    16771677
    def pat(regex, fn):
    1678-
    return re_path(regex, self.admin_site.admin_view(fn), name=f'{info}_{fn.__name__}')
    1678+
    return re_path(regex, self.admin_site.admin_view(fn), name='%s_%s' % (info, fn.__name__))
    16791679

    16801680
    url_patterns = [
    16811681
    pat(r'^([0-9]+)/set-home/$', self.set_home),

    cms/admin/placeholderadmin.py

    Lines changed: 5 additions & 5 deletions
    Original file line numberDiff line numberDiff line change
    @@ -73,10 +73,10 @@ def get_urls(self):
    7373
    """
    7474
    Register the url for the single field edit view
    7575
    """
    76-
    info = f"{self.model._meta.app_label}_{self.model._meta.model_name}"
    76+
    info = "%s_%s" % (self.model._meta.app_label, self.model._meta.model_name)
    7777

    7878
    def pat(regex, fn):
    79-
    return re_path(regex, self.admin_site.admin_view(fn), name=f'{info}_{fn.__name__}')
    79+
    return re_path(regex, self.admin_site.admin_view(fn), name='%s_%s' % (info, fn.__name__))
    8080

    8181
    url_patterns = [
    8282
    pat(r'edit-field/(%s)/([a-z\-]+)/$' % SLUG_REGEXP, self.edit_field),
    @@ -104,7 +104,7 @@ def edit_field(self, request, object_id, language):
    104104
    'message': force_str(_("Field %s not found")) % raw_fields
    105105
    }
    106106
    return render(request, 'admin/cms/page/plugin/error_form.html', context)
    107-
    if not request.user.has_perm("{}.change_{}".format(self.model._meta.app_label,
    107+
    if not request.user.has_perm("{0}.change_{1}".format(self.model._meta.app_label,
    108108
    self.model._meta.model_name)):
    109109
    context = {
    110110
    'opts': opts,
    @@ -222,10 +222,10 @@ def get_urls(self):
    222222
    """
    223223
    Register the plugin specific urls (add/edit/copy/remove/move)
    224224
    """
    225-
    info = f"{self.model._meta.app_label}_{self.model._meta.model_name}"
    225+
    info = "%s_%s" % (self.model._meta.app_label, self.model._meta.model_name)
    226226

    227227
    def pat(regex, fn):
    228-
    return re_path(regex, self.admin_site.admin_view(fn), name=f'{info}_{fn.__name__}')
    228+
    return re_path(regex, self.admin_site.admin_view(fn), name='%s_%s' % (info, fn.__name__))
    229229

    230230
    url_patterns = [
    231231
    pat(r'copy-plugins/$', self.copy_plugins),

    cms/admin/settingsadmin.py

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -123,7 +123,7 @@ def response_post_save_change(self, request, obj):
    123123
    args=[obj.id, ],
    124124
    current_app=self.admin_site.name
    125125
    )
    126-
    return HttpResponseRedirect(f"{post_url}?reload_window")
    126+
    return HttpResponseRedirect("{0}?reload_window".format(post_url))
    127127

    128128
    def has_change_permission(self, request, obj=None):
    129129
    if obj and obj.user == request.user:

    cms/admin/useradmin.py

    Lines changed: 1 addition & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -132,7 +132,7 @@ def get_fieldsets(self, request, obj=None):
    132132
    for key in ('add', 'change', 'delete'):
    133133
    perm_code = get_model_permission_codename(model, action=key)
    134134
    if request.user.has_perm(perm_code):
    135-
    fields.append(f'can_{key}_{name}')
    135+
    fields.append('can_%s_%s' % (key, name))
    136136
    if fields:
    137137
    fieldsets.insert(2 + i, (title, {'fields': (fields,)}))
    138138
    return fieldsets

    cms/app_base.py

    Lines changed: 3 additions & 1 deletion
    Original file line numberDiff line numberDiff line change
    @@ -1,3 +1,5 @@
    1+
    2+
    13
    class CMSApp:
    24
    #: list of urlconfs: example: ``_urls = ["myapp.urls"]``
    35
    _urls = []
    @@ -28,7 +30,7 @@ def __new__(cls):
    2830
    )
    2931
    )
    3032
    cls.app_config.cmsapp = cls
    31-
    return super().__new__(cls)
    33+
    return super(CMSApp, cls).__new__(cls)
    3234

    3335
    def get_configs(self):
    3436
    """

    cms/appresolver.py

    Lines changed: 2 additions & 2 deletions
    Original file line numberDiff line numberDiff line change
    @@ -120,7 +120,7 @@ def recurse_patterns(path, pattern_list, page_id, default_args=None,
    120120
    # make sure we don't get patterns that start with more than one '^'!
    121121
    app_pat = app_pat.lstrip('^')
    122122
    path = path.lstrip('^')
    123-
    regex = fr'^{path}{app_pat}' if not nested else r'^%s' % (app_pat)
    123+
    regex = r'^%s%s' % (path, app_pat) if not nested else r'^%s' % (app_pat)
    124124
    if isinstance(pattern, URLResolver):
    125125
    # include default_args
    126126
    args = pattern.default_kwargs
    @@ -234,7 +234,7 @@ def _get_app_patterns(site):
    234234
    # TODO: Need to be fixed for django-treebeard when forward ported to 3.1
    235235
    for title in titles:
    236236
    path = title.path
    237-
    mix_id = "{}:{}:{}".format(
    237+
    mix_id = "%s:%s:%s" % (
    238238
    path + "/", title.page.application_urls, title.language)
    239239
    if mix_id in included:
    240240
    # don't add the same thing twice

    cms/cache/page.py

    Lines changed: 1 addition & 0 deletions
    Original file line numberDiff line numberDiff line change
    @@ -1,3 +1,4 @@
    1+
    12
    import hashlib
    23
    from datetime import timedelta
    34

    0 commit comments

    Comments
     (0)
    0