Added Person.needs_consent() which returns a list of descriptions of fields for which consent is needed, or [].

- Legacy-Id: 15258
This commit is contained in:
Henrik Levkowetz 2018-06-14 18:56:01 +00:00
parent 35e16ef7d5
commit 31352b0064

View file

@ -163,6 +163,25 @@ class Person(models.Model):
from ietf.doc.models import Document
return Document.objects.filter(documentauthor__person=self, type='draft', states__slug__in=['repl', 'expired', 'auth-rm', 'ietf-rm']).order_by('-time')
def needs_consent(self):
"""
Returns an empty list or a list of fields which holds information that
requires consent to be given.
"""
needs_consent = []
if self.name != self.name_from_draft:
needs_consent.append("full name")
if self.ascii != self.name_from_draft:
needs_consent.append("ascii name")
if self.biography and self.role_set.count():
needs_consent.append("biography")
if self.user and self.user.communitylist_set.exists():
needs_consent.append("draft notification subscription(s)")
for email in self.email_set.all():
if not email.origin.split(':')[0] in ['author', 'role', 'reviewer', 'liaison', 'shepherd', ]:
needs_consent.append("email address(es)")
return needs_consent
def save(self, *args, **kwargs):
created = not self.pk
super(Person, self).save(*args, **kwargs)