From 3879017dd18da0ac1cd8bac7bb1830534de26f2b Mon Sep 17 00:00:00 2001 From: Mallory Hancock Date: Sat, 19 Jan 2019 10:46:20 -0800 Subject: [PATCH 1/2] add filters and submitted field for tickets --- .gitignore | 4 ++++ ttadmin/help/admin.py | 3 ++- .../help/migrations/0004_ticket_submitted.py | 22 +++++++++++++++++++ ttadmin/help/models.py | 3 ++- .../migrations/0010_auto_20190119_1828.py | 20 +++++++++++++++++ 5 files changed, 50 insertions(+), 2 deletions(-) create mode 100644 ttadmin/help/migrations/0004_ticket_submitted.py create mode 100644 ttadmin/users/migrations/0010_auto_20190119_1828.py diff --git a/.gitignore b/.gitignore index 4a6690c..71f00c5 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,7 @@ __pycache__ .viminfo ttadmin/settings_live.py ttadmin/static +venv/ +build/ +dist/ + diff --git a/ttadmin/help/admin.py b/ttadmin/help/admin.py index 61cd79b..c9697f8 100644 --- a/ttadmin/help/admin.py +++ b/ttadmin/help/admin.py @@ -3,5 +3,6 @@ from .models import Ticket @admin.register(Ticket) class TicketAdmin(admin.ModelAdmin): - list_display = ('issue_status', 'issue_type', 'name', 'email') + list_display = ('submitted', 'issue_status', 'issue_type', 'name', 'email') + list_filter = ('issue_status', 'issue_type') fields = ('name', 'email', 'issue_status', 'issue_type', 'issue_text') diff --git a/ttadmin/help/migrations/0004_ticket_submitted.py b/ttadmin/help/migrations/0004_ticket_submitted.py new file mode 100644 index 0000000..f8b95c8 --- /dev/null +++ b/ttadmin/help/migrations/0004_ticket_submitted.py @@ -0,0 +1,22 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.2 on 2019-01-19 18:28 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('help', '0003_auto_20171110_2323'), + ] + + operations = [ + migrations.AddField( + model_name='ticket', + name='submitted', + field=models.DateTimeField(auto_now_add=True, default=django.utils.timezone.now), + preserve_default=False, + ), + ] diff --git a/ttadmin/help/models.py b/ttadmin/help/models.py index 06962e8..17df9b5 100644 --- a/ttadmin/help/models.py +++ b/ttadmin/help/models.py @@ -1,4 +1,4 @@ -from django.db.models import Model, TextField, EmailField, CharField +from django.db.models import Model, TextField, EmailField, CharField, DateTimeField ISSUE_TYPE_CHOICES = ( ('logging_in', 'help logging in'), @@ -18,6 +18,7 @@ ISSUE_STATUS_CHOICES = ( class Ticket(Model): + submitted = DateTimeField(auto_now_add=True) name = CharField(blank=False, null=False, max_length=100) email = EmailField(blank=False, null=False) issue_type = CharField(choices=ISSUE_TYPE_CHOICES, diff --git a/ttadmin/users/migrations/0010_auto_20190119_1828.py b/ttadmin/users/migrations/0010_auto_20190119_1828.py new file mode 100644 index 0000000..7563409 --- /dev/null +++ b/ttadmin/users/migrations/0010_auto_20190119_1828.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.2 on 2019-01-19 18:28 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0009_auto_20170114_0757'), + ] + + operations = [ + migrations.AlterField( + model_name='pubkey', + name='key_type', + field=models.CharField(choices=[('ssh-rsa', 'ssh-rsa'), ('ssh-dss', 'ssh-dss'), ('ecdsa-sha2-nistp256', 'ecdsa-sha2-nistp256')], max_length=50), + ), + ] From 9f9fbf949bc5e6173452036e9174cb99e2d09d95 Mon Sep 17 00:00:00 2001 From: Mallory Hancock Date: Sat, 19 Jan 2019 11:17:19 -0800 Subject: [PATCH 2/2] add in readonly field to admin form --- ttadmin/help/admin.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ttadmin/help/admin.py b/ttadmin/help/admin.py index c9697f8..e29cc6b 100644 --- a/ttadmin/help/admin.py +++ b/ttadmin/help/admin.py @@ -3,6 +3,7 @@ from .models import Ticket @admin.register(Ticket) class TicketAdmin(admin.ModelAdmin): + readonly_fields = ('submitted',) list_display = ('submitted', 'issue_status', 'issue_type', 'name', 'email') list_filter = ('issue_status', 'issue_type') - fields = ('name', 'email', 'issue_status', 'issue_type', 'issue_text') + fields = ('submitted', 'name', 'email', 'issue_status', 'issue_type', 'issue_text')