[Update] 修改一些逻辑

This commit is contained in:
ibuler
2018-07-14 00:47:21 +08:00
parent 7412bdcba7
commit 28e47f33c1
30 changed files with 167 additions and 185 deletions

View File

@@ -4,10 +4,12 @@ import uuid
from django.db import models, IntegrityError
from django.utils.translation import ugettext_lazy as _
from orgs.mixins import OrgModelMixin
__all__ = ['UserGroup']
class UserGroup(models.Model):
class UserGroup(OrgModelMixin):
id = models.UUIDField(default=uuid.uuid4, primary_key=True)
name = models.CharField(max_length=128, unique=True, verbose_name=_('Name'))
comment = models.TextField(blank=True, verbose_name=_('Comment'))

View File

@@ -220,11 +220,10 @@ class User(AbstractUser):
if self.username == 'admin':
self.role = 'Admin'
self.is_active = True
instance = super().save(*args, **kwargs)
super().save(*args, **kwargs)
current_org = get_current_org()
if current_org and current_org.is_real():
instance.orgs.add(current_org)
return instance
self.orgs.add(current_org)
@property
def private_token(self):