Skip to content
Browse files

Merge pull request #2 from koirikivi/develop

Don't restrict user model name and fix travis python3 build
  • Loading branch information...
2 parents a767d48 + 2df0bea commit 0a262f538dc259bd608314d235f2c2d81f67ec42 @tanderegg tanderegg committed Feb 27, 2014
View
20 cms/models/permissionmodels.py
@@ -17,15 +17,19 @@
# To avoid circular dependencies, don't use cms.compat.get_user_model, and
# don't depend on the app registry, to get the custom user model if used
if is_user_swapped:
- user_app_name = user_model_label.split('.')[0]
+ user_app_name, user_model_name = user_model_label.rsplit('.', 1)
+ User = None
for app in settings.INSTALLED_APPS:
- if user_app_name in app:
- try:
- User = importlib.import_module(app + ".models").User
- except AttributeError:
- raise ImproperlyConfigured('''
- DjangoCMS requires the name of custom user models to be "User"
- ''')
+ if app.endswith(user_app_name):
+ user_app_models = importlib.import_module(app + ".models")
+ User = getattr(user_app_models, user_model_name)
+ break
+ if User is None:
+ raise ImproperlyConfigured(
+ "You have defined a custom user model %s, but the app %s is not "
+ "in settings.INSTALLED_APPS" % (user_model_label, user_app_name)
+ )
+
else:
from django.contrib.auth.models import User
View
6 cms/test_utils/project/emailuserapp/admin.py
@@ -4,8 +4,8 @@
from django.utils.translation import ugettext, ugettext_lazy as _
-from models import User
-from forms import UserChangeForm, UserCreationForm
+from .models import User
+from .forms import UserChangeForm, UserCreationForm
class UserAdmin(OriginalUserAdmin):
# The form to add and change user instances
@@ -37,4 +37,4 @@ class UserAdmin(OriginalUserAdmin):
ordering = ('last_name', 'first_name', 'email')
# Now register the emailuser admin
-admin.site.register(User, UserAdmin)
+admin.site.register(User, UserAdmin)
View
2 cms/test_utils/project/emailuserapp/forms.py
@@ -7,7 +7,7 @@
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.forms import ReadOnlyPasswordHashField
-from models import User
+from .models import User
class UserCreationForm(forms.ModelForm):
"""

0 comments on commit 0a262f5

Please sign in to comment.
Something went wrong with that request. Please try again.