From 32e640b875bc7060c7bc89c6a7d3bbdfc89c20fb Mon Sep 17 00:00:00 2001 From: Nate Smith Date: Thu, 18 Jul 2019 17:25:28 -0500 Subject: [PATCH] support assigning of help tickets --- ttadmin/help/admin.py | 8 +++---- .../help/migrations/0007_ticket_assigned.py | 23 +++++++++++++++++++ .../migrations/0008_auto_20190718_2223.py | 22 ++++++++++++++++++ ttadmin/help/models.py | 1 + 4 files changed, 50 insertions(+), 4 deletions(-) create mode 100644 ttadmin/help/migrations/0007_ticket_assigned.py create mode 100644 ttadmin/help/migrations/0008_auto_20190718_2223.py diff --git a/ttadmin/help/admin.py b/ttadmin/help/admin.py index 1c8d448..5bb4f43 100644 --- a/ttadmin/help/admin.py +++ b/ttadmin/help/admin.py @@ -26,10 +26,10 @@ class NewNoteInline(admin.StackedInline): @admin.register(Ticket) class TicketAdmin(admin.ModelAdmin): inlines = [ImmutableNoteInline, NewNoteInline] - readonly_fields = ('submitted',) - list_display = ('submitted', 'issue_status', 'issue_type', 'name', 'email') - list_filter = ('issue_status', 'issue_type') - fields = ('submitted', 'name', 'email', 'issue_status', 'issue_type', 'issue_text') + readonly_fields = ('submitted', 'issue_type') + list_display = ('submitted', 'issue_status', 'assigned', 'issue_type', 'name', 'email',) + list_filter = ('issue_status', 'issue_type', 'assigned') + fields = ('submitted', 'name', 'email', 'assigned', 'issue_status', 'issue_type', 'issue_text') def save_related(self, request, form, formsets, change): # THIS IS EXTREMELY BOOTLEG AND MAY BREAK IF MORE INLINES ARE ADDED TO THIS ADMIN. diff --git a/ttadmin/help/migrations/0007_ticket_assigned.py b/ttadmin/help/migrations/0007_ticket_assigned.py new file mode 100644 index 0000000..2b4029a --- /dev/null +++ b/ttadmin/help/migrations/0007_ticket_assigned.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.2 on 2019-07-18 22:21 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + migrations.swappable_dependency(settings.AUTH_USER_MODEL), + ('help', '0006_auto_20190716_0258'), + ] + + operations = [ + migrations.AddField( + model_name='ticket', + name='assigned', + field=models.ForeignKey(help_text='Assign this ticket to an admin or unassign it.', null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/ttadmin/help/migrations/0008_auto_20190718_2223.py b/ttadmin/help/migrations/0008_auto_20190718_2223.py new file mode 100644 index 0000000..dd394ee --- /dev/null +++ b/ttadmin/help/migrations/0008_auto_20190718_2223.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.2 on 2019-07-18 22:23 +from __future__ import unicode_literals + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('help', '0007_ticket_assigned'), + ] + + operations = [ + migrations.AlterField( + model_name='ticket', + name='assigned', + field=models.ForeignKey(blank=True, help_text='Assign this ticket to an admin or unassign it.', null=True, on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/ttadmin/help/models.py b/ttadmin/help/models.py index a9ff5af..70609aa 100644 --- a/ttadmin/help/models.py +++ b/ttadmin/help/models.py @@ -32,6 +32,7 @@ class Ticket(Model): null=False, max_length=50, default=ISSUE_STATUS_CHOICES[0][0]) + assigned = ForeignKey(User, blank=True, null=True, help_text="Assign this ticket to an admin or unassign it.") def __str__(self): return '{} from {}'.format(self.issue_type, self.name)