Add new settings for default list ID, default assignee, default redirect on public ticket submission

This commit is contained in:
Scot Hacker 2014-11-07 23:28:39 -08:00
parent b388aece1b
commit 5689ed2b51
2 changed files with 17 additions and 4 deletions

View file

@ -1,3 +1,14 @@
from django.conf import settings
from django.contrib.auth.models import User
from todo.models import List
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)
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', '/')

View file

@ -15,6 +15,8 @@ from django.db import IntegrityError
from django.db.models import Q
from django.contrib import messages
from django.views.decorators.csrf import csrf_exempt
from django.contrib.auth.decorators import login_required
import datetime
@ -310,7 +312,7 @@ def reorder_tasks(request):
return HttpResponse(status=201)
@user_passes_test(check_user_allowed)
@login_required
def external_add(request):
"""
Allow users who don't have access to the rest of the ticket system to file a ticket in a specific list.
@ -324,9 +326,9 @@ def external_add(request):
if form.is_valid():
# Don't commit the save until we've added in the fields we need to set
item = form.save(commit=False)
item.list_id = 20 # Hate hard-coding in IDs like this.
item.list_id = settings.DEFAULT_LIST_ID
item.created_by = request.user
item.assigned_to = User.objects.get(username='roy_baril')
item.assigned_to = User.objects.get(username=settings.DEFAULT_ASSIGNEE)
item.save()
# Send email
@ -340,7 +342,7 @@ def external_add(request):
messages.success(request, "Your trouble ticket has been submitted. We'll get back to you soon.")
return HttpResponseRedirect(reverse('intranet_home'))
return HttpResponseRedirect(reverse(settings.PUBLIC_SUBMIT_REDIRECT))
else:
form = AddExternalItemForm()