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

Become compatible with Django 3.2+/Python 3 (only) #71

Open
wants to merge 3 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
8 changes: 2 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
matrix:
include:
- python: 2.7
env: TOXENV=py27
- python: 3.4
env: TOXENV=py34
- python: 3.5
env: TOXENV=py35
- python: 3.6
env: TOXENV=py36
- python: 3.8
env: TOXENV=py38
language: python
install:
- pip install tox coveralls
Expand Down
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ A number of backwards incompatible changes are included in the 1.0 release.
Python/Django supported versions
--------------------------------

- Python: 2.7, 3.4, 3.5 and 3.6
- Django: 1.8 to 2.0
- Python: 3.6+
- Django: 3.2+, 4.0+


Running the Tests
Expand Down
6 changes: 6 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[build-system]
requires = [
"setuptools>=42",
"wheel"
]
build-backend = "setuptools.build_meta"
32 changes: 32 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[metadata]
name = django-simple-email-confirmation
version = attr:simple_email_confirmation.__version__
author = Mike Fogel
author_email = [email protected]
long_description = file:README.rst
description = Simple email confirmation for django.
url = https://github.com/mfogel/django-simple-email-confirmation
license = BSD
classifiers =
Development Status :: 3 - Alpha
Environment :: Web Environment
Intended Audience :: Developers
License :: OSI Approved :: BSD License
Operating System :: OS Independent
Programming Language :: Python
Programming Language :: Python :: 3
Programming Language :: Python :: 3.6
Programming Language :: Python :: 3.7
Programming Language :: Python :: 3.8
Topic :: Utilities
Framework :: Django

[options]
packages =
simple_email_confirmation
simple_email_confirmation.migrations
simple_email_confirmation.tests
simple_email_confirmation.tests.myproject
simple_email_confirmation.tests.myproject.myapp
install_requires =
django>=3.2
60 changes: 0 additions & 60 deletions setup.py

This file was deleted.

2 changes: 1 addition & 1 deletion simple_email_confirmation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
]

from django.conf import settings
from django.apps import apps

from .signals import (
email_confirmed, unconfirmed_email_created, primary_email_changed,
Expand All @@ -16,6 +15,7 @@

def get_email_address_model():
"""Convenience method to return the email model being used."""
from django.apps import apps
return apps.get_model(getattr(
settings,
'SIMPLE_EMAIL_CONFIRMATION_EMAIL_ADDRESS_MODEL',
Expand Down
6 changes: 6 additions & 0 deletions simple_email_confirmation/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
from django.apps import AppConfig


class SimpleEmailConfirmationAppConfig(AppConfig):
name = 'simple_email_confirmation'
default_auto_field = 'django.db.models.AutoField'
5 changes: 1 addition & 4 deletions simple_email_confirmation/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 models, migrations
import django.utils.timezone
from django.conf import settings
Expand Down Expand Up @@ -30,6 +27,6 @@ class Migration(migrations.Migration):
),
migrations.AlterUniqueTogether(
name='emailaddress',
unique_together=set([('user', 'email')]),
unique_together={('user', 'email')},
),
]
10 changes: 3 additions & 7 deletions simple_email_confirmation/models.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
from __future__ import unicode_literals

from django.conf import settings
from django.contrib.auth import get_user_model
from django.db import models
from django.db.models.signals import post_save
from django.utils.crypto import get_random_string
from django.utils import timezone
from six import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _

from simple_email_confirmation import get_email_address_model
from .exceptions import (
Expand All @@ -18,7 +15,7 @@
)


class SimpleEmailConfirmationUserMixin(object):
class SimpleEmailConfirmationUserMixin:
"""
Mixin to be used with your django 1.5+ custom User model.
Provides python-level functionality only.
Expand Down Expand Up @@ -225,7 +222,6 @@ def get_user_primary_email(user):
return user.email


@python_2_unicode_compatible
class AbstractEmailAddress(models.Model):
"An email address belonging to a User"

Expand Down Expand Up @@ -253,7 +249,7 @@ class Meta:
abstract = True

def __str__(self):
return '{} <{}>'.format(self.user, self.email)
return f'{self.user} <{self.email}>'

@property
def is_confirmed(self):
Expand Down
8 changes: 3 additions & 5 deletions simple_email_confirmation/signals.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
from django.dispatch import Signal

email_confirmed = Signal(providing_args=['user', 'email'])
unconfirmed_email_created = Signal(providing_args=['user', 'email'])
primary_email_changed = Signal(
providing_args=['user', 'old_email', 'new_email'],
)
email_confirmed = Signal() # args: ['user', 'email']
unconfirmed_email_created = Signal() # args: ['user', 'email']
primary_email_changed = Signal() # args: ['user', 'old_email', 'new_email']
54 changes: 0 additions & 54 deletions simple_email_confirmation/south_migrations/0001_initial.py

This file was deleted.

Empty file.
25 changes: 24 additions & 1 deletion simple_email_confirmation/tests/myproject/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
'simple_email_confirmation.tests.myproject.myapp',
)

MIDDLEWARE_CLASSES = (
MIDDLEWARE = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
Expand All @@ -48,6 +48,27 @@

WSGI_APPLICATION = 'project.wsgi.application'

# Templates

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.template.context_processors.request',
'django.contrib.messages.context_processors.messages',
],
},
},
]


# Database
# https://docs.djangoproject.com/en/dev/ref/settings/#databases
Expand All @@ -58,6 +79,8 @@
}
}

DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

# Internationalization
# https://docs.djangoproject.com/en/dev/topics/i18n/

Expand Down
2 changes: 1 addition & 1 deletion simple_email_confirmation/tests/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def test_is_primary_property(self):

def test_unicode(self):
email_obj = self.user.email_address_set.get(email=self.user.email)
self.assertEqual('%s' % email_obj, '%s <%s>' % (self.user, self.user.email))
self.assertEqual('%s' % email_obj, f'{self.user} <{self.user.email}>')


class AddEmailIfNotExistsTestCase(TestCase):
Expand Down
16 changes: 7 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
[tox]
isolated_build = True
envlist =
{py27,py34,py35,p36}-django{18,19,110,111}
{py34,py35,py36}-django20
{py36}-django32
{py38}-django{32,40}

[testenv]
commands = {envbindir}/django-admin.py test simple_email_confirmation
commands = {envbindir}/django-admin test simple_email_confirmation
setenv = DJANGO_SETTINGS_MODULE=simple_email_confirmation.tests.myproject.settings
# changing the default working directory to avoid relative vs.
# absolute import errors when doing unittest discovery.
changedir = {toxworkdir}
deps =
django18: Django>=1.8,<1.9
django19: Django>=1.9,<1.10
django110: Django>=1.10,<1.11
django111: Django>=1.11,<1.12
django20: Django>=2.0
django32: Django~=3.2.0
django40: Django~=4.0


[testenv:coverage]
Expand All @@ -27,4 +25,4 @@ commands =
python -c "import os; os.rename('.coverage', '{toxinidir}/.coverage');"
deps =
coverage
django<1.12
django~=3.2.0