Skip to content

Commit

Permalink
adding groups
Browse files Browse the repository at this point in the history
  • Loading branch information
chris-pettinga committed Dec 19, 2024
1 parent 37cd6b3 commit b4c9a27
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions trade_remedies_caseworker/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
from trade_remedies_client.exceptions import APIException
from core.base import GroupRequiredMixin
from core.utils import validate_required_fields, pluck, get
from core.constants import SECURITY_GROUP_TRA_ADMINISTRATOR, SECURITY_GROUPS_TRA_ADMINS

from core.constants import SECURITY_GROUP_TRA_ADMINISTRATOR, SECURITY_GROUPS_TRA_ADMINS, SECURITY_GROUPS_TRA

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -123,14 +122,10 @@ def get(self, request, *args, **kwargs):
)


class CustomDeleteUserView(UserBaseTemplateView):
class CustomDeleteUserView(UserBaseTemplateView, GroupRequiredMixin):
groups_required = SECURITY_GROUPS_TRA
template_name = "settings/custom_delete_user.html"

def dispatch(self, request, *args, **kwargs):
if request.user.tra:
return super().dispatch(request, *args, **kwargs)
return HttpResponseForbidden()

def post(self, request, *args, **kwargs):
client = self.client(request.user)
client.delete_user(user_id=kwargs["user_id"])
Expand Down

0 comments on commit b4c9a27

Please sign in to comment.