mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-07-21 18:25:58 +02:00
Linting
This commit is contained in:
parent
12d5905ef9
commit
f16382e946
4 changed files with 25 additions and 23 deletions
|
@ -10,6 +10,7 @@ from django.contrib import messages
|
|||
|
||||
from registrar.forms import application_wizard as forms
|
||||
from registrar.models import DomainApplication
|
||||
from registrar.models.user import User
|
||||
from registrar.utility import StrEnum
|
||||
from registrar.views.utility import StepsHelper
|
||||
|
||||
|
@ -131,11 +132,19 @@ class ApplicationWizard(ApplicationWizardPermissionView, TemplateView):
|
|||
if self._application:
|
||||
return self._application
|
||||
|
||||
# For linter. The else block should never be hit, but if it does,
|
||||
# there may be a UI consideration. That will need to be handled in another ticket.
|
||||
creator = None
|
||||
if self.request.user is not None and isinstance(self.request.user, User):
|
||||
creator = self.request.user
|
||||
else:
|
||||
raise ValueError("Invalid value for User")
|
||||
|
||||
if self.has_pk():
|
||||
id = self.storage["application_id"]
|
||||
try:
|
||||
self._application = DomainApplication.objects.get(
|
||||
creator=self.request.user, # type: ignore
|
||||
creator=creator,
|
||||
pk=id,
|
||||
)
|
||||
return self._application
|
||||
|
@ -476,6 +485,7 @@ class DotgovDomain(ApplicationWizard):
|
|||
self.application.save()
|
||||
return response
|
||||
|
||||
|
||||
class Purpose(ApplicationWizard):
|
||||
template_name = "application_purpose.html"
|
||||
forms = [forms.PurposeForm]
|
||||
|
|
|
@ -34,7 +34,7 @@ from registrar.utility.errors import (
|
|||
SecurityEmailErrorCodes,
|
||||
)
|
||||
from registrar.models.utility.contact_error import ContactError
|
||||
from registrar.views.utility.permission_views import UserDomainRolePermissionDeleteView, UserDomainRolePermissionView
|
||||
from registrar.views.utility.permission_views import UserDomainRolePermissionDeleteView
|
||||
|
||||
from ..forms import (
|
||||
ContactForm,
|
||||
|
@ -643,7 +643,6 @@ class DomainUsersView(DomainBaseView):
|
|||
return context
|
||||
|
||||
def _add_booleans_to_context(self, context):
|
||||
|
||||
# Determine if the current user can delete managers
|
||||
domain_pk = None
|
||||
can_delete_users = False
|
||||
|
@ -660,17 +659,17 @@ class DomainUsersView(DomainBaseView):
|
|||
"""Adds modal buttons (and their HTML) to the context"""
|
||||
# Create HTML for the modal button
|
||||
modal_button = self._create_modal_button_html(
|
||||
button_name="delete_domain_manager",
|
||||
button_name="delete_domain_manager",
|
||||
button_text_content="Yes, remove domain manager",
|
||||
classes=["usa-button", "usa-button--secondary"]
|
||||
classes=["usa-button", "usa-button--secondary"],
|
||||
)
|
||||
context["modal_button"] = modal_button
|
||||
|
||||
# Create HTML for the modal button when deleting yourself
|
||||
modal_button_self= self._create_modal_button_html(
|
||||
modal_button_self = self._create_modal_button_html(
|
||||
button_name="delete_domain_manager_self",
|
||||
button_text_content="Yes, remove myself",
|
||||
classes=["usa-button", "usa-button--secondary"]
|
||||
classes=["usa-button", "usa-button--secondary"],
|
||||
)
|
||||
context["modal_button_self"] = modal_button_self
|
||||
|
||||
|
@ -686,11 +685,7 @@ class DomainUsersView(DomainBaseView):
|
|||
|
||||
html_class = f'class="{class_list}"' if class_list else None
|
||||
|
||||
modal_button = (
|
||||
'<button type="submit" '
|
||||
f"{html_class} "
|
||||
f'name="{button_name}">{button_text_content}</button>'
|
||||
)
|
||||
modal_button = '<button type="submit" ' f"{html_class} " f'name="{button_name}">{button_text_content}</button>'
|
||||
return modal_button
|
||||
|
||||
|
||||
|
@ -809,8 +804,8 @@ class DomainInvitationDeleteView(DomainInvitationPermissionDeleteView, SuccessMe
|
|||
|
||||
|
||||
class DomainDeleteUserView(UserDomainRolePermissionDeleteView):
|
||||
"""Inside of a domain's user management, a form for deleting users.
|
||||
"""
|
||||
"""Inside of a domain's user management, a form for deleting users."""
|
||||
|
||||
object: UserDomainRole # workaround for type mismatch in DeleteView
|
||||
|
||||
def get_object(self, queryset=None):
|
||||
|
@ -823,8 +818,8 @@ class DomainDeleteUserView(UserDomainRolePermissionDeleteView):
|
|||
"""Refreshes the page after a delete is successful"""
|
||||
return reverse("domain-users", kwargs={"pk": self.object.domain.id})
|
||||
|
||||
def get_success_message(self, delete_self = False):
|
||||
"""Returns confirmation content for the deletion event """
|
||||
def get_success_message(self, delete_self=False):
|
||||
"""Returns confirmation content for the deletion event"""
|
||||
|
||||
# Grab the text representation of the user we want to delete
|
||||
email_or_name = self.object.user.email
|
||||
|
@ -860,5 +855,5 @@ class DomainDeleteUserView(UserDomainRolePermissionDeleteView):
|
|||
delete_self = self.request.user == self.object.user
|
||||
if delete_self:
|
||||
return redirect(reverse("home"))
|
||||
|
||||
return response
|
||||
|
||||
return response
|
||||
|
|
|
@ -307,7 +307,7 @@ class UserDomainRolePermission(PermissionsLoginMixin):
|
|||
# Check if the UserDomainRole object exists, then check
|
||||
# if the user requesting the delete has permissions to do so
|
||||
has_delete_permission = UserDomainRole.objects.filter(
|
||||
user=user_pk,
|
||||
user=user_pk,
|
||||
domain=domain_pk,
|
||||
domain__permissions__user=self.request.user,
|
||||
).exists()
|
||||
|
@ -316,9 +316,7 @@ class UserDomainRolePermission(PermissionsLoginMixin):
|
|||
|
||||
# Check if more than one manager exists on the domain.
|
||||
# If only one exists, prevent this from happening
|
||||
has_multiple_managers = len(UserDomainRole.objects.filter(
|
||||
domain=domain_pk
|
||||
)) > 1
|
||||
has_multiple_managers = len(UserDomainRole.objects.filter(domain=domain_pk)) > 1
|
||||
if not has_multiple_managers:
|
||||
return False
|
||||
|
||||
|
|
|
@ -152,4 +152,3 @@ class UserDomainRolePermissionDeleteView(UserDomainRolePermissionView, DeleteVie
|
|||
model = UserDomainRole
|
||||
# variable name in template context for the model object
|
||||
context_object_name = "userdomainrole"
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue