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

Django 4 Support #589

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 0 additions & 1 deletion demo/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@

USE_TZ = True
USE_I18N = True
USE_L10N = True

SITE_ID = 1

Expand Down
30 changes: 15 additions & 15 deletions demo/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from django.conf import settings
from django.conf.urls import include
from django.conf.urls import url
from django.urls import include, path, re_path
from django.contrib import admin
from django.contrib.sitemaps.views import index
from django.contrib.sitemaps.views import sitemap
Expand All @@ -23,13 +23,13 @@


urlpatterns = [
url(r'^$', RedirectView.as_view(url='/blog/', permanent=True)),
url(r'^blog/', include('zinnia.urls')),
url(r'^comments/', include('django_comments.urls')),
url(r'^xmlrpc/$', handle_xmlrpc),
url(r'^i18n/', include('django.conf.urls.i18n')),
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
url(r'^admin/', admin.site.urls),
path('', RedirectView.as_view(url='/blog/', permanent=True)),
re_path(r'^blog/', include('zinnia.urls')),
re_path(r'^comments/', include('django_comments.urls')),
path('xmlrpc/', handle_xmlrpc),
re_path(r'^i18n/', include('django.conf.urls.i18n')),
re_path(r'^admin/doc/', include('django.contrib.admindocs.urls')),
re_path(r'^admin/', admin.site.urls),
]

sitemaps = {
Expand All @@ -40,23 +40,23 @@
}

urlpatterns += [
url(r'^sitemap.xml$',
re_path(r'^sitemap.xml$',
index,
{'sitemaps': sitemaps}),
url(r'^sitemap-(?P<section>.+)\.xml$',
re_path(r'^sitemap-(?P<section>.+)\.xml$',
sitemap,
{'sitemaps': sitemaps}),
]

urlpatterns += [
url(r'^400/$', partial(bad_request, exception=None)),
url(r'^403/$', partial(permission_denied, exception=None)),
url(r'^404/$', partial(page_not_found, exception=None)),
url(r'^500/$', server_error),
path('400/', partial(bad_request, exception=None)),
path('403/', partial(permission_denied, exception=None)),
path('404/', partial(page_not_found, exception=None)),
path('500/', server_error),
]

if settings.DEBUG:
urlpatterns += [
url(r'^media/(?P<path>.*)$', serve,
re_path(r'^media/(?P<path>.*)$', serve,
{'document_root': settings.MEDIA_ROOT})
]
6 changes: 3 additions & 3 deletions docs/extensions/zinnia_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import inspect

from django.db import models
from django.utils.encoding import force_text
from django.utils.encoding import force_str
from django.utils.html import strip_tags


Expand All @@ -22,10 +22,10 @@ def process_model_docstring(app, what, name, obj, options, lines):
if inspect.isclass(obj) and issubclass(obj, models.Model):
for field in obj._meta.fields:
# Decode and strip any html out of the field's help text
help_text = strip_tags(force_text(field.help_text))
help_text = strip_tags(force_str(field.help_text))
# Decode and capitalize the verbose name, for use if there isn't
# any help text
verbose_name = force_text(field.verbose_name).capitalize()
verbose_name = force_str(field.verbose_name).capitalize()

if help_text:
lines.append(':param %s: %s' % (field.attname, help_text))
Expand Down
2 changes: 1 addition & 1 deletion zinnia/breadcrumbs.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def wrapper(path, model, page, root_name):
path = PAGE_REGEXP.sub('', path)
breadcrumbs = func(path, model, root_name)
if page:
if page.number > 1:
if page.number > 1 and breadcrumbs:
breadcrumbs[-1].url = path
page_crumb = Crumb(_('Page %s') % page.number)
breadcrumbs.append(page_crumb)
Expand Down
19 changes: 19 additions & 0 deletions zinnia/migrations/0006_alter_entry_related.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Generated by Django 4.1.10 on 2023-10-02 09:45

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
("zinnia", "0005_category_mptt_update"),
]

operations = [
migrations.AlterField(
model_name="entry",
name="related",
field=models.ManyToManyField(
blank=True, to="zinnia.entry", verbose_name="related entries"
),
),
]
4 changes: 2 additions & 2 deletions zinnia/signals.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
PINGBACK_WF_COUNT_PINGBACKS = 'zinnia.pingback.was_flagged.count_pingbacks'
TRACKBACK_WF_COUNT_TRACKBACKS = 'zinnia.trackback.was_flagged.count_trackbacks'

pingback_was_posted = Signal(providing_args=['pingback', 'entry'])
trackback_was_posted = Signal(providing_args=['trackback', 'entry'])
pingback_was_posted = Signal()
trackback_was_posted = Signal()


def disable_for_loaddata(signal_handler):
Expand Down
2 changes: 1 addition & 1 deletion zinnia/templates/admin/zinnia/app_index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% extends "admin/app_index.html" %}
{% load i18n staticfiles %}
{% load i18n static %}

{% block extrastyle %}
{{ block.super }}
Expand Down
2 changes: 1 addition & 1 deletion zinnia/templates/comments/zinnia/entry/form.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
{% for field in form %}
{% if field.is_hidden %}{{ field }}{% else %}
{% if user.email and field.name in "namemailurl" %}{% else %}
<div{% if field.errors %} class="error"{% endif %}{% ifequal field.name "honeypot" %} style="display:none;"{% endifequal %}>
<div{% if field.errors %} class="error"{% endif %}{% if field.name == "honeypot" %} style="display:none;"{% endif %}>
{{ field.label_tag }}
{% if field.errors %}{{ field.errors }}{% endif %}
{{ field }}
Expand Down
2 changes: 1 addition & 1 deletion zinnia/templates/zinnia/opensearch.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load i18n staticfiles zinnia %}{% get_tags as entry_tags %}<?xml version="1.0" encoding="UTF-8"?>
{% load i18n static zinnia %}{% get_tags as entry_tags %}<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
xmlns:moz="http://www.mozilla.org/2006/browser/search/">
<ShortName>{{ site.name }}</ShortName>
Expand Down
2 changes: 1 addition & 1 deletion zinnia/templates/zinnia/skeleton.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% load staticfiles %}
{% load static %}
<!doctype html>
<html lang="{{ LANGUAGE_CODE }}">
<head>
Expand Down
2 changes: 1 addition & 1 deletion zinnia/templates/zinnia/tags/entries_slider.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% load staticfiles %}
{% load static %}
{% if entries %}
<div class="slider-container">
<div class="slider">
Expand Down
18 changes: 9 additions & 9 deletions zinnia/templates/zinnia/tags/pagination.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,40 +13,40 @@
{% endif %}

{% for page_number in begin %}
<li class="page{% ifequal page.number page_number %} current{% endifequal %}">
{% ifequal page.number page_number %}
<li class="page{% if page.number == page_number %} current{% endif %}">
{% if page.number == page_number %}
{{ page_number }}
{% else %}
<a href="?page={{ page_number }}{{ GET_string }}"
title="{% trans "Entries page" %} {{ page_number }}">{{ page_number }}</a>
{% endifequal%}
{% endif %}
</li>
{% endfor %}

{% if middle %}
<li class="ellipsis">&hellip;</li>
{% for page_number in middle %}
<li class="page{% ifequal page.number page_number %} current{% endifequal %}">
{% ifequal page.number page_number %}
<li class="page{% if page.number == page_number %} current{% endif %}">
{% if page.number == page_number %}
{{ page_number }}
{% else %}
<a href="?page={{ page_number }}{{ GET_string }}"
title="{% trans "Entries page" %} {{ page_number }}">{{ page_number }}</a>
{% endifequal%}
{% endif %}
</li>
{% endfor %}
{% endif %}

{% if end %}
<li class="ellipsis">&hellip;</li>
{% for page_number in end %}
<li class="page{% ifequal page.number page_number %} current{% endifequal %}">
{% ifequal page.number page_number %}
<li class="page{% if page.number == page_number %} current{% endif %}">
{% if page.number == page_number %}
{{ page_number }}
{% else %}
<a href="?page={{ page_number }}{{ GET_string }}"
title="{% trans "Entries page" %} {{ page_number }}">{{ page_number }}</a>
{% endifequal%}
{% endif %}
</li>
{% endfor %}
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion zinnia/templates/zinnia/tags/search_form.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{% load i18n %}
{% load staticfiles %}
{% load static %}
<form method="get" id="searchform" action="{% url 'zinnia:entry_search' %}">
<p>
<input type="text" name="pattern" id="searchbox" placeholder="{% trans "Keywords..." %}" {% if pattern %}value="{{ pattern }}"{% endif %} />
Expand Down
2 changes: 1 addition & 1 deletion zinnia/templates/zinnia/wlwmanifest.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{% load i18n staticfiles zinnia %}<?xml version="1.0" encoding="utf-8" ?>
{% load i18n static zinnia %}<?xml version="1.0" encoding="utf-8" ?>
<manifest xmlns="http://schemas.microsoft.com/wlw/manifest/weblog">
<options>
<clientType>Metaweblog</clientType>
Expand Down
14 changes: 7 additions & 7 deletions zinnia/tests/implementations/urls/custom_detail_views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"""Test urls for the zinnia project"""
from django.conf.urls import url
from django.urls import path, re_path

from zinnia.tests.implementations.urls.default import (
urlpatterns as test_urlpatterns)
Expand Down Expand Up @@ -35,22 +35,22 @@ class CustomCategoryDetail(CustomModelDetailMixin, CategoryDetail):


urlpatterns = [
url(r'^authors/(?P<username>[.+-@\w]+)/$',
re_path(r'^authors/(?P<username>[.+-@\w]+)/$',
CustomAuthorDetail.as_view(),
name='zinnia_author_detail'),
url(r'^authors/(?P<username>[.+-@\w]+)/page/(?P<page>\d+)/$',
re_path(r'^authors/(?P<username>[.+-@\w]+)/page/(?P<page>\d+)/$',
CustomAuthorDetail.as_view(),
name='zinnia_author_detail_paginated'),
url(r'^categories/(?P<path>[-\/\w]+)/page/(?P<page>\d+)/$',
re_path(r'^categories/(?P<path>[-\/\w]+)/page/(?P<page>\d+)/$',
CustomCategoryDetail.as_view(),
name='zinnia_category_detail_paginated'),
url(r'^categories/(?P<path>[-\/\w]+)/$',
re_path(r'^categories/(?P<path>[-\/\w]+)/$',
CustomCategoryDetail.as_view(),
name='zinnia_category_detail'),
url(r'^tags/(?P<tag>[^/]+)/$',
path('tags/<str:tag>/',
CustomTagDetail.as_view(),
name='zinnia_tag_detail'),
url(r'^tags/(?P<tag>[^/]+)/page/(?P<page>\d+)/$',
path('tags/<str:tag>/page/<int:page>/',
CustomTagDetail.as_view(),
name='zinnia_tag_detail_paginated'),
] + test_urlpatterns
12 changes: 6 additions & 6 deletions zinnia/tests/implementations/urls/default.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"""Test urls for the zinnia project"""
from django.conf.urls import include
from django.conf.urls import url
from django.urls import include, path, re_path
from django.contrib import admin

from django_xmlrpc.views import handle_xmlrpc
Expand All @@ -10,9 +10,9 @@
admin.autodiscover()

urlpatterns = [
url(r'^', include('zinnia.urls')),
url(r'^channel-test/$', EntryChannel.as_view(query='test')),
url(r'^comments/', include('django_comments.urls')),
url(r'^xmlrpc/$', handle_xmlrpc),
url(r'^admin/', admin.site.urls),
re_path(r'^', include('zinnia.urls')),
path('channel-test/', EntryChannel.as_view(query='test')),
re_path(r'^comments/', include('django_comments.urls')),
path('xmlrpc/', handle_xmlrpc),
re_path(r'^admin/', admin.site.urls),
]
8 changes: 4 additions & 4 deletions zinnia/tests/implementations/urls/poor.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
"""Poor test urls for the zinnia project"""
from django.conf.urls import include
from django.conf.urls import url
from django.urls import include, re_path
from django.contrib import admin

from zinnia.views.entries import EntryDetail

admin.autodiscover()

blog_urls = ([
url(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<slug>[-\w]+)/$',
re_path(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<slug>[-\w]+)/$',
EntryDetail.as_view(),
name='entry_detail')],
'zinnia'
)

urlpatterns = [
url(r'^', include(blog_urls)),
url(r'^admin/', admin.site.urls),
re_path(r'^', include(blog_urls)),
re_path(r'^admin/', admin.site.urls),
]
31 changes: 15 additions & 16 deletions zinnia/urls/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
"""Defaults urls for the Zinnia project"""
from django.conf.urls import include
from django.conf.urls import url
from django.urls import include, re_path
from django.utils.translation import gettext_lazy

from zinnia.settings import TRANSLATED_URLS
Expand All @@ -20,18 +19,18 @@ def i18n_url(url, translate=TRANSLATED_URLS):
app_name = 'zinnia'

urlpatterns = [
url(_(r'^feeds/'), include('zinnia.urls.feeds')),
url(_(r'^tags/'), include('zinnia.urls.tags')),
url(_(r'^authors/'), include('zinnia.urls.authors')),
url(_(r'^categories/'), include('zinnia.urls.categories')),
url(_(r'^search/'), include('zinnia.urls.search')),
url(_(r'^random/'), include('zinnia.urls.random')),
url(_(r'^sitemap/'), include('zinnia.urls.sitemap')),
url(_(r'^trackback/'), include('zinnia.urls.trackback')),
url(_(r'^comments/'), include('zinnia.urls.comments')),
url(r'^', include('zinnia.urls.entries')),
url(r'^', include('zinnia.urls.archives')),
url(r'^', include('zinnia.urls.shortlink')),
url(r'^', include('zinnia.urls.quick_entry')),
url(r'^', include('zinnia.urls.capabilities')),
re_path(_(r'^feeds/'), include('zinnia.urls.feeds')),
re_path(_(r'^tags/'), include('zinnia.urls.tags')),
re_path(_(r'^authors/'), include('zinnia.urls.authors')),
re_path(_(r'^categories/'), include('zinnia.urls.categories')),
re_path(_(r'^search/'), include('zinnia.urls.search')),
re_path(_(r'^random/'), include('zinnia.urls.random')),
re_path(_(r'^sitemap/'), include('zinnia.urls.sitemap')),
re_path(_(r'^trackback/'), include('zinnia.urls.trackback')),
re_path(_(r'^comments/'), include('zinnia.urls.comments')),
re_path(r'^', include('zinnia.urls.entries')),
re_path(r'^', include('zinnia.urls.archives')),
re_path(r'^', include('zinnia.urls.shortlink')),
re_path(r'^', include('zinnia.urls.quick_entry')),
re_path(r'^', include('zinnia.urls.capabilities')),
]
Loading