You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

57 lines
1.7 KiB

# This file is part of dnmgmt, a number resource management system
# Licensed under GNU General Public License v3 or later
# Written by Sebastian Lohff (
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'),
# 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=(,))
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
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)