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

Add Django 3.2 support #27

Open
wants to merge 2 commits into
base: master
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
31 changes: 0 additions & 31 deletions CHANGELOG.rst

This file was deleted.

4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ INSTALLED_APPS += [
'aldryn_redirects'
]

# add the middleware somewhere near the top of MIDDLEWARE_CLASSES
# add the middleware somewhere near the top of MIDDLEWARE

MIDDLEWARE_CLASSES.insert(
MIDDLEWARE.insert(
0, 'aldryn_redirects.middleware.RedirectFallbackMiddleware')
```
2 changes: 1 addition & 1 deletion aldryn_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@
class Form(forms.BaseForm):
def to_settings(self, data, settings):
# No need to setup django-parler. That is already done in aldryn-django-cms
settings['MIDDLEWARE_CLASSES'].insert(0, 'aldryn_redirects.middleware.RedirectFallbackMiddleware')
settings['MIDDLEWARE'].insert(0, 'aldryn_redirects.middleware.RedirectFallbackMiddleware')
return settings
4 changes: 1 addition & 3 deletions aldryn_redirects/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
__version__ = '1.3.7'

__version__ = '1.4.0'

default_app_config = 'aldryn_redirects.apps.AldrynRedirects'
16 changes: 7 additions & 9 deletions aldryn_redirects/admin.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
from __future__ import unicode_literals

from tablib import Dataset

from django.conf import settings
from django.contrib import admin, messages
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.http import HttpResponse
from django.shortcuts import redirect, render
from django.utils import timezone
from django.utils.translation import ugettext_lazy as _, ugettext
from django.utils.translation import gettext_lazy as _, gettext

from parler.admin import TranslatableAdmin

Expand All @@ -18,7 +16,7 @@
from .models import Redirect, StaticRedirect, StaticRedirectInboundRouteQueryParam


class DeletionMixin(object):
class DeletionMixin():
actions = ['delete_selected']

def delete_selected(self, request, queryset):
Expand Down Expand Up @@ -118,8 +116,8 @@ def import_view(self, request):
'root_path': reverse('admin:index'),
'current_app': self.admin_site.name,
'app_label': opts.app_label,
'title': ugettext('Import redirects'),
'original': ugettext('Import redirects'),
'title': gettext('Import redirects'),
'original': gettext('Import redirects'),
'errors': form.errors,
}
return render(request, 'admin/aldryn_redirects/redirect/import_form.html', context)
Expand Down Expand Up @@ -211,8 +209,8 @@ def import_view(self, request):
'root_path': reverse('admin:index'),
'current_app': self.admin_site.name,
'app_label': opts.app_label,
'title': ugettext('Import redirects'),
'original': ugettext('Import redirects'),
'title': gettext('Import redirects'),
'original': gettext('Import redirects'),
'errors': form.errors,
}
return render(request, 'admin/aldryn_redirects/staticredirect/import_form.html', context)
Expand Down
1 change: 0 additions & 1 deletion aldryn_redirects/apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django.apps import AppConfig


Expand Down
4 changes: 1 addition & 3 deletions aldryn_redirects/forms.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
from __future__ import unicode_literals

from tablib import Dataset

from django import forms
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from .importers import RedirectImporter, StaticRedirectImporter

Expand Down
8 changes: 4 additions & 4 deletions aldryn_redirects/importers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

from django.contrib.sites.models import Site
from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from .models import Redirect, StaticRedirect
from .utils import get_query_params_dict, remove_query_params


class FlattenErrorMixin(object):
class FlattenErrorMixin():

def flatten_error(self, e):
result = []
Expand All @@ -19,7 +19,7 @@ def flatten_error(self, e):
return '\n'.join(result)


class RedirectImporter(FlattenErrorMixin, object):
class RedirectImporter(FlattenErrorMixin):

def __init__(self):
self.sites_per_domain = {site.domain: site for site in Site.objects.all()}
Expand Down Expand Up @@ -92,7 +92,7 @@ def validate_row(self, row):
raise ValidationError(self.flatten_error(e))


class StaticRedirectImporter(FlattenErrorMixin, object):
class StaticRedirectImporter(FlattenErrorMixin):

def __init__(self):
self.sites_per_domain = {site.domain: site for site in Site.objects.all()}
Expand Down
2 changes: 0 additions & 2 deletions aldryn_redirects/managers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import unicode_literals

from django.conf import settings
from django.db import models

Expand Down
5 changes: 2 additions & 3 deletions aldryn_redirects/middleware.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
from __future__ import unicode_literals

from django import http
from django.conf import settings
from django.contrib.sites.models import Site
from django.db.models import Q
from django.utils.deprecation import MiddlewareMixin

from .models import Redirect, StaticRedirect


class RedirectFallbackMiddleware(object):
class RedirectFallbackMiddleware(MiddlewareMixin):
def process_request(self, request):
static_redirect = StaticRedirect.objects.get_for_request(request)
if static_redirect:
Expand Down
7 changes: 2 additions & 5 deletions aldryn_redirects/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models


Expand All @@ -16,7 +13,7 @@ class Migration(migrations.Migration):
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('old_path', models.CharField(help_text="This should be an absolute path, excluding the domain name. Example: '/events/search/'.", max_length=200, verbose_name='redirect from', db_index=True)),
('site', models.ForeignKey(related_name='redirects_hvad_set', to='sites.Site')),
('site', models.ForeignKey(related_name='redirects_hvad_set', to='sites.Site', on_delete=models.deletion.CASCADE)),
],
options={
'ordering': ('old_path',),
Expand All @@ -30,7 +27,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('new_path', models.CharField(help_text="This can be either an absolute path (as above) or a full URL starting with 'http://'.", max_length=200, verbose_name='redirect to', blank=True)),
('language_code', models.CharField(max_length=15, db_index=True)),
('master', models.ForeignKey(related_name='translations', editable=False, to='aldryn_redirects.Redirect', null=True)),
('master', models.ForeignKey(related_name='translations', editable=False, to='aldryn_redirects.Redirect', null=True, on_delete=models.deletion.CASCADE)),
],
options={
'managed': True,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.2 on 2016-02-22 08:03
from __future__ import unicode_literals

from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
Expand All @@ -20,7 +16,7 @@ class Migration(migrations.Migration):
migrations.AlterField(
model_name='redirect',
name='site',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='aldryn_redirects_redirect_set', to='sites.Site'),
field=models.ForeignKey(on_delete=models.deletion.CASCADE, related_name='aldryn_redirects_redirect_set', to='sites.Site'),
),
migrations.AlterField(
model_name='redirecttranslation',
Expand Down
6 changes: 1 addition & 5 deletions aldryn_redirects/migrations/0003_auto_20171206_1150.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2017-12-06 13:50
from __future__ import unicode_literals

import aldryn_redirects.validators
from django.db import migrations, models
import django.db.models.deletion


class Migration(migrations.Migration):
Expand Down Expand Up @@ -34,7 +30,7 @@ class Migration(migrations.Migration):
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('key', models.CharField(max_length=255, verbose_name='Key')),
('value', models.CharField(blank=True, max_length=255, verbose_name='Value')),
('static_redirect', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='query_params', to='aldryn_redirects.StaticRedirect')),
('static_redirect', models.ForeignKey(on_delete=models.deletion.CASCADE, related_name='query_params', to='aldryn_redirects.StaticRedirect')),
],
),
migrations.AlterModelOptions(
Expand Down
3 changes: 0 additions & 3 deletions aldryn_redirects/migrations/0004_auto_20171208_1702.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2017-12-08 19:02
from __future__ import unicode_literals

from django.db import migrations, models


Expand Down
17 changes: 8 additions & 9 deletions aldryn_redirects/models.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
from __future__ import unicode_literals

from django.db import models
from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _, ugettext
from django.urls import reverse
from django.utils.translation import gettext_lazy as _, gettext

from parler.models import TranslatableModel, TranslatedFields
from six.moves.urllib.parse import urlparse, urljoin
Expand All @@ -14,10 +11,12 @@
from .validators import validate_inbound_route, validate_outbound_route


@python_2_unicode_compatible
class Redirect(TranslatableModel):
site = models.ForeignKey(
Site, related_name='aldryn_redirects_redirect_set')
Site,
related_name='aldryn_redirects_redirect_set',
on_delete=models.deletion.CASCADE,
)
old_path = models.CharField(
_('redirect from'), max_length=400, db_index=True,
help_text=_(
Expand Down Expand Up @@ -47,7 +46,7 @@ def __str__(self):
for t in self.translations.all()
])
if not new_paths:
new_paths = ugettext('None')
new_paths = gettext('None')
return "{} ---> {}".format(self.old_path or 'None', new_paths)


Expand Down Expand Up @@ -94,7 +93,7 @@ def get_full_inbound_route(self):


class StaticRedirectInboundRouteQueryParam(models.Model):
static_redirect = models.ForeignKey(StaticRedirect, related_name='query_params', on_delete=models.CASCADE)
static_redirect = models.ForeignKey(StaticRedirect, related_name='query_params', on_delete=models.deletion.CASCADE)
key = models.CharField(_('Key'), max_length=255)
value = models.CharField(_('Value'), max_length=255, blank=True)

Expand Down
1 change: 0 additions & 1 deletion aldryn_redirects/south_migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import datetime
from south.db import db
from south.v2 import SchemaMigration
Expand Down
5 changes: 2 additions & 3 deletions aldryn_redirects/validators.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function, division
from __future__ import print_function, division
import re

from django.core.exceptions import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from six.moves.urllib.parse import urlparse

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from setuptools import setup, find_packages
from aldryn_redirects import __version__

Expand Down
5 changes: 2 additions & 3 deletions tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function, division
from __future__ print_function, division

HELPER_SETTINGS = {
'MIDDLEWARE_CLASSES': [
'MIDDLEWARE': [
'aldryn_redirects.middleware.RedirectFallbackMiddleware',
],
'INSTALLED_APPS': [
Expand Down
3 changes: 1 addition & 2 deletions tests/test_importers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function, division
from __future__ import print_function, division

from django.contrib.sites.models import Site
from django.core.exceptions import ValidationError
Expand Down
3 changes: 1 addition & 2 deletions tests/test_managers.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function, division
from __future__ import print_function, division

from django.contrib.sites.models import Site
from django.test import TestCase
Expand Down
3 changes: 1 addition & 2 deletions tests/test_middleware.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function, division
from __future__ import print_function, division

from django.contrib.sites.models import Site
from django.test import TestCase
Expand Down
3 changes: 1 addition & 2 deletions tests/test_models.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, print_function, division
from __future__ import print_function, division

from django.contrib.sites.models import Site
from django.core.exceptions import ValidationError
Expand Down