diff --git a/dynamicweb/urls.py b/dynamicweb/urls.py index b6e546e2..7f06be82 100644 --- a/dynamicweb/urls.py +++ b/dynamicweb/urls.py @@ -18,10 +18,10 @@ urlpatterns = [ # note the django CMS URLs included via i18n_patterns urlpatterns += i18n_patterns('', - url(r'^login',include(membership_urls)), + url(r'^login/',include(membership_urls)), url(r'^admin/', include(admin.site.urls)), url(r'^digitalglarus/', include('digitalglarus.urls', - namespace="digitalglarus")), + namespace="digitalglarus"),name='digitalglarus'), url(r'^', include('cms.urls')), ) diff --git a/membership/models.py b/membership/models.py index 7c185021..ba633f98 100644 --- a/membership/models.py +++ b/membership/models.py @@ -1,13 +1,13 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ -from django.contrib.auth.models import User, AbstractBaseUser, BaseUserManager +from django.contrib.auth.models import User, AbstractBaseUser, BaseUserManager,AbstractUser from django.contrib.auth.hashers import make_password from django.core.mail import send_mail from django.core.validators import RegexValidator from django.contrib.auth.models import User REGISTRATION_MESSAGE = {'subject': "Validation mail", - 'message': 'Please validate Your account under this link http://localhost:8000/en-us/validate/{}', + 'message': 'Please validate Your account under this link http://localhost:8000/en-us/login/validate/{}', 'from': 'test@test.com'} @@ -21,10 +21,10 @@ class MyUserManager(BaseUserManager): user = self.model( email=self.normalize_email(email), - name=name + name=name, + password=password, + validation_slug=make_password(None) ) - - user.set_password(password) user.save(using=self._db) return user @@ -32,9 +32,11 @@ class MyUserManager(BaseUserManager): """ Creates and saves a superuser with the given email, name and password. """ + import ipdb;ipdb.set_trace() user = self.create_user(email, password=password, - name=name + name=name, + validation_slug=make_password(None) ) user.is_admin = True user.save(using=self._db) @@ -48,6 +50,11 @@ class CustomUser(AbstractBaseUser): validated = models.IntegerField(choices=VALIDATED_CHOICES, default=0) validation_slug = models.CharField(db_index=True, unique=True, max_length=50) + is_staff = models.BooleanField( + _('staff status'), + default=False, + help_text=_('Designates whether the user can log into this admin site.'), + ) objects = MyUserManager() @@ -58,9 +65,8 @@ class CustomUser(AbstractBaseUser): def register(cls, name, password, email): user = cls.objects.filter(email=email).first() if not user: - user = cls.objects.create_user(username=name, email=email, password=password) + user = cls.objects.create_user(name=name, email=email, password=password) if user: - user.validation_slug = make_password(None) send_mail(REGISTRATION_MESSAGE['subject'], REGISTRATION_MESSAGE['message'].format(user.validation_slug), REGISTRATION_MESSAGE['from'], [user.email], fail_silently=False) @@ -75,11 +81,12 @@ class CustomUser(AbstractBaseUser): user = cls.objects.filter(validation_slug=validation_slug).first() if user: user.validated = 1 + user.save() return True return False def is_superuser(self): - return True + return False def is_admin(self): return True @@ -96,6 +103,7 @@ class CustomUser(AbstractBaseUser): return self.email def has_perm(self, perm, obj=None): + print(perm) "Does the user have a specific permission?" # Simplest possible answer: Yes, always return True diff --git a/membership/templates/error.html b/membership/templates/error.html index f5206a59..7e7ce023 100644 --- a/membership/templates/error.html +++ b/membership/templates/error.html @@ -23,12 +23,11 @@
Your last action was not complete. +
Your last action was not complete. {{ msg }}
Have problems? contact us at
help@digitalglarus.ch
{{ msg }}
redirecting...
+ {% else %} +Email not verfied!
+ {% endif %} + +