[Python-modules-commits] [django-organizations] 01/04: Imported Upstream version 1.0.0

Scott Kitterman kitterman at moszumanska.debian.org
Mon Jan 8 20:10:28 UTC 2018


This is an automated email from the git hooks/post-receive script.

kitterman pushed a commit to branch debian/master
in repository django-organizations.

commit acd26db75e641e6991b3cdbae1e32cd8b3e46e9f
Author: Scott Kitterman <scott at kitterman.com>
Date:   Mon Jan 8 14:55:33 2018 -0500

    Imported Upstream version 1.0.0
---
 HISTORY.rst                                   | 12 ++++++++
 PKG-INFO                                      | 29 ++++++++++++++-----
 README.rst                                    | 14 +++++----
 django_organizations.egg-info/PKG-INFO        | 29 ++++++++++++++-----
 django_organizations.egg-info/SOURCES.txt     |  1 +
 organizations/__init__.py                     |  2 +-
 organizations/abstract.py                     | 16 ++++-------
 organizations/backends/defaults.py            | 41 +++++++++++++++++----------
 organizations/base.py                         | 20 ++++++-------
 organizations/compat.py                       | 10 +++++++
 organizations/migrations/0001_initial.py      | 40 +++++++++++++-------------
 organizations/migrations/0002_model_update.py |  3 +-
 organizations/views.py                        | 10 +++++--
 setup.py                                      |  1 +
 14 files changed, 147 insertions(+), 81 deletions(-)

diff --git a/HISTORY.rst b/HISTORY.rst
index 265aeac..5593f74 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -3,6 +3,18 @@
 History
 =======
 
+1.0.0
+-----
+
+* Django 2 compatibility.
+
+At this point it seems reasonable to bump to version 1.
+
+0.9.3
+-----
+
+* Create username value for user if username field exists (custom user models) 
+
 0.9.2
 -----
 
diff --git a/PKG-INFO b/PKG-INFO
index 53b3945..250dfe4 100644
--- a/PKG-INFO
+++ b/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: django-organizations
-Version: 0.9.2
+Version: 1.0.0
 Summary: Group accounts for Django
 Home-page: https://github.com/bennylope/django-organizations/
 Author: Ben Lopatin
@@ -116,7 +116,7 @@ Description: ====================
         
             ORGS_SLUGFIELD = 'django_extensions.db.fields.AutoSlugField'
         
-        Alternative::
+        Alternative (note: this is not compatible with Django 2.0)::
         
             ORGS_SLUGFIELD = 'autoslug.fields.AutoSlugField'
         
@@ -125,7 +125,10 @@ Description: ====================
         warning will be given but this *should not* have any effect on your code.
         
         - `django-extensions <http://django-extensions.readthedocs.org/en/latest/>`_
-        - `Django Autoslug <https://pythonhosted.org/django-autoslug/>`_
+        - `Django Autoslug <http://django-autoslug.readthedocs.io/en/latest/>`_
+        - `django-slugger <https://gitlab.com/dspechnikov/django-slugger/>`_
+        
+        Note that as of django-autoslug 1.9.3. it is incompatible with Django 2.x
         
         Registration & invitation backends
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -209,9 +212,8 @@ Description: ====================
         
         The codebase is targeted and tested against:
         
-        * Django 1.8.x against Python 2.7, 3.4, 3.5, and PyPy
-        * Django 1.9.x against Python 2.7, 3.4, 3.5, and PyPy
-        * Django 1.10.x against Python 2.7, 3.4, 3.5, and PyPy
+        * Django 1.11.x against Python 2.7, 3.4, 3.5, 3.6, and PyPy
+        * Django 2.0.x against Python 3.4, 3.5, 3.6
         
         To run the tests against all target environments, install `tox
         <https://testrun.org/tox/latest/>`_ and then execute the command::
@@ -240,7 +242,7 @@ Description: ====================
         
         * Ensure they match the project goals and are sufficiently generalized
         * Please try to follow `Django coding style
-          <https://docs.djangoproject.com/en/1.8/internals/contributing/writing-code/coding-style/>`_.
+          <https://docs.djangoproject.com/en/stable/internals/contributing/writing-code/coding-style/>`_.
           The code base style isn't all up to par, but I'd like it to move in that
           direction
         * Also please try to include `good commit log messages
@@ -277,6 +279,18 @@ Description: ====================
         History
         =======
         
+        1.0.0
+        -----
+        
+        * Django 2 compatibility.
+        
+        At this point it seems reasonable to bump to version 1.
+        
+        0.9.3
+        -----
+        
+        * Create username value for user if username field exists (custom user models) 
+        
         0.9.2
         -----
         
@@ -503,6 +517,7 @@ Classifier: Programming Language :: Python
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
 Classifier: Programming Language :: Python :: Implementation :: CPython
 Classifier: Programming Language :: Python :: Implementation :: PyPy
 Classifier: Framework :: Django
diff --git a/README.rst b/README.rst
index 1dbb447..2a1ae67 100644
--- a/README.rst
+++ b/README.rst
@@ -108,7 +108,7 @@ django-extensions, but you can configure your own in settings. The default::
 
     ORGS_SLUGFIELD = 'django_extensions.db.fields.AutoSlugField'
 
-Alternative::
+Alternative (note: this is not compatible with Django 2.0)::
 
     ORGS_SLUGFIELD = 'autoslug.fields.AutoSlugField'
 
@@ -117,7 +117,10 @@ is now ignored and the functionality satisifed by a vendored solution. A
 warning will be given but this *should not* have any effect on your code.
 
 - `django-extensions <http://django-extensions.readthedocs.org/en/latest/>`_
-- `Django Autoslug <https://pythonhosted.org/django-autoslug/>`_
+- `Django Autoslug <http://django-autoslug.readthedocs.io/en/latest/>`_
+- `django-slugger <https://gitlab.com/dspechnikov/django-slugger/>`_
+
+Note that as of django-autoslug 1.9.3. it is incompatible with Django 2.x
 
 Registration & invitation backends
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -201,9 +204,8 @@ Targets & testing
 
 The codebase is targeted and tested against:
 
-* Django 1.8.x against Python 2.7, 3.4, 3.5, and PyPy
-* Django 1.9.x against Python 2.7, 3.4, 3.5, and PyPy
-* Django 1.10.x against Python 2.7, 3.4, 3.5, and PyPy
+* Django 1.11.x against Python 2.7, 3.4, 3.5, 3.6, and PyPy
+* Django 2.0.x against Python 3.4, 3.5, 3.6
 
 To run the tests against all target environments, install `tox
 <https://testrun.org/tox/latest/>`_ and then execute the command::
@@ -232,7 +234,7 @@ reviewed and make it into the project:
 
 * Ensure they match the project goals and are sufficiently generalized
 * Please try to follow `Django coding style
-  <https://docs.djangoproject.com/en/1.8/internals/contributing/writing-code/coding-style/>`_.
+  <https://docs.djangoproject.com/en/stable/internals/contributing/writing-code/coding-style/>`_.
   The code base style isn't all up to par, but I'd like it to move in that
   direction
 * Also please try to include `good commit log messages
diff --git a/django_organizations.egg-info/PKG-INFO b/django_organizations.egg-info/PKG-INFO
index 53b3945..250dfe4 100644
--- a/django_organizations.egg-info/PKG-INFO
+++ b/django_organizations.egg-info/PKG-INFO
@@ -1,6 +1,6 @@
 Metadata-Version: 1.1
 Name: django-organizations
-Version: 0.9.2
+Version: 1.0.0
 Summary: Group accounts for Django
 Home-page: https://github.com/bennylope/django-organizations/
 Author: Ben Lopatin
@@ -116,7 +116,7 @@ Description: ====================
         
             ORGS_SLUGFIELD = 'django_extensions.db.fields.AutoSlugField'
         
-        Alternative::
+        Alternative (note: this is not compatible with Django 2.0)::
         
             ORGS_SLUGFIELD = 'autoslug.fields.AutoSlugField'
         
@@ -125,7 +125,10 @@ Description: ====================
         warning will be given but this *should not* have any effect on your code.
         
         - `django-extensions <http://django-extensions.readthedocs.org/en/latest/>`_
-        - `Django Autoslug <https://pythonhosted.org/django-autoslug/>`_
+        - `Django Autoslug <http://django-autoslug.readthedocs.io/en/latest/>`_
+        - `django-slugger <https://gitlab.com/dspechnikov/django-slugger/>`_
+        
+        Note that as of django-autoslug 1.9.3. it is incompatible with Django 2.x
         
         Registration & invitation backends
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -209,9 +212,8 @@ Description: ====================
         
         The codebase is targeted and tested against:
         
-        * Django 1.8.x against Python 2.7, 3.4, 3.5, and PyPy
-        * Django 1.9.x against Python 2.7, 3.4, 3.5, and PyPy
-        * Django 1.10.x against Python 2.7, 3.4, 3.5, and PyPy
+        * Django 1.11.x against Python 2.7, 3.4, 3.5, 3.6, and PyPy
+        * Django 2.0.x against Python 3.4, 3.5, 3.6
         
         To run the tests against all target environments, install `tox
         <https://testrun.org/tox/latest/>`_ and then execute the command::
@@ -240,7 +242,7 @@ Description: ====================
         
         * Ensure they match the project goals and are sufficiently generalized
         * Please try to follow `Django coding style
-          <https://docs.djangoproject.com/en/1.8/internals/contributing/writing-code/coding-style/>`_.
+          <https://docs.djangoproject.com/en/stable/internals/contributing/writing-code/coding-style/>`_.
           The code base style isn't all up to par, but I'd like it to move in that
           direction
         * Also please try to include `good commit log messages
@@ -277,6 +279,18 @@ Description: ====================
         History
         =======
         
+        1.0.0
+        -----
+        
+        * Django 2 compatibility.
+        
+        At this point it seems reasonable to bump to version 1.
+        
+        0.9.3
+        -----
+        
+        * Create username value for user if username field exists (custom user models) 
+        
         0.9.2
         -----
         
@@ -503,6 +517,7 @@ Classifier: Programming Language :: Python
 Classifier: Programming Language :: Python :: 2.7
 Classifier: Programming Language :: Python :: 3.4
 Classifier: Programming Language :: Python :: 3.5
+Classifier: Programming Language :: Python :: 3.6
 Classifier: Programming Language :: Python :: Implementation :: CPython
 Classifier: Programming Language :: Python :: Implementation :: PyPy
 Classifier: Framework :: Django
diff --git a/django_organizations.egg-info/SOURCES.txt b/django_organizations.egg-info/SOURCES.txt
index 4e82974..d8ccbcd 100644
--- a/django_organizations.egg-info/SOURCES.txt
+++ b/django_organizations.egg-info/SOURCES.txt
@@ -17,6 +17,7 @@ organizations/app_settings.py
 organizations/apps.py
 organizations/base.py
 organizations/base_admin.py
+organizations/compat.py
 organizations/exceptions.py
 organizations/fields.py
 organizations/forms.py
diff --git a/organizations/__init__.py b/organizations/__init__.py
index 9ebcf4a..4769fc3 100644
--- a/organizations/__init__.py
+++ b/organizations/__init__.py
@@ -26,7 +26,7 @@
 
 __author__ = 'Ben Lopatin'
 __email__ = 'ben at wellfire.co'
-__version__ = '0.9.2'
+__version__ = '1.0.0'
 
 
 default_app_config = 'organizations.apps.OrganizationsConfig'
diff --git a/organizations/abstract.py b/organizations/abstract.py
index a9890d7..a380350 100644
--- a/organizations/abstract.py
+++ b/organizations/abstract.py
@@ -26,25 +26,21 @@
 import warnings
 
 from django.conf import settings
-from django.core.urlresolvers import reverse
 from django.db import models
 from django.utils.translation import ugettext_lazy as _
 
-try:
-    import six
-except ImportError:
-    from django.utils import six
-
-from organizations.base import OrgMeta
 from organizations.base import AbstractBaseOrganization
-from organizations.base import AbstractBaseOrganizationUser
 from organizations.base import AbstractBaseOrganizationOwner
-from organizations.fields import SlugField
+from organizations.base import AbstractBaseOrganizationUser
+from organizations.base import OrgMeta
+from organizations.compat import reverse
+from organizations.compat import six
 from organizations.fields import AutoCreatedField
 from organizations.fields import AutoLastModifiedField
+from organizations.fields import SlugField
+from organizations.signals import owner_changed
 from organizations.signals import user_added
 from organizations.signals import user_removed
-from organizations.signals import owner_changed
 
 USER_MODEL = getattr(settings, 'AUTH_USER_MODEL', 'auth.User')
 ORGS_TIMESTAMPED_MODEL = getattr(settings, 'ORGS_TIMESTAMPED_MODEL', None)
diff --git a/organizations/backends/defaults.py b/organizations/backends/defaults.py
index f537557..eafa01a 100644
--- a/organizations/backends/defaults.py
+++ b/organizations/backends/defaults.py
@@ -27,6 +27,7 @@
 """
 
 import email.utils
+import inspect
 import uuid
 
 from django.conf import settings
@@ -35,7 +36,6 @@ from django.contrib.auth import authenticate
 from django.contrib.auth import get_user_model
 from django.contrib.auth import login
 from django.core.mail import EmailMessage
-from django.core.urlresolvers import reverse
 from django.http import Http404
 from django.shortcuts import redirect
 from django.shortcuts import render
@@ -45,6 +45,7 @@ from django.utils.translation import ugettext as _
 from organizations.backends.forms import UserRegistrationForm
 from organizations.backends.forms import org_registration_form
 from organizations.backends.tokens import RegistrationTokenGenerator
+from organizations.compat import reverse
 from organizations.utils import create_organization
 from organizations.utils import default_org_model
 from organizations.utils import model_field_attr
@@ -135,13 +136,15 @@ class BaseBackend(object):
             return False
         token = RegistrationTokenGenerator().make_token(user)
         kwargs.update({'token': token})
-        self._send_email(user, self.reminder_subject, self.reminder_body, sender, **kwargs)
+        self.email_message(user, self.reminder_subject, self.reminder_body, sender, **kwargs).send()
 
-    # This could be replaced with a more channel agnostic function, most likely
-    # in a custom backend.
-    def _send_email(self, user, subject_template, body_template,
-            sender=None, **kwargs):
-        """Utility method for sending emails to new users"""
+    def email_message(self, user, subject_template, body_template,
+            sender=None, message_class=EmailMessage, **kwargs):
+        """
+        Returns an email message for a new user. This can be easily overriden.
+        For instance, to send an HTML message, use the EmailMultiAlternatives message_class
+        and attach the additional conent.
+        """
         if sender:
             from_email = "%s %s <%s>" % (sender.first_name, sender.last_name,
                     email.utils.parseaddr(settings.DEFAULT_FROM_EMAIL)[1])
@@ -157,7 +160,7 @@ class BaseBackend(object):
         body_template = loader.get_template(body_template)
         subject = subject_template.render(kwargs).strip()  # Remove stray newline characters
         body = body_template.render(kwargs)
-        return EmailMessage(subject, body, from_email, [user.email], headers=headers).send()
+        return message_class(subject, body, from_email, [user.email], headers=headers)
 
 
 class RegistrationBackend(BaseBackend):
@@ -208,14 +211,18 @@ class RegistrationBackend(BaseBackend):
             return False
         token = self.get_token(user)
         kwargs.update({'token': token})
-        self._send_email(user, self.activation_subject, self.activation_body, sender, **kwargs)
+        self.email_message(user, self.activation_subject, self.activation_body, sender, **kwargs).send()
 
     def create_view(self, request):
         """
         Initiates the organization and user account creation process
         """
-        if request.user.is_authenticated():
-            return redirect("organization_add")
+        try:
+            if request.user.is_authenticated():
+                return redirect("organization_add")
+        except TypeError:
+            if request.user.is_authenticated:
+                return redirect("organization_add")
         form = org_registration_form(self.org_model)(request.POST or None)
         if form.is_valid():
             try:
@@ -272,8 +279,12 @@ class InvitationBackend(BaseBackend):
             user = self.user_model.objects.get(email=email)
         except self.user_model.DoesNotExist:
             # TODO break out user creation process
-            user = self.user_model.objects.create(username=self.get_username(),
-                    email=email, password=self.user_model.objects.make_random_password())
+            if 'username' in inspect.getargspec(self.user_model.objects.create_user).args:
+                user = self.user_model.objects.create(username=self.get_username(),
+                        email=email, password=self.user_model.objects.make_random_password())
+            else:
+                user = self.user_model.objects.create(email=email,
+                        password=self.user_model.objects.make_random_password())
             user.is_active = False
             user.save()
         self.send_invitation(user, sender, **kwargs)
@@ -288,7 +299,7 @@ class InvitationBackend(BaseBackend):
             return False
         token = self.get_token(user)
         kwargs.update({'token': token})
-        self._send_email(user, self.invitation_subject, self.invitation_body, sender, **kwargs)
+        self.email_message(user, self.invitation_subject, self.invitation_body, sender, **kwargs).send()
         return True
 
     def send_notification(self, user, sender=None, **kwargs):
@@ -299,5 +310,5 @@ class InvitationBackend(BaseBackend):
         """
         if not user.is_active:
             return False
-        self._send_email(user, self.notification_subject, self.notification_body, sender, **kwargs)
+        self.email_message(user, self.notification_subject, self.notification_body, sender, **kwargs).send()
         return True
diff --git a/organizations/base.py b/organizations/base.py
index f06f2cd..9a7a018 100644
--- a/organizations/base.py
+++ b/organizations/base.py
@@ -24,16 +24,12 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 from django.conf import settings
+from django.core.exceptions import FieldDoesNotExist
 from django.db import models
 from django.db.models.base import ModelBase
-from django.db.models.fields import FieldDoesNotExist
-
-try:
-    import six
-except ImportError:
-    from django.utils import six
 from django.utils.translation import ugettext_lazy as _
 
+from organizations.compat import six
 from organizations.managers import ActiveOrgManager
 from organizations.managers import OrgManager
 
@@ -48,7 +44,7 @@ class UnicodeMixin(object):
         if six.PY3:
             return self.__unicode__()
         else:
-            return unicode(self).encode('utf-8')
+            return unicode(self).encode('utf-8') # noqa
 
 
 class OrgMeta(ModelBase):
@@ -123,13 +119,14 @@ class OrgMeta(ModelBase):
             cls.module_registry[module]['OrgUserModel']._meta.get_field("user")
         except FieldDoesNotExist:
             cls.module_registry[module]['OrgUserModel'].add_to_class("user",
-                models.ForeignKey(USER_MODEL, related_name="%(app_label)s_%(class)s"))
+                models.ForeignKey(USER_MODEL, related_name="%(app_label)s_%(class)s",
+                        on_delete=models.CASCADE))
         try:
             cls.module_registry[module]['OrgUserModel']._meta.get_field("organization")
         except FieldDoesNotExist:
             cls.module_registry[module]['OrgUserModel'].add_to_class("organization",
                 models.ForeignKey(cls.module_registry[module]['OrgModel'],
-                        related_name="organization_users"))
+                        related_name="organization_users", on_delete=models.CASCADE))
 
     def update_org_owner(cls, module):
         """
@@ -139,13 +136,14 @@ class OrgMeta(ModelBase):
             cls.module_registry[module]['OrgOwnerModel']._meta.get_field("organization_user")
         except FieldDoesNotExist:
             cls.module_registry[module]['OrgOwnerModel'].add_to_class("organization_user",
-                models.OneToOneField(cls.module_registry[module]['OrgUserModel']))
+                models.OneToOneField(cls.module_registry[module]['OrgUserModel'],
+                        on_delete=models.CASCADE))
         try:
             cls.module_registry[module]['OrgOwnerModel']._meta.get_field("organization")
         except FieldDoesNotExist:
             cls.module_registry[module]['OrgOwnerModel'].add_to_class("organization",
                 models.OneToOneField(cls.module_registry[module]['OrgModel'],
-                        related_name="owner"))
+                        related_name="owner", on_delete=models.CASCADE))
 
 
 class AbstractBaseOrganization(UnicodeMixin, models.Model):
diff --git a/organizations/compat.py b/organizations/compat.py
new file mode 100644
index 0000000..dd39fe2
--- /dev/null
+++ b/organizations/compat.py
@@ -0,0 +1,10 @@
+
+try:
+    from django.urls import reverse  # noqa
+except ImportError:
+    from django.core.urlresolvers import reverse  # noqa
+
+try:
+    import six  # noqa
+except ImportError:
+    from django.utils import six  # noqa
diff --git a/organizations/migrations/0001_initial.py b/organizations/migrations/0001_initial.py
index 83e4ba4..4b678c7 100644
--- a/organizations/migrations/0001_initial.py
+++ b/organizations/migrations/0001_initial.py
@@ -1,15 +1,16 @@
-# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
+# Generated by Django 2.0 on 2017-12-05 00:17
 
+from django.conf import settings
 from django.db import migrations, models
-import organizations.fields
-import organizations.base
+import django.db.models.deletion
 import django.utils.timezone
-from django.conf import settings
-
+import organizations.base
+import organizations.fields
 
 class Migration(migrations.Migration):
 
+    initial = True
+
     dependencies = [
         migrations.swappable_dependency(settings.AUTH_USER_MODEL),
     ]
@@ -18,57 +19,58 @@ class Migration(migrations.Migration):
         migrations.CreateModel(
             name='Organization',
             fields=[
-                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                 ('name', models.CharField(help_text='The name of the organization', max_length=200)),
                 ('is_active', models.BooleanField(default=True)),
                 ('created', organizations.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False)),
                 ('modified', organizations.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False)),
-                ('slug', organizations.fields.SlugField(populate_from=b'name', editable=True, max_length=200, help_text='The name in all lowercase, suitable for URL identification', unique=True)),
+                ('slug', organizations.fields.SlugField(editable=True, help_text='The name in all lowercase, suitable for URL identification', max_length=200, populate_from='name', unique=True)),
             ],
             options={
-                'ordering': ['name'],
-                'abstract': False,
                 'verbose_name': 'organization',
                 'verbose_name_plural': 'organizations',
+                'ordering': ['name'],
+                'abstract': False,
             },
             bases=(organizations.base.UnicodeMixin, models.Model),
         ),
         migrations.CreateModel(
             name='OrganizationOwner',
             fields=[
-                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                 ('created', organizations.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False)),
                 ('modified', organizations.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False)),
-                ('organization', models.OneToOneField(related_name='owner', to='organizations.Organization')),
+                ('organization', models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, related_name='owner', to='organizations.Organization')),
             ],
             options={
                 'verbose_name': 'organization owner',
                 'verbose_name_plural': 'organization owners',
+                'abstract': False,
             },
             bases=(organizations.base.UnicodeMixin, models.Model),
         ),
         migrations.CreateModel(
             name='OrganizationUser',
             fields=[
-                ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
                 ('created', organizations.fields.AutoCreatedField(default=django.utils.timezone.now, editable=False)),
                 ('modified', organizations.fields.AutoLastModifiedField(default=django.utils.timezone.now, editable=False)),
                 ('is_admin', models.BooleanField(default=False)),
-                ('organization', models.ForeignKey(related_name='organization_users', to='organizations.Organization')),
-                ('user', models.ForeignKey(related_name='organizations_organizationuser', to=settings.AUTH_USER_MODEL)),
+                ('organization', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='organization_users', to='organizations.Organization')),
+                ('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='organizations_organizationuser', to=settings.AUTH_USER_MODEL)),
             ],
             options={
-                'ordering': ['organization', 'user'],
-                'abstract': False,
                 'verbose_name': 'organization user',
                 'verbose_name_plural': 'organization users',
+                'ordering': ['organization', 'user'],
+                'abstract': False,
             },
             bases=(organizations.base.UnicodeMixin, models.Model),
         ),
         migrations.AddField(
             model_name='organizationowner',
             name='organization_user',
-            field=models.OneToOneField(to='organizations.OrganizationUser'),
+            field=models.OneToOneField(on_delete=django.db.models.deletion.CASCADE, to='organizations.OrganizationUser'),
         ),
         migrations.AddField(
             model_name='organization',
@@ -77,6 +79,6 @@ class Migration(migrations.Migration):
         ),
         migrations.AlterUniqueTogether(
             name='organizationuser',
-            unique_together=set([('user', 'organization')]),
+            unique_together={('user', 'organization')},
         ),
     ]
diff --git a/organizations/migrations/0002_model_update.py b/organizations/migrations/0002_model_update.py
index 3f9fc35..92eccc1 100644
--- a/organizations/migrations/0002_model_update.py
+++ b/organizations/migrations/0002_model_update.py
@@ -4,7 +4,6 @@ from __future__ import unicode_literals
 from django.db import migrations, models
 import organizations.fields
 
-
 class Migration(migrations.Migration):
 
     dependencies = [
@@ -15,6 +14,6 @@ class Migration(migrations.Migration):
         migrations.AlterField(
             model_name='organization',
             name='slug',
-            field=organizations.fields.SlugField(help_text='The name in all lowercase, suitable for URL identification', unique=True, populate_from='name', max_length=200, editable=True),
+            field=organizations.fields.SlugField(blank=True, editable=False, help_text='The name in all lowercase, suitable for URL identification', max_length=200, populate_from=('name',), unique=True),
         ),
     ]
diff --git a/organizations/views.py b/organizations/views.py
index 1193759..1d4f1ec 100644
--- a/organizations/views.py
+++ b/organizations/views.py
@@ -24,7 +24,6 @@
 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
 from django.contrib.sites.shortcuts import get_current_site
-from django.core.urlresolvers import reverse
 from django.http import HttpResponseBadRequest
 from django.shortcuts import redirect
 from django.shortcuts import render
@@ -38,6 +37,7 @@ from django.views.generic import UpdateView
 
 from organizations.backends import invitation_backend
 from organizations.backends import registration_backend
+from organizations.compat import reverse
 from organizations.forms import OrganizationAddForm
 from organizations.forms import OrganizationForm
 from organizations.forms import OrganizationUserAddForm
@@ -177,8 +177,12 @@ class OrganizationSignup(FormView):
     backend = registration_backend()
 
     def dispatch(self, request, *args, **kwargs):
-        if request.user.is_authenticated():
-            return redirect('organization_add')
+        try:
+            if request.user.is_authenticated():
+                return redirect('organization_add')
+        except TypeError:
+            if request.user.is_authenticated:
+                return redirect('organization_add')
         return super(OrganizationSignup, self).dispatch(request, *args,
                 **kwargs)
 
diff --git a/setup.py b/setup.py
index c0b2871..8652eff 100644
--- a/setup.py
+++ b/setup.py
@@ -45,6 +45,7 @@ setup(
         'Programming Language :: Python :: 2.7',
         'Programming Language :: Python :: 3.4',
         'Programming Language :: Python :: 3.5',
+        'Programming Language :: Python :: 3.6',
         'Programming Language :: Python :: Implementation :: CPython',
         'Programming Language :: Python :: Implementation :: PyPy',
         'Framework :: Django',

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/python-modules/packages/django-organizations.git



More information about the Python-modules-commits mailing list