tildetown-admin/ttadmin/help/models.py

57 lines
1.8 KiB
Python
Raw Normal View History

2019-07-18 22:04:59 +00:00
from django.contrib.auth.models import User
2019-07-16 02:44:03 +00:00
from django.db.models import Model, TextField, EmailField, CharField, DateTimeField, ForeignKey
2016-12-19 07:20:48 +00:00
ISSUE_TYPE_CHOICES = (
('logging_in', 'help logging in'),
('concern_site', 'concern about the site'),
('concern_user', 'concern about another user'),
('package', 'install a package'),
('question', 'just a question',),
('other', 'something else'),
)
2016-12-19 23:38:10 +00:00
ISSUE_STATUS_CHOICES = (
('triage', 'to triage'),
('acked', 'acknowledged'),
('waiting', 'waiting to hear from submitter'),
('completed', 'nothing more to do'),
)
2016-12-19 05:15:06 +00:00
class Ticket(Model):
submitted = DateTimeField(auto_now_add=True)
name = CharField(blank=False, null=False, max_length=100)
2016-12-19 07:20:48 +00:00
email = EmailField(blank=False, null=False)
issue_type = CharField(choices=ISSUE_TYPE_CHOICES,
blank=False,
null=False,
max_length=50)
issue_text = TextField(blank=False, null=False)
2016-12-19 23:38:10 +00:00
issue_status = CharField(choices=ISSUE_STATUS_CHOICES,
blank=False,
null=False,
max_length=50,
default=ISSUE_STATUS_CHOICES[0][0])
2019-07-18 22:25:28 +00:00
assigned = ForeignKey(User, blank=True, null=True, help_text="Assign this ticket to an admin or unassign it.")
2016-12-19 07:20:48 +00:00
def __str__(self):
return '{} from {}'.format(self.issue_type, self.name)
2019-07-16 02:44:03 +00:00
class Note(Model):
created = DateTimeField(auto_now_add=True)
body = TextField(blank=False, null=False)
2019-07-18 22:04:59 +00:00
author = ForeignKey(User)
2019-07-16 02:44:03 +00:00
ticket = ForeignKey(Ticket)
2019-07-18 22:04:59 +00:00
def __str__(self):
return "admin note"
2019-07-20 01:52:01 +00:00
class EmailTemplate(Model):
name = CharField(blank=False, null=False, max_length=50)
body = TextField(blank=False, null=False)
def __str__(self):
return f"'{self.name}' email template"