Add ineligible status on domain application, on user. Trigger fsm transition on domain application which triggers status ineligible on user. Edit permissions on domains and newly created application wizard perm class to block access to ineligible users. Run migrations.

This commit is contained in:
rachidatecs 2023-08-18 17:24:34 -04:00
parent 87bb71a214
commit c98392baac
No known key found for this signature in database
GPG key ID: 3CEBBFA7325E5525
9 changed files with 236 additions and 7 deletions

View file

@ -16,6 +16,20 @@ class User(AbstractUser):
A custom user model that performs identically to the default user model
but can be customized later.
"""
# #### Constants for choice fields ####
INELIGIBLE = 'ineligible'
STATUS_CHOICES = (
(INELIGIBLE, INELIGIBLE),
)
status = models.CharField(
max_length=10,
choices=STATUS_CHOICES,
default=None, # Set the default value to None
null=True, # Allow the field to be null
blank=True, # Allow the field to be blank
)
domains = models.ManyToManyField(
"registrar.Domain",
@ -38,6 +52,19 @@ class User(AbstractUser):
return self.email
else:
return self.username
def block_user(self):
self.status = "ineligible"
self.save()
def unblock_user(self):
self.status = None
self.save()
def is_blocked(self):
if self.status == "ineligible":
return True
return False
def first_login(self):
"""Callback when the user is authenticated for the very first time.