Skip to content
This repository has been archived by the owner on Jan 20, 2022. It is now read-only.

Commit

Permalink
drop python 2 support and make compatible with django 3
Browse files Browse the repository at this point in the history
  • Loading branch information
Victor Yunenko committed Oct 5, 2020
1 parent ed766a9 commit b2697ae
Show file tree
Hide file tree
Showing 45 changed files with 24 additions and 77 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,19 @@ Changelog
=========


6.2.0.rc1 (2020-10-05)
==================

* Scroll the page to the submitted form success text (before the page would just reload without a success message)
* Fix the email notification variables render (it wasn't working for a year)
* Fix `reply_to_email` field - it wasn't possible to configure before
* Fix the form submission success message that was appearing on a non-related to the form page
* Fix a bug that would break the form when the user added spaces to a field's name
* Fix the caching bug that was breaking the page when a field was added outside of a form plugin
* Drop Python 2 support, make compatible with Django 3
* Drop the form plugin that doesn't allow to send email notifications


5.0.4 (2020-05-19)
==================

Expand Down
1 change: 0 additions & 1 deletion aldryn_config.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from aldryn_client import forms


Expand Down
3 changes: 1 addition & 2 deletions aldryn_forms/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
# -*- coding: utf-8 -*-
__version__ = '5.0.4'
__version__ = '6.2.0.rc1'
1 change: 0 additions & 1 deletion aldryn_forms/action_backends.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import logging

from django.utils.translation import ugettext_lazy as _
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/action_backends_base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import abc

import six
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/admin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django.contrib import admin

from ..models import FormSubmission
Expand Down
7 changes: 1 addition & 6 deletions aldryn_forms/admin/base.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
# -*- coding: utf-8 -*-
from email.utils import formataddr

from django.contrib import admin
from django.template.loader import render_to_string
from django.urls import reverse
from django.utils import six
from django.utils.translation import ugettext_lazy as _


if six.PY2:
str_dunder_method = '__unicode__'
else:
str_dunder_method = '__str__'
str_dunder_method = '__str__'


class BaseFormSubmissionAdmin(admin.ModelAdmin):
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/admin/exporter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from tablib import Dataset


Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/admin/forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from datetime import datetime, timedelta

from django import forms
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/admin/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django import get_version
from django.contrib import messages
from django.http import HttpResponse
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/cms_apps.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django.utils.translation import ugettext_lazy as _

from cms.app_base import CMSApp
Expand Down
7 changes: 2 additions & 5 deletions aldryn_forms/cms_plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from django import forms
from django.contrib import messages
from django.contrib.admin import TabularInline
from django.core.validators import MinLengthValidator
from django.db.models import query
from django.template.loader import select_template
from django.utils.safestring import mark_safe
from django.utils.six import text_type
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _
from emailit.api import send_mail
Expand Down Expand Up @@ -289,10 +286,10 @@ class Field(FormElement):

def serialize_value(self, instance, value, is_confirmation=False):
if isinstance(value, query.QuerySet):
value = u', '.join(map(text_type, value))
value = u', '.join(map(str, value))
elif value is None:
value = '-'
return text_type(value)
return str(value)

def serialize_field(self, form, field, is_confirmation=False):
"""Returns a (key, label, value) named tuple for the given field."""
Expand Down
2 changes: 0 additions & 2 deletions aldryn_forms/compat.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-

try:
from collections import OrderedDict
except ImportError:
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/contrib/email_notifications/cms_plugins.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import logging
from email.utils import parseaddr
from typing import List
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/contrib/email_notifications/helpers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
import os
from string import Template

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.contrib.auth.models import Permission
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2018-02-06 19:33
from __future__ import unicode_literals

Expand Down
3 changes: 0 additions & 3 deletions aldryn_forms/contrib/email_notifications/models.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
# -*- coding: utf-8 -*-
from email.utils import formataddr
from functools import partial

from django.conf import settings
from django.core.exceptions import ValidationError
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext
from django.utils.translation import ugettext_lazy as _

Expand Down Expand Up @@ -52,7 +50,6 @@ def get_notification_text_context_keys_as_choices(self):
return choices


@python_2_unicode_compatible
class EmailNotification(models.Model):

class Meta:
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/contrib/email_notifications/notification.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django.utils.translation import ugettext

from .helpers import get_email_template_name
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/forms.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django import forms
from django.conf import settings
from django.forms.forms import NON_FIELD_ERRORS
Expand Down
3 changes: 0 additions & 3 deletions aldryn_forms/helpers.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-


def get_user_name(user):
try:
name = user.get_full_name()
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/migrations/0001_initial.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/migrations/0002_auto_20151014_1631.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import django.core.validators
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/migrations/0003_auto_20151207_1038.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import django.core.validators
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/migrations/0004_auto_20151207_1825.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/migrations/0005_auto_20160821_1026.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.8 on 2016-08-21 14:26
from __future__ import unicode_literals

Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/migrations/0006_auto_20160821_1039.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9.8 on 2016-08-21 14:39
from __future__ import unicode_literals

Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/migrations/0007_auto_20170315_1421.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/migrations/0008_auto_20170316_0845.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.db import migrations, models
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/migrations/0009_auto_20171218_1049.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2017-12-18 12:49
from __future__ import unicode_literals

Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/migrations/0010_auto_20171220_1733.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2017-12-20 19:33
from __future__ import unicode_literals

Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/migrations/0011_auto_20180110_1300.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.8 on 2018-01-10 15:00
from __future__ import unicode_literals

Expand Down
11 changes: 1 addition & 10 deletions aldryn_forms/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@
from django.core.exceptions import ValidationError
from django.db import models
from django.db.models.functions import Coalesce
from django.utils.encoding import python_2_unicode_compatible
from django.utils.functional import cached_property
from django.utils.six import text_type
from django.utils.translation import ugettext_lazy as _
from djangocms_attributes_field.fields import AttributesField
from filer.fields.folder import FilerFolderField
Expand Down Expand Up @@ -92,7 +90,6 @@ def field_type(self):
return self.name.rpartition('_')[0]


@python_2_unicode_compatible
class BaseFormPlugin(CMSPlugin):
FALLBACK_FORM_TEMPLATE = 'aldryn_forms/form.html'
DEFAULT_FORM_TEMPLATE = getattr(
Expand Down Expand Up @@ -335,7 +332,6 @@ def get_form_elements(self):
return self._form_elements


@python_2_unicode_compatible
class FormPlugin(BaseFormPlugin):

class Meta:
Expand All @@ -345,7 +341,6 @@ def __str__(self):
return self.name


@python_2_unicode_compatible
class FieldsetPlugin(CMSPlugin):

legend = models.CharField(_('Legend'), max_length=255, blank=True)
Expand All @@ -356,10 +351,9 @@ class FieldsetPlugin(CMSPlugin):
)

def __str__(self):
return self.legend or text_type(self.pk)
return self.legend or str(self.pk)


@python_2_unicode_compatible
class FieldPluginBase(CMSPlugin):
name = models.CharField(
_('Name'),
Expand Down Expand Up @@ -520,7 +514,6 @@ class ImageUploadFieldPlugin(FileFieldPluginBase):
)


@python_2_unicode_compatible
class Option(models.Model):
field = models.ForeignKey(FieldPlugin, editable=False, on_delete=models.CASCADE)
value = models.CharField(_('Value'), max_length=255)
Expand All @@ -546,7 +539,6 @@ def save(self, *args, **kwargs):
return super(Option, self).save(*args, **kwargs)


@python_2_unicode_compatible
class FormButtonPlugin(CMSPlugin):
label = models.CharField(_('Label'), max_length=255)
custom_classes = models.CharField(
Expand All @@ -559,7 +551,6 @@ def __str__(self):
return self.label


@python_2_unicode_compatible
class FormSubmission(models.Model):
name = models.CharField(
max_length=255,
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/signals.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django.dispatch import Signal


Expand Down
8 changes: 3 additions & 5 deletions aldryn_forms/sizefield/utils.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
from __future__ import unicode_literals

import operator
import re
import sys

from django.conf import settings
from django.utils import formats, six
from django.utils import formats
from django.utils.translation import ugettext as _


Expand Down Expand Up @@ -43,7 +41,7 @@ def filesizeformat(bytes, decimals=1):
def filesize_number_format(value):
return formats.number_format(round(value, decimals), decimals)

units_list = sorted(six.iteritems(FILESIZE_UNITS), key=operator.itemgetter(1))
units_list = sorted(FILESIZE_UNITS.items(), key=operator.itemgetter(1))

value = unit = None
len_unints_list = len(units_list)
Expand All @@ -65,7 +63,7 @@ def parse_size(size):
"""
@rtype int
"""
if isinstance(size, six.integer_types):
if isinstance(size, int):
return size

r = file_size_re.match(size.strip())
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/templatetags/aldryn_forms_tags.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django import template
from django.utils import encoding
from django.utils.safestring import mark_safe
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/urls.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django.conf.urls import url

from .views import submit_form_view
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.conf import settings
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/validators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from email.utils import parseaddr

from django.core.exceptions import ValidationError
Expand Down
1 change: 0 additions & 1 deletion aldryn_forms/views.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
from django.http import HttpResponseBadRequest, HttpResponseRedirect
from django.shortcuts import render
from django.urls import resolve
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 find_packages, setup

from aldryn_forms import __version__
Expand Down
1 change: 0 additions & 1 deletion tests/settings.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import division, print_function, unicode_literals


Expand Down
9 changes: 3 additions & 6 deletions tests/test_migrations.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
# -*- coding: utf-8 -*-
# original from
# http://tech.octopus.energy/news/2016/01/21/testing-for-missing-migrations-in-django.html
from StringIO import StringIO

from django.core.management import call_command
from django.test import TestCase, override_settings
from django.utils.six import text_type
from django.utils.six.moves import StringIO


class MigrationTestCase(TestCase):
Expand All @@ -22,7 +19,7 @@ def test_for_missing_migrations(self):
try:
call_command('makemigrations', **options)
except SystemExit as e:
status_code = text_type(e)
status_code = str(e)
else:
# the "no changes" exit code is 0
status_code = '0'
Expand Down
Loading

0 comments on commit b2697ae

Please sign in to comment.