Skip to content

Commit

Permalink
feat: Add Django 2.2 compatability (#1956)
Browse files Browse the repository at this point in the history
* Try and fix admin link error

* Try and fix admin link error mk2

* Try and fix admin link error mk2

* Try and fix admin link error mk3

* try and fix the thing

* A better registration message

* Fix broken admin link thing

* Fix broken admin link thing

* Fix my bad imports

* Fix drag and drop issues

* Attempt to fix the related manager error

* Some merge updates I think?

* Require Treebeard to use its manager with displayable models
(Althon sitemap bug)
Some merge updates I think?

* Undo my treebeard changes

* Overshard's S3 speedup

* Add REPLY_TO_EMAIL setting

* Fix for when we don't have a reply_to

* Bump django install requires version

* Fixes for django 2.2

* Add messages to installed apps

* Fix for the broken sitemaps and link system

* Rollback template tags

* Fix Token_type errors

* Fix allowed_hosts

* Refactor keywords_fields to work with Django 2.2

* Take media out of static directory

* Fix TokenType

* Fix line length issues

* Add removed TokenType import

* Fix password reset test

* Backwards compat changes to mezzanine tags

* Fixes for next_url

* Fix setup.py requirements

* Remove future imports from accounts

* Remove future imports from bin

* Remove future imports from blog

* Fix imports for rss and tumblr import commands

* Add additional breadcrumb classes

* Use 2.0 compatible urls for blog pages

* Remove future imports for boot

* Remove future imports for conf

* Remove future imports for core

* 2.0 compat urls for core

* Fix metaclass for core models

* Fix future imports for auth_backends.py

* Remove additional jquery ui from core admin (it's loaded in the base instead)

* Remove future imports from forms

* Remove future imports from galleries

* Remove future imports from generic

* 2.0 compatible urls for generic

* Remove future imports from pages

* 2.0 compatible urls for pages

* version bump nestedSortable

* Add additional classes for page menus

* version bump bootstrap

* fix ajax_csrf and keywords fields

* Fix token_type

* Fix page tree sortable

* Revert "version bump bootstrap"

This reverts commit 3eb8157

* Bump jquery file versions

* Fix indentation

* Add localhost and 127.0.01 to ALLOWED_HOSTS

* Fix blog url

* Update tox to use new python and django

* Revert "Move jQuery setup for ajax/csrf outside of document.ready handler."

This reverts commit 543c437

* Rollback version number

* Changes based on code review

* Changes based on code review

* Fix URLs for Python 3.5

* Tox test py3.5

* Update travis

* Update travis

* Fix adding link inlines. Mezzanine issue #1634

* Style fix for M2M widget

* Revert menu changes made in August

* Update tox to test against the fermor fork rather than the master

* Make widget scripts load in correct order in dj2.2

Make all admin widget which rely on window.jQuery load jquery.init.js
and all that rely on window.django.jQuery also load jquery.js as per 2.2
upgrade instructions

* Disable required on TinyMceWidget textareas, allowing forms with required fields to submit on dj2.2

TinyMCE does not put content back into the <textarea>, so we want to
allow it to submit when empty. Currently a form with a required field
with a TinyMceWidget would be impossible to submit and no error would
show since the textarea has been hidden.

* Roll back page_tree based review

* Django required version < 3

* Version bump of nestedSortable

* https://stackoverflow.com/questions/54336787

* caracteres extraños en plantilla

* PEP8 Fix

* Limit admin thumb images to 100%

* Remove fermor specific style overrides

* Styles for page-model and readonly textareas

* Rename admin CSS class "field-box" to "fieldBox".

(This addresses a change made in Django 2.1 to fix
Django bug #29248.)

* Updated formfield_for_dbfield() calls to include request argument

* PEP8 (black) formatting

* Fix __admin_media_prefix__ pointing to nonexistent resource

It breaks sites on production that use the ManifestStaticFilesStorage.

For such cases, Django provides the "get_static_prefix" template tag.

But it's an incitement to bypass the storage mechanism to produce the
URL to cache (by appending a hash in this case).

And I don't understand how it could work with more "exotic" yet valid
backends relying on cloud storage or CDNs, where the source file path
and the URL path won't match one to one.

I advise against this usage and call for its deprecation.

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

Co-authored-by: Frankie Robertson <[email protected]>
Co-authored-by: Marcos Sánchez Provencio <[email protected]>
Co-authored-by: zriv <[email protected]>
Co-authored-by: Tuk Bredsdorff <[email protected]>
Co-authored-by: Peter Dermott <peter.dermott@:gmail.com>
Co-authored-by: Diego Rabatone Oliveira <[email protected]>
  • Loading branch information
7 people authored Aug 12, 2020
1 parent 7624b8f commit db62ee5
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 db62ee5

Please sign in to comment.