Improve verbose name of custom group model. Allow user to be created without belonging to an organization, this is used for superusers.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations, models
|
||||
import django.contrib.auth.models
|
||||
import organizations.shortcuts
|
||||
import user_management.models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('user_management', '0003_auto_20160525_0155'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterModelManagers(
|
||||
name='mayanuser',
|
||||
managers=[
|
||||
('objects', django.contrib.auth.models.UserManager()),
|
||||
('on_organization', user_management.models.OrganizationUserManagerHybridClass()),
|
||||
],
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='mayanuser',
|
||||
name='organization',
|
||||
field=models.ForeignKey(default=organizations.shortcuts.get_current_organization, blank=True, to='organizations.Organization', null=True),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='mayanuser',
|
||||
name='organization_groups',
|
||||
field=models.ManyToManyField(related_query_name='user', related_name='users', to='user_management.MayanGroup', blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', verbose_name='Groups'),
|
||||
),
|
||||
]
|
||||
@@ -18,6 +18,10 @@ class MayanGroup(Group):
|
||||
objects = GroupManager()
|
||||
on_organization = CurrentOrganizationManager()
|
||||
|
||||
class Meta:
|
||||
verbose_name = _('Group')
|
||||
verbose_name_plural = _('Groups')
|
||||
|
||||
|
||||
class OrganizationUserManagerHybridClass(CurrentOrganizationManager, UserManager):
|
||||
"""
|
||||
@@ -27,7 +31,7 @@ class OrganizationUserManagerHybridClass(CurrentOrganizationManager, UserManager
|
||||
|
||||
class MayanUser(AbstractUser):
|
||||
organization = models.ForeignKey(
|
||||
Organization, default=get_current_organization
|
||||
Organization, blank=True, default=get_current_organization, null=True
|
||||
)
|
||||
|
||||
organization_groups = models.ManyToManyField(
|
||||
|
||||
Reference in New Issue
Block a user