kopia lustrzana https://github.com/wagtail/wagtail
Revert hacks dealing with EmailUser not inheriting from PermissionsMixin
These were necessary when EmailUser was installed at the same time as CustomUser, because the reverse relations on Permission / Group would have clashed. Now we're only installing one at a time, this isn't necessary.pull/6361/head
rodzic
afb51eafbe
commit
8c38dc5cf5
|
@ -0,0 +1,24 @@
|
|||
# Generated by Django 3.1 on 2020-08-13 23:00
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('auth', '0012_alter_user_first_name_max_length'),
|
||||
('emailuser', '0001_initial'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AlterField(
|
||||
model_name='emailuser',
|
||||
name='groups',
|
||||
field=models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups'),
|
||||
),
|
||||
migrations.AlterField(
|
||||
model_name='emailuser',
|
||||
name='user_permissions',
|
||||
field=models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions'),
|
||||
),
|
||||
]
|
|
@ -1,5 +1,4 @@
|
|||
from django.contrib.auth.models import (
|
||||
AbstractBaseUser, BaseUserManager, Group, Permission, PermissionsMixin)
|
||||
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager, PermissionsMixin
|
||||
from django.db import models
|
||||
|
||||
|
||||
|
@ -25,9 +24,7 @@ class EmailUserManager(BaseUserManager):
|
|||
**extra_fields)
|
||||
|
||||
|
||||
class EmailUser(AbstractBaseUser):
|
||||
# Cant inherit from PermissionsMixin because of clashes with
|
||||
# groups/user_permissions related_names.
|
||||
class EmailUser(AbstractBaseUser, PermissionsMixin):
|
||||
email = models.EmailField(max_length=255, unique=True)
|
||||
is_staff = models.BooleanField(default=True)
|
||||
is_active = models.BooleanField(default=True)
|
||||
|
@ -35,8 +32,6 @@ class EmailUser(AbstractBaseUser):
|
|||
last_name = models.CharField(max_length=50, blank=True)
|
||||
|
||||
is_superuser = models.BooleanField(default=False)
|
||||
groups = models.ManyToManyField(Group, related_name='+', blank=True)
|
||||
user_permissions = models.ManyToManyField(Permission, related_name='+', blank=True)
|
||||
|
||||
USERNAME_FIELD = 'email'
|
||||
|
||||
|
@ -47,10 +42,3 @@ class EmailUser(AbstractBaseUser):
|
|||
|
||||
def get_short_name(self):
|
||||
return self.first_name
|
||||
|
||||
|
||||
methods = ['get_group_permissions', 'get_all_permissions', 'has_perm',
|
||||
'has_perms', 'has_module_perms']
|
||||
for method in methods:
|
||||
func = getattr(PermissionsMixin, method)
|
||||
setattr(EmailUser, method, func)
|
||||
|
|
Ładowanie…
Reference in New Issue