Skip to content
Snippets Groups Projects
Commit 2ed3676b authored by Andreas Ellewsen's avatar Andreas Ellewsen
Browse files

Merge branch 'feature/hasconsented' into 'master'

Feature/hasconsented

See merge request !43
parents c81c14ca 771923ef
No related branches found
No related tags found
1 merge request!43Feature/hasconsented
Pipeline #92467 passed
......@@ -79,7 +79,13 @@ class ConsentAdmin(VersionAdmin):
class ConsentTypeAdmin(admin.ModelAdmin):
list_display = ("id", "name_en", "valid_from", "user_allowed_to_change")
list_display = (
"id",
"name_en",
"valid_from",
"user_allowed_to_change",
"mandatory",
)
readonly_fields = ("id", "created", "updated")
......
# Generated by Django 3.2.7 on 2021-09-03 10:59
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('greg', '0002_identity'),
]
operations = [
migrations.AddField(
model_name='consenttype',
name='mandatory',
field=models.BooleanField(default=False),
),
]
......@@ -113,6 +113,20 @@ class Person(BaseModel):
>= 1
)
@property
def has_mandatory_consents(self) -> bool:
"""
A person that has mandatory consents is a person whom has given consent
to all mandatory consent types known to greg.
"""
person_consents = sorted(
i.type.name_en for i in self.consents.filter(consent_given_at__isnull=False)
)
mandatory_consents = sorted(
i.name_en for i in ConsentType.objects.filter(mandatory=True)
)
return person_consents == mandatory_consents
class RoleType(BaseModel):
"""A role variant."""
......@@ -247,6 +261,7 @@ class ConsentType(BaseModel):
link_nb = models.URLField(null=True)
valid_from = models.DateField(default=date.today)
user_allowed_to_change = models.BooleanField()
mandatory = models.BooleanField(default=False)
def __str__(self):
return "{} ({})".format(str(self.name_en or self.name_nb), self.identifier)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment