mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-06 19:23:23 +02:00
Fix linting errors
This commit is contained in:
parent
e4233870d6
commit
63979afe32
3 changed files with 14 additions and 6 deletions
|
@ -3,7 +3,7 @@
|
|||
import logging
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.db import models, IntegrityError
|
||||
from django.db import models
|
||||
|
||||
from django_fsm import FSMField, transition # type: ignore
|
||||
|
||||
|
@ -63,12 +63,16 @@ class DomainInvitation(TimeStampedModel):
|
|||
|
||||
# and create a role for that user on this domain
|
||||
try:
|
||||
role = UserDomainRole.objects.get(
|
||||
UserDomainRole.objects.get(
|
||||
user=user, domain=self.domain, role=UserDomainRole.Roles.ADMIN
|
||||
)
|
||||
except UserDomainRole.DoesNotExist:
|
||||
UserDomainRole.objects.create(user=user, domain=self.domain, role=UserDomainRole.Roles.ADMIN)
|
||||
UserDomainRole.objects.create(
|
||||
user=user, domain=self.domain, role=UserDomainRole.Roles.ADMIN
|
||||
)
|
||||
else:
|
||||
# something strange happened and this role already existed when
|
||||
# the invitation was retrieved. Log that this occurred.
|
||||
logger.warn("Invitation %s was retrieved for a role that already exists.", self)
|
||||
logger.warn(
|
||||
"Invitation %s was retrieved for a role that already exists.", self
|
||||
)
|
||||
|
|
|
@ -55,4 +55,6 @@ class User(AbstractUser):
|
|||
# retrieving should not fail because of a missing user, but
|
||||
# if it does fail, log the error so a new user can continue
|
||||
# logging in
|
||||
logger.warn("Failed to retrieve invitation %s", invitation, exc_info=True)
|
||||
logger.warn(
|
||||
"Failed to retrieve invitation %s", invitation, exc_info=True
|
||||
)
|
||||
|
|
|
@ -192,7 +192,9 @@ class TestInvitations(TestCase):
|
|||
|
||||
def test_retrieve_existing_role_no_error(self):
|
||||
# make the overlapping role
|
||||
UserDomainRole.objects.get_or_create(user=self.user, domain=self.domain, role=UserDomainRole.Roles.ADMIN)
|
||||
UserDomainRole.objects.get_or_create(
|
||||
user=self.user, domain=self.domain, role=UserDomainRole.Roles.ADMIN
|
||||
)
|
||||
# this is not an error but does produce a console warning
|
||||
with less_console_noise():
|
||||
self.invitation.retrieve()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue