Use default user auth group from site settings
This commit is contained in:
parent
2c680cb365
commit
7ae983acdf
2 changed files with 40 additions and 4 deletions
|
@ -3,9 +3,9 @@ import re
|
|||
from urllib.parse import urlparse
|
||||
|
||||
from django.apps import apps
|
||||
from django.contrib.auth.models import AbstractUser, Group
|
||||
from django.contrib.auth.models import AbstractUser
|
||||
from django.contrib.postgres.fields import ArrayField, CICharField
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.core.exceptions import PermissionDenied, ObjectDoesNotExist
|
||||
from django.dispatch import receiver
|
||||
from django.db import models, transaction
|
||||
from django.utils import timezone
|
||||
|
@ -356,8 +356,14 @@ class User(OrderedCollectionPageMixin, AbstractUser):
|
|||
|
||||
# make users editors by default
|
||||
try:
|
||||
self.groups.add(Group.objects.get(name="editor"))
|
||||
except Group.DoesNotExist:
|
||||
group = (
|
||||
apps.get_model("bookwyrm.SiteSettings")
|
||||
.objects.get()
|
||||
.default_user_auth_group
|
||||
)
|
||||
if group:
|
||||
self.groups.add(group)
|
||||
except ObjectDoesNotExist:
|
||||
# this should only happen in tests
|
||||
pass
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue