Custom exception for missing superuser in settings
This commit is contained in:
parent
85c45ecbfc
commit
c408224e02
1 changed files with 10 additions and 7 deletions
|
@ -2,13 +2,16 @@ from django.conf import settings
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
from todo.models import List
|
from todo.models import List
|
||||||
|
|
||||||
|
|
||||||
|
class MissingSuperuserException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
try:
|
||||||
|
first_superuser = User.objects.filter(is_superuser=True)[0]
|
||||||
|
except:
|
||||||
|
raise MissingSuperuserException('django-todo requires at least one superuser in the database')
|
||||||
|
|
||||||
STAFF_ONLY = getattr(settings, 'TODO_STAFF_ONLY', False)
|
STAFF_ONLY = getattr(settings, 'TODO_STAFF_ONLY', False)
|
||||||
|
|
||||||
first_superuser = User.objects.filter(is_superuser=True)[0]
|
|
||||||
DEFAULT_ASSIGNEE = getattr(settings, 'TODO_DEFAULT_ASSIGNEE', first_superuser.username)
|
DEFAULT_ASSIGNEE = getattr(settings, 'TODO_DEFAULT_ASSIGNEE', first_superuser.username)
|
||||||
|
DEFAULT_LIST_ID = getattr(settings, 'TODO_DEFAULT_LIST_ID', 1)
|
||||||
first_list = List.objects.first()
|
|
||||||
DEFAULT_LIST_ID = getattr(settings, 'TODO_DEFAULT_LIST_ID', first_list.id)
|
|
||||||
|
|
||||||
PUBLIC_SUBMIT_REDIRECT = getattr(settings, 'TODO_PUBLIC_SUBMIT_REDIRECT', '/')
|
PUBLIC_SUBMIT_REDIRECT = getattr(settings, 'TODO_PUBLIC_SUBMIT_REDIRECT', '/')
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue