1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
from django.db import models
from engagements.models import EngagementEffort, Organisation
from myuser.models import TeamUser
class Common(models.Model):
date_created = models.DateTimeField(auto_now_add=True)
last_modified = models.DateTimeField(auto_now=True)
class Meta:
abstract = True
class SOP(Common):
draft_status = [
("Draft", "Draft"),
("Final", "Final"),
("Published", "Published"),
("To be reviewed", "To be reviewed"),
]
name = models.CharField(max_length=512, null=False, blank=False)
designation = models.CharField(max_length=5, null=False, blank=False)
# sp_link is for Sharepoint so the max length has to be massive
sp_link = models.URLField(max_length=1000, null=True, blank=True)
draft_status = models.CharField(max_length=20, choices=draft_status, null=False, blank=False)
author_lead = models.ForeignKey(
TeamUser,
on_delete=models.CASCADE,
)
def __str__(self):
return self.name
class Meta:
verbose_name = "SOP"
class Instrument(Common):
"JSP 628, JSP 440, the ONR ones, etc"
name = models.CharField(max_length=512, null=False, blank=False)
long_title = models.CharField(max_length=1024, null=True, blank=True)
designator = models.CharField(max_length=3, null=True, blank=True)
owner = models.ForeignKey(Organisation, null=False, blank=False, on_delete=models.CASCADE)
link = models.URLField(max_length=1024, null=True, blank=True)
def __str__(self):
return self.name
class Meta:
verbose_name_plural = "Instruments"
class SubInstrument(Common):
"DSCs, Chapters, Supplements, Leaflets..."
choices = (
("DSC", "Defence Security Condition (DSC)"),
("DSYAP", "Defence Security Assessment Principle (DSyAP)"),
("DSTAIG", "Defence Security Testing And I Don't Know (DSTAIG)"),
)
is_guidance = models.BooleanField(null=True, blank=True, default=False)
itype = models.CharField(choices=choices, max_length=6, verbose_name="Instrument Type")
title = models.CharField(max_length=512, null=False, blank=False)
parent = models.ForeignKey(Instrument, on_delete=models.CASCADE, verbose_name="Parent Instrument")
description = models.TextField(null=True, blank=True)
rationale = models.TextField(null=True, blank=True)
relative = models.ManyToManyField("self", blank=True)
short = models.CharField(max_length=10, null=True, blank=True)
def effort(self):
return EngagementEffort.objects.filter(sub_instruments__contains=self)
def effort_for_org(self, org):
eff = EngagementEffort.objects.filter(engagement__external_party=org).filter(effort_type="REGULATION")
return sum(e.effort_total_hours() for e in eff)
def __str__(self):
return self.title
class Meta:
verbose_name_plural = "Sub Instruments"
|