messy wip for Note

admin-improvements
Nate Smith 2019-07-15 21:44:03 -05:00
parent 31adb3cc3a
commit dfd843064d
3 changed files with 50 additions and 2 deletions

View File

@ -1,5 +1,13 @@
from django.contrib import admin
from .models import Ticket
from django.forms import ModelForm
from .models import Ticket, Note
class NoteInline(admin.StackedInline):
model = Note
fields = ('created_at', 'body', 'author')
readonly_fields = ('created_at', 'body', 'author')
ordering = ('created_at',)
extra = 1
@admin.register(Ticket)
class TicketAdmin(admin.ModelAdmin):
@ -7,3 +15,9 @@ class TicketAdmin(admin.ModelAdmin):
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')
def save_related(request, form, formsets, change):
for formset in formsets:
import ipdb; ipdb.set_trace()
pass # TODO set author based on request
super()

View File

@ -0,0 +1,27 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.10.2 on 2019-07-16 02:43
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('users', '0015_remove_townie_reviewed'),
('help', '0004_ticket_submitted'),
]
operations = [
migrations.CreateModel(
name='Note',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('created', models.DateTimeField(auto_now_add=True)),
('body', models.TextField()),
('author', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='users.Townie')),
('ticket', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='help.Ticket')),
],
),
]

View File

@ -1,4 +1,4 @@
from django.db.models import Model, TextField, EmailField, CharField, DateTimeField
from django.db.models import Model, TextField, EmailField, CharField, DateTimeField, ForeignKey
ISSUE_TYPE_CHOICES = (
('logging_in', 'help logging in'),
@ -34,3 +34,10 @@ class Ticket(Model):
def __str__(self):
return '{} from {}'.format(self.issue_type, self.name)
class Note(Model):
created = DateTimeField(auto_now_add=True)
body = TextField(blank=False, null=False)
author = ForeignKey('users.Townie')
ticket = ForeignKey(Ticket)