mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-05-18 18:39: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 phonenumber_field.widgets import RegionalPhoneNumberWidget
|
||||||
from registrar.models.utility.domain_helper import DomainHelper
|
from registrar.models.utility.domain_helper import DomainHelper
|
||||||
|
|
||||||
|
|
||||||
class UserProfileForm(forms.ModelForm):
|
class UserProfileForm(forms.ModelForm):
|
||||||
"""Form for updating user profile."""
|
"""Form for updating user profile."""
|
||||||
|
|
||||||
|
@ -20,7 +21,7 @@ class UserProfileForm(forms.ModelForm):
|
||||||
"email": forms.EmailInput,
|
"email": forms.EmailInput,
|
||||||
"phone": RegionalPhoneNumberWidget,
|
"phone": RegionalPhoneNumberWidget,
|
||||||
}
|
}
|
||||||
|
|
||||||
# the database fields have blank=True so ModelForm doesn't create
|
# the database fields have blank=True so ModelForm doesn't create
|
||||||
# required fields by default. Use this list in __init__ to mark each
|
# required fields by default. Use this list in __init__ to mark each
|
||||||
# of these fields as required
|
# 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."
|
"required": "Enter your email address in the required format, like name@example.com."
|
||||||
}
|
}
|
||||||
self.fields["phone"].error_messages["required"] = "Enter your phone number."
|
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)
|
DomainHelper.disable_field(self.fields["email"], disable_required=True)
|
||||||
|
|
|
@ -595,7 +595,7 @@ class DomainYourContactInformationView(DomainFormBaseView):
|
||||||
|
|
||||||
# superclass has the redirect
|
# superclass has the redirect
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
def has_permission(self):
|
def has_permission(self):
|
||||||
"""Check if this user has permission to see this view.
|
"""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"):
|
if flag_is_active(self.request, "profile_feature"):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return super().has_permission()
|
return super().has_permission()
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -394,7 +394,7 @@ class DomainRequestWizard(DomainRequestWizardPermissionView, TemplateView):
|
||||||
"is_federal": self.domain_request.is_federal(),
|
"is_federal": self.domain_request.is_federal(),
|
||||||
"modal_button": modal_button,
|
"modal_button": modal_button,
|
||||||
"modal_heading": modal_heading,
|
"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:
|
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 registrar.forms.user_profile import UserProfileForm
|
||||||
from django.urls import reverse
|
from django.urls import reverse
|
||||||
from registrar.models import (
|
from registrar.models import (
|
||||||
User,
|
|
||||||
Contact,
|
Contact,
|
||||||
)
|
)
|
||||||
from registrar.views.utility.permission_views import UserProfilePermissionView
|
from registrar.views.utility.permission_views import UserProfilePermissionView
|
||||||
|
@ -34,7 +33,7 @@ class UserProfileView(UserProfilePermissionView, FormMixin):
|
||||||
form = self.form_class(instance=self.object)
|
form = self.form_class(instance=self.object)
|
||||||
context = self.get_context_data(object=self.object, form=form)
|
context = self.get_context_data(object=self.object, form=form)
|
||||||
return self.render_to_response(context)
|
return self.render_to_response(context)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
"""Extend get_context_data to include has_profile_feature_flag"""
|
"""Extend get_context_data to include has_profile_feature_flag"""
|
||||||
self.get()
|
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
|
# 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")
|
context["has_profile_feature_flag"] = flag_is_active(self.request, "profile_feature")
|
||||||
return context
|
return context
|
||||||
|
|
||||||
def get_success_url(self):
|
def get_success_url(self):
|
||||||
"""Redirect to the user's profile page."""
|
"""Redirect to the user's profile page."""
|
||||||
return reverse("user-profile")
|
return reverse("user-profile")
|
||||||
|
@ -65,10 +64,10 @@ class UserProfileView(UserProfilePermissionView, FormMixin):
|
||||||
|
|
||||||
# superclass has the redirect
|
# superclass has the redirect
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
def get_object(self, queryset=None):
|
def get_object(self, queryset=None):
|
||||||
"""Override get_object to return the logged-in user's contact"""
|
"""Override get_object to return the logged-in user's contact"""
|
||||||
user = self.request.user # get the logged in user
|
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 user.contact
|
||||||
return None
|
return None
|
||||||
|
|
|
@ -382,7 +382,7 @@ class DomainInvitationPermission(PermissionsLoginMixin):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
class UserProfilePermission(PermissionsLoginMixin):
|
class UserProfilePermission(PermissionsLoginMixin):
|
||||||
"""Permission mixin that redirects to user profile if user
|
"""Permission mixin that redirects to user profile if user
|
||||||
|
|
|
@ -2,9 +2,8 @@
|
||||||
|
|
||||||
import abc # abstract base class
|
import abc # abstract base class
|
||||||
|
|
||||||
from django.contrib.auth import get_user_model
|
|
||||||
from django.views.generic import DetailView, DeleteView, TemplateView
|
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.contact import Contact
|
||||||
from registrar.models.user_domain_role import UserDomainRole
|
from registrar.models.user_domain_role import UserDomainRole
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue