Don't require superuser
Just require default_assignee for anon ticket submissions Resolves https://github.com/shacker/django-todo/issues/25
This commit is contained in:
parent
f9efd68f82
commit
c3e47ba438
2 changed files with 4 additions and 10 deletions
|
@ -1,16 +1,10 @@
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.contrib.auth.models import User
|
from django.contrib.auth.models import User
|
||||||
|
|
||||||
|
def missing_defaults():
|
||||||
class MissingSuperuserException(Exception):
|
raise AttributeError('django-todo requires settings TODO_DEFAULT_ASSIGNEE and TODO_PUBLIC_SUBMIT_REDIRECT for anonymous ticket submissions.')
|
||||||
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)
|
||||||
DEFAULT_ASSIGNEE = getattr(settings, 'TODO_DEFAULT_ASSIGNEE', first_superuser.username)
|
|
||||||
DEFAULT_LIST_ID = getattr(settings, 'TODO_DEFAULT_LIST_ID', 1)
|
DEFAULT_LIST_ID = getattr(settings, 'TODO_DEFAULT_LIST_ID', 1)
|
||||||
|
DEFAULT_ASSIGNEE = getattr(settings, 'TODO_DEFAULT_ASSIGNEE', missing_defaults)
|
||||||
PUBLIC_SUBMIT_REDIRECT = getattr(settings, 'TODO_PUBLIC_SUBMIT_REDIRECT', '/')
|
PUBLIC_SUBMIT_REDIRECT = getattr(settings, 'TODO_PUBLIC_SUBMIT_REDIRECT', '/')
|
||||||
|
|
|
@ -344,7 +344,7 @@ def external_add(request):
|
||||||
|
|
||||||
messages.success(request, "Your trouble ticket has been submitted. We'll get back to you soon.")
|
messages.success(request, "Your trouble ticket has been submitted. We'll get back to you soon.")
|
||||||
|
|
||||||
return HttpResponseRedirect(reverse(settings.PUBLIC_SUBMIT_REDIRECT))
|
return HttpResponseRedirect(settings.PUBLIC_SUBMIT_REDIRECT)
|
||||||
else:
|
else:
|
||||||
form = AddExternalItemForm()
|
form = AddExternalItemForm()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue