|
|
|
|
@ -1,6 +1,7 @@ |
|
|
|
|
# encoding=utf-8 |
|
|
|
|
import random |
|
|
|
|
import string |
|
|
|
|
import json |
|
|
|
|
from courses.models import Vertex, Course |
|
|
|
|
from storage.models import Storage |
|
|
|
|
|
|
|
|
|
@ -60,10 +61,12 @@ class CustomUserManager(BaseUserManager): |
|
|
|
|
return self._create_user(**kwargs) |
|
|
|
|
|
|
|
|
|
@transaction_decorator |
|
|
|
|
def _create_user(self, email, password=None, is_staff=False, is_superuser=False, role_list=[], |
|
|
|
|
def _create_user(self, email, password=None, is_staff=False, is_superuser=False, role_list=None, |
|
|
|
|
is_active=False, first_name='Guest', hash_password=None, is_send=False, |
|
|
|
|
date_joined=timezone.now(), last_login=timezone.now(), **extra_fields): |
|
|
|
|
|
|
|
|
|
if role_list is None: |
|
|
|
|
role_list = [] |
|
|
|
|
if not email: |
|
|
|
|
raise ValueError('The given email must be set') |
|
|
|
|
|
|
|
|
|
@ -81,10 +84,13 @@ class CustomUserManager(BaseUserManager): |
|
|
|
|
user.password = hash_password |
|
|
|
|
|
|
|
|
|
user.save(using=self._db) |
|
|
|
|
|
|
|
|
|
Account.objects.create(owner=user) |
|
|
|
|
|
|
|
|
|
for group in role_list: |
|
|
|
|
user.groups.add(group) |
|
|
|
|
if role_list: |
|
|
|
|
for group in json.loads(role_list): |
|
|
|
|
user.groups.add(group) |
|
|
|
|
user.save(using=self._db) |
|
|
|
|
|
|
|
|
|
if is_send: |
|
|
|
|
pass |
|
|
|
|
|