Skip to content

Commit

Permalink
feat: Add Django 2.2 compatability (#1956)
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Support for Python 2 and Django < 2.2 has been dropped

From: bors-ltd@88aa6c9
Related to: #1895

Co-authored-by: Frankie Robertson <frankie@robertson.name>
Co-authored-by: Marcos Sánchez Provencio <marcos@meteogrid.com>
Co-authored-by: zriv <zriv@users.noreply.github.com>
Co-authored-by: Tuk Bredsdorff <tukodeb@gmail.com>
Co-authored-by: Peter Dermott <peter.dermott@:gmail.com>
Co-authored-by: Diego Rabatone Oliveira <diraol@diraol.eng.br>
  • Loading branch information
7 people authored and jerivas committed Aug 18, 2020
1 parent 7624b8f commit 9768b46
Show file tree
Hide file tree
Showing 150 changed files with 41,135 additions and 751 deletions.
12 changes: 3 additions & 9 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
language: python
env:
- DJANGO="111"
- DJANGO="20"
- DJANGO="21"
- DJANGO="22"
- DJANGO="master"
python:
- "3.5"
Expand All @@ -16,12 +14,8 @@ script:
matrix:
fast_finish: true
include:
- python: "2.7"
env: DJANGO="111"
- python: "3.4"
env: DJANGO="111"
- python: "3.4"
env: DJANGO="20"
- python: "3.5"
env: DJANGO="22"
allow_failures:
- env: DJANGO="master"
notifications:
Expand Down
1 change: 0 additions & 1 deletion mezzanine/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@

__version__ = "4.3.1"
2 changes: 0 additions & 2 deletions mezzanine/accounts/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
setting. Some utility functions for probing the profile model are
included below.
"""
from __future__ import unicode_literals

from django.apps import apps
from django.conf import settings
from django.contrib.auth import get_user_model
Expand Down
2 changes: 0 additions & 2 deletions mezzanine/accounts/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from django.contrib import admin
from django.contrib.auth import get_user_model
from mezzanine.accounts import get_profile_model, ProfileNotConfigured
Expand Down
2 changes: 0 additions & 2 deletions mezzanine/accounts/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
that are only read during startup shouldn't be editable, since changing
them would require an application reload.
"""
from __future__ import unicode_literals

from django.utils.translation import ugettext_lazy as _

from mezzanine.conf import register_setting
Expand Down
2 changes: 0 additions & 2 deletions mezzanine/accounts/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from django.contrib.auth import authenticate, get_user_model
from django.contrib.auth.tokens import default_token_generator
from django.db.models import Q
Expand Down
2 changes: 0 additions & 2 deletions mezzanine/accounts/templatetags/accounts_tags.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from collections import OrderedDict

from django.contrib.auth import get_user_model
Expand Down
2 changes: 0 additions & 2 deletions mezzanine/accounts/tests.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from django.contrib.auth import get_user_model
from django.contrib.auth.tokens import default_token_generator
from django.core import mail
Expand Down
2 changes: 0 additions & 2 deletions mezzanine/accounts/views.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from django.contrib.auth import (login as auth_login, authenticate,
logout as auth_logout, get_user_model)
from django.contrib.auth.decorators import login_required
Expand Down
2 changes: 0 additions & 2 deletions mezzanine/bin/runtests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#!/usr/bin/env python
from __future__ import unicode_literals

import atexit
import os
import shutil
Expand Down
2 changes: 0 additions & 2 deletions mezzanine/blog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,4 @@
Provides a blogging app with posts, keywords, categories and comments.
Posts can be listed by month, keyword, category or author.
"""
from __future__ import unicode_literals

from mezzanine import __version__ # noqa
2 changes: 0 additions & 2 deletions mezzanine/blog/admin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from copy import deepcopy

from django.contrib import admin
Expand Down
2 changes: 0 additions & 2 deletions mezzanine/blog/defaults.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
that are only read during startup shouldn't be editable, since changing
them would require an application reload.
"""
from __future__ import unicode_literals

from django.conf import settings
from django.utils.translation import ugettext_lazy as _

Expand Down
2 changes: 0 additions & 2 deletions mezzanine/blog/feeds.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from django.contrib.auth import get_user_model
from django.contrib.sites.models import Site
from django.contrib.syndication.views import Feed, add_domain
Expand Down
2 changes: 0 additions & 2 deletions mezzanine/blog/forms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from django import forms

from mezzanine.blog.models import BlogPost
Expand Down
7 changes: 1 addition & 6 deletions mezzanine/blog/management/base.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
from __future__ import print_function, unicode_literals
from future.builtins import input, int
try:
from urllib.parse import urlparse
except:
from urlparse import urlparse
from urllib.parse import urlparse

from django.contrib.auth import get_user_model
from django.contrib.redirects.models import Redirect
Expand Down
2 changes: 0 additions & 2 deletions mezzanine/blog/management/commands/import_blogger.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from datetime import datetime, timedelta
from time import timezone
import re
Expand Down
2 changes: 0 additions & 2 deletions mezzanine/blog/management/commands/import_posterous.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from datetime import datetime
import json
import time
Expand Down
11 changes: 3 additions & 8 deletions mezzanine/blog/management/commands/import_rss.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
from __future__ import unicode_literals

from datetime import timedelta
from time import timezone
try:
from urllib.request import urlopen
from urllib.parse import urljoin
except ImportError:
from urllib import urlopen
from urlparse import urljoin

from urllib.request import urlopen
from urllib.parse import urljoin

from django.core.management.base import CommandError

Expand Down
9 changes: 1 addition & 8 deletions mezzanine/blog/management/commands/import_tumblr.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
from __future__ import print_function
from __future__ import unicode_literals
from future.builtins import int

from datetime import datetime
from json import loads
from time import sleep

try:
from urllib.request import urlopen
except ImportError:
from urllib import urlopen
from urllib.request import urlopen

from django.core.management.base import CommandError
from django.utils.html import strip_tags
Expand Down
3 changes: 0 additions & 3 deletions mezzanine/blog/management/commands/import_wordpress.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import unicode_literals
from future.builtins import int

from collections import defaultdict
from datetime import datetime, timedelta
import re
Expand Down
2 changes: 0 additions & 2 deletions mezzanine/blog/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations
import mezzanine.core.fields
import mezzanine.utils.models
Expand Down
2 changes: 0 additions & 2 deletions mezzanine/blog/migrations/0002_auto_20150527_1555.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import models, migrations


Expand Down
3 changes: 0 additions & 3 deletions mezzanine/blog/migrations/0003_auto_20170411_0504.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11 on 2017-04-11 05:04
from __future__ import unicode_literals

from django.db import migrations, models


Expand Down
3 changes: 0 additions & 3 deletions mezzanine/blog/models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import unicode_literals
from future.builtins import str

from django.db import models
from django.urls import reverse
from django.utils.translation import ugettext_lazy as _
Expand Down
2 changes: 1 addition & 1 deletion mezzanine/blog/templates/blog/blog_post_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

{% block breadcrumb_menu %}
{{ block.super }}
<li class="active">{{ blog_post.title }}</li>
<li class="breadcrumb-item active">{{ blog_post.title }}</li>
{% endblock %}

{% block main %}
Expand Down
2 changes: 1 addition & 1 deletion mezzanine/blog/templates/blog/blog_post_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
{% block breadcrumb_menu %}
{{ block.super }}
{% if tag or category or year or month or author %}
<li>{% spaceless %}
<li class="breadcrumb-item active">{% spaceless %}
{% if tag %}
{% trans "Tag:" %} {{ tag }}
{% else %}{% if category %}
Expand Down
1 change: 0 additions & 1 deletion mezzanine/blog/templatetags/blog_tags.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from __future__ import unicode_literals
from datetime import datetime

from django.contrib.auth import get_user_model
Expand Down
7 changes: 1 addition & 6 deletions mezzanine/blog/tests.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
from __future__ import unicode_literals

import re
import pytz
import datetime
from unittest import skipUnless

try:
from urllib.parse import urlparse
except ImportError:
from urlparse import urlparse
from urllib.parse import urlparse

from django.urls import reverse
from django.template import Context, Template
Expand Down
32 changes: 15 additions & 17 deletions mezzanine/blog/urls.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
from __future__ import unicode_literals

from django.conf.urls import url
from django.urls import re_path

from mezzanine.blog import views
from mezzanine.conf import settings
Expand All @@ -11,32 +9,32 @@

# Blog patterns.
urlpatterns = [
url(r"^feeds/(?P<format>.*)%s$" % _slash,
re_path(r"^feeds/(?P<format>.*)%s$" % _slash,
views.blog_post_feed, name="blog_post_feed"),
url(r"^tag/(?P<tag>.*)/feeds/(?P<format>.*)%s$" % _slash,
re_path(r"^tag/(?P<tag>.*)/feeds/(?P<format>.*)%s$" % _slash,
views.blog_post_feed, name="blog_post_feed_tag"),
url(r"^tag/(?P<tag>.*)%s$" % _slash,
re_path(r"^tag/(?P<tag>.*)%s$" % _slash,
views.blog_post_list, name="blog_post_list_tag"),
url(r"^category/(?P<category>.*)/feeds/(?P<format>.*)%s$" % _slash,
re_path(r"^category/(?P<category>.*)/feeds/(?P<format>.*)%s$" % _slash,
views.blog_post_feed, name="blog_post_feed_category"),
url(r"^category/(?P<category>.*)%s$" % _slash,
re_path(r"^category/(?P<category>.*)%s$" % _slash,
views.blog_post_list, name="blog_post_list_category"),
url(r"^author/(?P<username>.*)/feeds/(?P<format>.*)%s$" % _slash,
re_path(r"^author/(?P<username>.*)/feeds/(?P<format>.*)%s$" % _slash,
views.blog_post_feed, name="blog_post_feed_author"),
url(r"^author/(?P<username>.*)%s$" % _slash,
re_path(r"^author/(?P<username>.*)%s$" % _slash,
views.blog_post_list, name="blog_post_list_author"),
url(r"^archive/(?P<year>\d{4})/(?P<month>\d{1,2})%s$" % _slash,
re_path(r"^archive/(?P<year>\d{4})/(?P<month>\d{1,2})%s$" % _slash,
views.blog_post_list, name="blog_post_list_month"),
url(r"^archive/(?P<year>\d{4})%s$" % _slash,
re_path(r"^archive/(?P<year>\d{4})%s$" % _slash,
views.blog_post_list, name="blog_post_list_year"),
url(r"^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/"
re_path(r"^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<day>\d{1,2})/"
"(?P<slug>.*)%s$" % _slash,
views.blog_post_detail, name="blog_post_detail_day"),
url(r"^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<slug>.*)%s$" % _slash,
re_path(r"^(?P<year>\d{4})/(?P<month>\d{1,2})/(?P<slug>.*)%s$" % _slash,
views.blog_post_detail, name="blog_post_detail_month"),
url(r"^(?P<year>\d{4})/(?P<slug>.*)%s$" % _slash,
re_path(r"^(?P<year>\d{4})/(?P<slug>.*)%s$" % _slash,
views.blog_post_detail, name="blog_post_detail_year"),
url(r"^(?P<slug>.*)%s$" % _slash,
re_path(r"^(?P<slug>.*)%s$" % _slash,
views.blog_post_detail, name="blog_post_detail"),
url(r"^$", views.blog_post_list, name="blog_post_list"),
re_path(r"^$", views.blog_post_list, name="blog_post_list"),
]
3 changes: 0 additions & 3 deletions mezzanine/blog/views.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import unicode_literals
from future.builtins import str, int

from calendar import month_name

from django.contrib.auth import get_user_model
Expand Down
2 changes: 0 additions & 2 deletions mezzanine/boot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
custom fields not being available when custom admin classes are
registered.
"""
from __future__ import unicode_literals

from collections import defaultdict

from django import VERSION as DJANGO_VERSION
Expand Down
3 changes: 0 additions & 3 deletions mezzanine/conf/admin.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import unicode_literals
from future.builtins import str

from copy import copy

from django.contrib import admin
Expand Down
3 changes: 0 additions & 3 deletions mezzanine/conf/forms.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import unicode_literals
from future.builtins import int

from collections import defaultdict

from django import forms
Expand Down
4 changes: 0 additions & 4 deletions mezzanine/conf/models.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
from __future__ import unicode_literals

from django.db import models
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import python_2_unicode_compatible

from mezzanine.core.models import SiteRelated


@python_2_unicode_compatible
class Setting(SiteRelated):
"""
Stores values for ``mezzanine.conf`` that can be edited via the admin.
Expand Down
3 changes: 0 additions & 3 deletions mezzanine/conf/tests.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
from __future__ import unicode_literals
from future.builtins import bytes, str

import sys
from unittest import skipUnless
import warnings
Expand Down
2 changes: 0 additions & 2 deletions mezzanine/core/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
Provides abstract models and admin features used throughout the various
Mezzanine apps.
"""
from __future__ import unicode_literals

from mezzanine import __version__ # noqa


Expand Down
5 changes: 3 additions & 2 deletions mezzanine/core/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class BaseTranslationModelAdmin(TranslationAdmin):
"""
class Media:
js = (
'admin/js/jquery.init.js',
static("modeltranslation/js/force_jquery.js"),
static("mezzanine/js/%s" % settings.JQUERY_UI_FILENAME),
static("mezzanine/js/admin/tabbed_translation_fields.js"),
)
css = {
Expand Down Expand Up @@ -301,7 +301,8 @@ def __init__(self, *args, **kwargs):
self.model._meta.many_to_many)
for field in reversed(fields):
if field.name not in exclude_fields and field.editable:
if not hasattr(field, "translated_field"):
if not hasattr(field, "translated_field") and field.name \
not in self.fieldsets[0][1]["fields"]:
self.fieldsets[0][1]["fields"].insert(3, field.name)

@property
Expand Down
2 changes: 0 additions & 2 deletions mezzanine/core/apps.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from django import VERSION as DJANGO_VERSION
from django.apps import AppConfig

Expand Down
2 changes: 0 additions & 2 deletions mezzanine/core/auth_backends.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from django.contrib.auth import get_user_model
from django.contrib.auth.backends import ModelBackend
from django.contrib.auth.tokens import default_token_generator
Expand Down
Loading

0 comments on commit 9768b46

Please sign in to comment.