from django.db import models from django.urls import reverse from whoisdb.models import Maintainer class Request(models.Model): STATE_OPEN = "OPEN" STATE_RESOLVED = "RESOLVED" STATE_REJECTED = "REJECTED" STATES = ( (STATE_OPEN, 'Open'), (STATE_RESOLVED, 'Resolved'), (STATE_REJECTED, 'Rejected'), ) # request goes to mnt? subject = models.CharField(max_length=200) status = models.CharField(max_length=16, choices=STATES) applicant = models.ForeignKey(Maintainer) provider = models.ForeignKey(Maintainer, related_name='requestfrom_set') requestResources = models.TextField() grantedResources = models.TextField() created = models.DateTimeField(auto_now_add=True) lastAction = models.DateTimeField(auto_now_add=True) def get_absolute_url(self): return reverse("rrequests:show", args=(self.pk,)) def __str__(self): return "(%s -> %s) [%s] %s" % (self.applicant, self.provider, self.status, self.subject) class RequestMessage(models.Model): request = models.ForeignKey(Request) statusChanged = models.CharField(max_length=16, choices=Request.STATES, default=None, null=True, blank=True) creator = models.ForeignKey(Maintainer) message = models.TextField() created = models.DateTimeField(auto_now_add=True)