Skip to content

Commit

Permalink
Add application and associated models
Browse files Browse the repository at this point in the history
Models to reflect the current thinking on the data required to
make a decision on an application. In the Review model we use
the simple-history package to track changes made to the review
fields.
  • Loading branch information
jimnarey committed Mar 8, 2024
1 parent 40b6f72 commit 4b74220
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 10 deletions.
10 changes: 0 additions & 10 deletions request_a_govuk_domain/request/models.py

This file was deleted.

16 changes: 16 additions & 0 deletions request_a_govuk_domain/request/models/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from .application import Application, ApplicationStatus, CentralGovernmentAttributes
from .organisation import Organisation, Registrant, Registrar, RegistrantTypeChoices
from .person import Person
from .review import Review

__all__ = [
"Application",
"ApplicationStatus",
"CentralGovernmentAttributes",
"Organisation",
"Registrant",
"Registrar",
"RegistrantTypeChoices",
"Person",
"Review",
]
45 changes: 45 additions & 0 deletions request_a_govuk_domain/request/models/application.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from django.db import models
from .person import Person
from .organisation import Registrant, Registrar
from .review import Review

REF_NUM_LENGTH = 6


class ApplicationStatus(models.TextChoices):
approved = "Approved"
rejected = "Rejected"
pending = "Pending"


class Application(models.Model):
_reference = models.CharField(max_length=REF_NUM_LENGTH, blank=True)
status = models.CharField(
choices=ApplicationStatus.choices,
default=ApplicationStatus.pending,
max_length=8,
)
domain_name = models.CharField(max_length=253)
applicant = Person()
registrant_person = Person()
responsible_person = Person()
registrant_org = Registrant()
registrar = Registrar()
written_permission_evidence = models.FileField
review = Review()

@property
def reference(self):
if not self._reference:
self._reference = hex(self.id)[2:].upper().zfill(REF_NUM_LENGTH)
return self._reference


class CentralGovernmentAttributes(models.Model):
application = models.OneToOneField(Application, on_delete=models.CASCADE)
domain_purpose = models.CharField()
ministerial_request_evidence = models.FileField
gds_exemption_evidence = models.FileField

class Meta:
default_related_name = "centralgovt"
27 changes: 27 additions & 0 deletions request_a_govuk_domain/request/models/organisation.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from django.db import models


class Organisation(models.Model):
name = models.CharField()


class RegistrantTypeChoices(models.TextChoices):
central_goverment = "Central government department or agency"
ndpb = "Non-departmental body - also known as an arm's length body"
fire_service = "Fire Service"
local_authority = "County, borough, metropolitan or district council"
parish_council = "Parish, town or community council"
village_council = "Neighbourhood or village council"
combined_authority = "Combined or unitary authority"
pcc = "Police and Crime Commissioner"
joint_authority = "Joint Authority"
joint_committee = "Joint Committee"
representative = "Representing public sector bodies"


class Registrant(Organisation):
type = models.CharField(choices=RegistrantTypeChoices.choices, max_length=100)


class Registrar(Organisation):
email_address = models.EmailField(max_length=320)
9 changes: 9 additions & 0 deletions request_a_govuk_domain/request/models/person.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
from django.db import models
from phonenumber_field.modelfields import PhoneNumberField


class Person(models.Model):
name = models.CharField() # We don't need to set a max under Django 4.2
email_address = models.EmailField(max_length=320)
role = models.CharField()
phone_number = PhoneNumberField(blank=True)
34 changes: 34 additions & 0 deletions request_a_govuk_domain/request/models/review.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from django.db import models
from simple_history.models import HistoricalRecords

NOTES_MAX_LENGTH = 500


class Review(models.Model):
registrant_org_exists = models.BooleanField(default=False)
registrant_org_exists_notes = models.TextField(max_length=NOTES_MAX_LENGTH)

registrant_org_eligible = models.BooleanField(default=False)
registrant_org_eligible_notes = models.TextField(max_length=NOTES_MAX_LENGTH)

registrant_person_id_confirmed = models.BooleanField(default=False)
registrant_person_id_confirmed_notes = models.TextField(max_length=NOTES_MAX_LENGTH)

permission_signatory_role_confirmed = models.BooleanField(default=False)
permission_signatory_role_confirmed_notes = models.TextField(
max_length=NOTES_MAX_LENGTH
)

domain_name_validated = models.BooleanField(default=False)
domain_name_validated_notes = models.TextField(max_length=NOTES_MAX_LENGTH)

gds_exemption_validated = models.BooleanField(null=True)
gds_exemption_validated_notes = models.TextField(max_length=NOTES_MAX_LENGTH)

ministerial_request_validated = models.BooleanField(null=True)
ministerial_request_validated_notes = models.TextField(max_length=NOTES_MAX_LENGTH)

nac_appeal_validated = models.BooleanField(null=True)
nac_appeal_validated_notes = models.TextField(max_length=NOTES_MAX_LENGTH)

history = HistoricalRecords()

0 comments on commit 4b74220

Please sign in to comment.