mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-25 10:33:50 +02:00
updated tests, updated waffle_flag decorator to replace has_permission
This commit is contained in:
parent
164abe06aa
commit
a90b124b93
3 changed files with 86 additions and 36 deletions
|
@ -12,11 +12,10 @@ from registrar.models import (
|
|||
Contact,
|
||||
)
|
||||
from registrar.views.utility.permission_views import UserProfilePermissionView
|
||||
from waffle.decorators import flag_is_active
|
||||
from waffle.decorators import flag_is_active, waffle_flag
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class UserProfileView(UserProfilePermissionView, FormMixin):
|
||||
"""
|
||||
Base View for the User Profile. Handles getting and setting the User Profile
|
||||
|
@ -34,6 +33,10 @@ class UserProfileView(UserProfilePermissionView, FormMixin):
|
|||
context = self.get_context_data(object=self.object, form=form)
|
||||
return self.render_to_response(context)
|
||||
|
||||
@waffle_flag("profile_feature")
|
||||
def dispatch(self, request, *args, **kwargs):
|
||||
return super().dispatch(request, *args, **kwargs)
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
"""Extend get_context_data to include has_profile_feature_flag"""
|
||||
context = super().get_context_data(**kwargs)
|
||||
|
@ -70,14 +73,3 @@ class UserProfileView(UserProfilePermissionView, FormMixin):
|
|||
if hasattr(user, "contact"): # Check if the user has a contact instance
|
||||
return user.contact
|
||||
return None
|
||||
|
||||
def has_permission(self):
|
||||
"""Check if this user has permission to see this view.
|
||||
|
||||
In addition to permissions for the user, check that the profile_feature waffle flag
|
||||
is not turned on.
|
||||
"""
|
||||
if not flag_is_active(self.request, "profile_feature"):
|
||||
return False
|
||||
|
||||
return super().has_permission()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue