Change default list identifier
This commit is contained in:
parent
97bcfd96c2
commit
3ecf4e58cb
4 changed files with 10 additions and 9 deletions
|
@ -13,7 +13,7 @@ EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
|
||||||
|
|
||||||
# Document
|
# Document
|
||||||
TODO_STAFF_ONLY = False
|
TODO_STAFF_ONLY = False
|
||||||
TODO_DEFAULT_LIST_ID = None
|
TODO_DEFAULT_LIST_SLUG = 'tickets'
|
||||||
TODO_DEFAULT_ASSIGNEE = None
|
TODO_DEFAULT_ASSIGNEE = None
|
||||||
TODO_PUBLIC_SUBMIT_REDIRECT = '/'
|
TODO_PUBLIC_SUBMIT_REDIRECT = '/'
|
||||||
|
|
||||||
|
|
|
@ -86,9 +86,10 @@ class Command(BaseCommand):
|
||||||
user.groups.add(bw_group)
|
user.groups.add(bw_group)
|
||||||
user.groups.add(sd_group)
|
user.groups.add(sd_group)
|
||||||
|
|
||||||
# Create lists with tasks
|
# Create lists with tasks, plus one with fixed name for externally added tasks
|
||||||
TaskListFactory.create_batch(5, group=bw_group)
|
TaskListFactory.create_batch(5, group=bw_group)
|
||||||
TaskListFactory.create_batch(5, group=sd_group)
|
TaskListFactory.create_batch(5, group=sd_group)
|
||||||
|
TaskListFactory.create(name="Public Tickets", slug="tickets", group=bw_group)
|
||||||
|
|
||||||
print("For each of two groups, created fake tasks in each of {} fake lists.".format(num_lists))
|
print("For each of two groups, created fake tasks in each of {} fake lists.".format(num_lists))
|
||||||
|
|
||||||
|
|
|
@ -32,8 +32,8 @@ def test_view_reorder(todo_setup, admin_client):
|
||||||
|
|
||||||
def test_view_external_add(todo_setup, admin_client, settings):
|
def test_view_external_add(todo_setup, admin_client, settings):
|
||||||
default_list = TaskList.objects.first()
|
default_list = TaskList.objects.first()
|
||||||
settings.TODO_DEFAULT_LIST_ID = default_list.id
|
settings.TODO_DEFAULT_LIST_SLUG = default_list.slug
|
||||||
assert settings.TODO_DEFAULT_LIST_ID == default_list.id
|
assert settings.TODO_DEFAULT_LIST_SLUG == default_list.slug
|
||||||
url = reverse('todo:external_add')
|
url = reverse('todo:external_add')
|
||||||
response = admin_client.get(url)
|
response = admin_client.get(url)
|
||||||
assert response.status_code == 200
|
assert response.status_code == 200
|
||||||
|
|
|
@ -349,11 +349,11 @@ def external_add(request) -> HttpResponse:
|
||||||
Publicly filed tickets are unassigned unless settings.DEFAULT_ASSIGNEE exists.
|
Publicly filed tickets are unassigned unless settings.DEFAULT_ASSIGNEE exists.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not settings.TODO_DEFAULT_LIST_ID:
|
if not settings.TODO_DEFAULT_LIST_SLUG:
|
||||||
raise RuntimeError("This feature requires TODO_DEFAULT_LIST_ID: in settings. See documentation.")
|
raise RuntimeError("This feature requires TODO_DEFAULT_LIST_SLUG: in settings. See documentation.")
|
||||||
|
|
||||||
if not TaskList.objects.filter(id=settings.TODO_DEFAULT_LIST_ID).exists():
|
if not TaskList.objects.filter(slug=settings.TODO_DEFAULT_LIST_SLUG).exists():
|
||||||
raise RuntimeError("There is no TaskList with ID specified for DEFAULT_LIST_ID in settings.")
|
raise RuntimeError("There is no TaskList with slug specified for TODO_DEFAULT_LIST_SLUG in settings.")
|
||||||
|
|
||||||
if request.POST:
|
if request.POST:
|
||||||
form = AddExternalTaskForm(request.POST)
|
form = AddExternalTaskForm(request.POST)
|
||||||
|
@ -361,7 +361,7 @@ def external_add(request) -> HttpResponse:
|
||||||
if form.is_valid():
|
if form.is_valid():
|
||||||
current_site = Site.objects.get_current()
|
current_site = Site.objects.get_current()
|
||||||
task = form.save(commit=False)
|
task = form.save(commit=False)
|
||||||
task.task_list = TaskList.objects.get(id=settings.TODO_DEFAULT_LIST_ID)
|
task.task_list = TaskList.objects.get(slug=settings.TODO_DEFAULT_LIST_SLUG)
|
||||||
task.created_by = request.user
|
task.created_by = request.user
|
||||||
if settings.TODO_DEFAULT_ASSIGNEE:
|
if settings.TODO_DEFAULT_ASSIGNEE:
|
||||||
task.assigned_to = User.objects.get(username=settings.TODO_DEFAULT_ASSIGNEE)
|
task.assigned_to = User.objects.get(username=settings.TODO_DEFAULT_ASSIGNEE)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue