mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-15 22:14:15 +02:00
pt. 1 of test refactors
This commit is contained in:
parent
f587a994f2
commit
432ee9c860
11 changed files with 100 additions and 132 deletions
|
@ -208,17 +208,6 @@ class User(AbstractUser):
|
|||
def has_contact_info(self):
|
||||
return bool(self.title or self.email or self.phone)
|
||||
|
||||
def clean(self):
|
||||
"""Extends clean method to perform additional validation, which can raise errors in django admin."""
|
||||
super().clean()
|
||||
|
||||
portfolio_perm = self.portfolio_permissions.filter(portfolio=self.last_selected_portfolio, user=self).first()
|
||||
if self.last_selected_portfolio is None and portfolio_perm._get_portfolio_permissions():
|
||||
raise ValidationError("When portfolio roles or additional permissions are assigned, portfolio is required.")
|
||||
|
||||
if self.last_selected_portfolio is not None and not portfolio_perm._get_portfolio_permissions():
|
||||
raise ValidationError("When portfolio is assigned, portfolio roles or additional permissions are required.")
|
||||
|
||||
def _has_portfolio_permission(self, portfolio_permission):
|
||||
"""The views should only call this function when testing for perms and not rely on roles."""
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue