Merge branch 'master' into feature/flake8
This commit is contained in:
		
				commit
				
					
						fcc109b8f5
					
				
			
		
					 15 changed files with 701 additions and 372 deletions
				
			
		|  | @ -5,6 +5,8 @@ from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, Permis | |||
| from django.contrib.auth.hashers import make_password | ||||
| from django.core.validators import RegexValidator | ||||
| from django.contrib.sites.models import Site | ||||
| from django.conf import settings | ||||
| from django.utils.crypto import get_random_string | ||||
| 
 | ||||
| from utils.stripe_utils import StripeUtils | ||||
| from utils.mailer import DigitalGlarusRegistrationMailer | ||||
|  | @ -73,7 +75,7 @@ class CustomUser(AbstractBaseUser, PermissionsMixin): | |||
|     REQUIRED_FIELDS = ['name', 'password'] | ||||
| 
 | ||||
|     @classmethod | ||||
|     def register(cls, name, password, email, app='digital_glarus', base_url=None): | ||||
|     def register(cls, name, password, email, app='digital_glarus', base_url=None, send_email=True): | ||||
|         user = cls.objects.filter(email=email).first() | ||||
|         if not user: | ||||
|             user = cls.objects.create_user(name=name, email=email, password=password) | ||||
|  | @ -82,19 +84,24 @@ class CustomUser(AbstractBaseUser, PermissionsMixin): | |||
|                     dg = DigitalGlarusRegistrationMailer(user.validation_slug) | ||||
|                     dg.send_mail(to=user.email) | ||||
|                 elif app == 'dcl': | ||||
|                     dcl_text = settings.DCL_TEXT | ||||
|                     dcl_from_address = settings.DCL_SUPPORT_FROM_ADDRESS | ||||
|                     user.is_active = False | ||||
|                     email_data = { | ||||
|                         'subject': _('Activate your Data Center Light account'), | ||||
|                         'from_address': '(Data Center Light) Data Center Light Support <support@datacenterlight.ch>', | ||||
|                         'to': user.email, | ||||
|                         'context': {'base_url': base_url, | ||||
|                                     'activation_link': reverse('hosting:validate', | ||||
|                                                                kwargs={'validate_slug': user.validation_slug})}, | ||||
|                         'template_name': 'user_activation', | ||||
|                         'template_path': 'datacenterlight/emails/' | ||||
|                     } | ||||
|                     email = BaseEmail(**email_data) | ||||
|                     email.send() | ||||
| 
 | ||||
|                     if send_email is True: | ||||
|                         email_data = { | ||||
|                             'subject': str(_('Activate your ')) + dcl_text + str(_(' account')), | ||||
|                             'from_address': settings.DCL_SUPPORT_FROM_ADDRESS, | ||||
|                             'to': user.email, | ||||
|                             'context': {'base_url'  : base_url,  | ||||
|                                         'activation_link' : reverse('hosting:validate', kwargs={'validate_slug': user.validation_slug}), | ||||
|                                         'dcl_text' : dcl_text | ||||
|                                         }, | ||||
|                             'template_name': 'user_activation', | ||||
|                             'template_path': 'datacenterlight/emails/' | ||||
|                         } | ||||
|                         email = BaseEmail(**email_data) | ||||
|                         email.send() | ||||
|                 return user | ||||
|             else: | ||||
|                 return None | ||||
|  | @ -114,6 +121,10 @@ class CustomUser(AbstractBaseUser, PermissionsMixin): | |||
|             return True | ||||
|         return False | ||||
| 
 | ||||
|     @classmethod | ||||
|     def get_random_password(cls): | ||||
|         return get_random_string(24) | ||||
| 
 | ||||
|     def is_superuser(self): | ||||
|         return False | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue