57 lines
1.7 KiB
Python
57 lines
1.7 KiB
Python
# This file is part of dnmgmt, a number resource management system
|
|
# Licensed under GNU General Public License v3 or later
|
|
# Written by Sebastian Lohff (seba@someserver.de)
|
|
|
|
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)
|
|
|
|
def getLastActionBy(self):
|
|
msgs = self.requestmessage_set.order_by("-created")
|
|
|
|
if msgs.count() > 0:
|
|
return msgs[0].creator
|
|
else:
|
|
return None
|
|
|
|
|
|
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)
|