mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-19 02:49:21 +02:00
formatted for linter
This commit is contained in:
parent
fef606c1dc
commit
bbceee1dc0
6 changed files with 13 additions and 15 deletions
|
@ -6,6 +6,7 @@ from django.core.validators import MaxLengthValidator
|
|||
from phonenumber_field.widgets import RegionalPhoneNumberWidget
|
||||
from registrar.models.utility.domain_helper import DomainHelper
|
||||
|
||||
|
||||
class UserProfileForm(forms.ModelForm):
|
||||
"""Form for updating user profile."""
|
||||
|
||||
|
@ -20,7 +21,7 @@ class UserProfileForm(forms.ModelForm):
|
|||
"email": forms.EmailInput,
|
||||
"phone": RegionalPhoneNumberWidget,
|
||||
}
|
||||
|
||||
|
||||
# the database fields have blank=True so ModelForm doesn't create
|
||||
# required fields by default. Use this list in __init__ to mark each
|
||||
# of these fields as required
|
||||
|
@ -54,7 +55,6 @@ class UserProfileForm(forms.ModelForm):
|
|||
"required": "Enter your email address in the required format, like name@example.com."
|
||||
}
|
||||
self.fields["phone"].error_messages["required"] = "Enter your phone number."
|
||||
self.domainInfo = None
|
||||
self.domainInfo = None
|
||||
|
||||
DomainHelper.disable_field(self.fields["email"], disable_required=True)
|
||||
|
|
@ -595,7 +595,7 @@ class DomainYourContactInformationView(DomainFormBaseView):
|
|||
|
||||
# superclass has the redirect
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
def has_permission(self):
|
||||
"""Check if this user has permission to see this view.
|
||||
|
||||
|
@ -604,7 +604,7 @@ class DomainYourContactInformationView(DomainFormBaseView):
|
|||
"""
|
||||
if flag_is_active(self.request, "profile_feature"):
|
||||
return False
|
||||
|
||||
|
||||
return super().has_permission()
|
||||
|
||||
|
||||
|
|
|
@ -394,7 +394,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
|||
"is_federal": self.domain_request.is_federal(),
|
||||
"modal_button": modal_button,
|
||||
"modal_heading": modal_heading,
|
||||
"has_profile_feature_flag": flag_is_active(self.request, "profile_feature")
|
||||
"has_profile_feature_flag": flag_is_active(self.request, "profile_feature"),
|
||||
}
|
||||
|
||||
def get_step_list(self) -> list:
|
||||
|
|
|
@ -9,7 +9,6 @@ from django.views.generic.edit import FormMixin
|
|||
from registrar.forms.user_profile import UserProfileForm
|
||||
from django.urls import reverse
|
||||
from registrar.models import (
|
||||
User,
|
||||
Contact,
|
||||
)
|
||||
from registrar.views.utility.permission_views import UserProfilePermissionView
|
||||
|
@ -34,7 +33,7 @@ class UserProfileView(UserProfilePermissionView, FormMixin):
|
|||
form = self.form_class(instance=self.object)
|
||||
context = self.get_context_data(object=self.object, form=form)
|
||||
return self.render_to_response(context)
|
||||
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Extend get_context_data to include has_profile_feature_flag"""
|
||||
self.get()
|
||||
|
@ -42,7 +41,7 @@ class UserProfileView(UserProfilePermissionView, FormMixin):
|
|||
# This is a django waffle flag which toggles features based off of the "flag" table
|
||||
context["has_profile_feature_flag"] = flag_is_active(self.request, "profile_feature")
|
||||
return context
|
||||
|
||||
|
||||
def get_success_url(self):
|
||||
"""Redirect to the user's profile page."""
|
||||
return reverse("user-profile")
|
||||
|
@ -65,10 +64,10 @@ class UserProfileView(UserProfilePermissionView, FormMixin):
|
|||
|
||||
# superclass has the redirect
|
||||
return super().form_valid(form)
|
||||
|
||||
|
||||
def get_object(self, queryset=None):
|
||||
"""Override get_object to return the logged-in user's contact"""
|
||||
user = self.request.user # get the logged in user
|
||||
if hasattr(user, 'contact'): # Check if the user has a contact instance
|
||||
if hasattr(user, "contact"): # Check if the user has a contact instance
|
||||
return user.contact
|
||||
return None
|
||||
return None
|
||||
|
|
|
@ -382,7 +382,7 @@ class DomainInvitationPermission(PermissionsLoginMixin):
|
|||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
|
||||
class UserProfilePermission(PermissionsLoginMixin):
|
||||
"""Permission mixin that redirects to user profile if user
|
||||
|
|
|
@ -2,9 +2,8 @@
|
|||
|
||||
import abc # abstract base class
|
||||
|
||||
from django.contrib.auth import get_user_model
|
||||
from django.views.generic import DetailView, DeleteView, TemplateView
|
||||
from registrar.models import Domain, DomainRequest, DomainInvitation, User
|
||||
from registrar.models import Domain, DomainRequest, DomainInvitation
|
||||
from registrar.models.contact import Contact
|
||||
from registrar.models.user_domain_role import UserDomainRole
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue