Skip to content

Commit

Permalink
disabled custom max update field for non-admins
Browse files Browse the repository at this point in the history
  • Loading branch information
dfadil committed Jun 24, 2024
1 parent 74e7370 commit 5397f58
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
8 changes: 8 additions & 0 deletions corehq/apps/domain/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1168,6 +1168,7 @@ class DomainInternalForm(forms.Form, SubAreaMixin):
)

def __init__(self, domain, can_edit_eula, *args, **kwargs):
self.user = kwargs.pop('user', None)
super(DomainInternalForm, self).__init__(*args, **kwargs)
self.domain = domain
self.can_edit_eula = can_edit_eula
Expand Down Expand Up @@ -1266,6 +1267,13 @@ def __init__(self, domain, can_edit_eula, *args, **kwargs):
),
)

if not self.user.is_staff:
self.fields['auto_case_update_limit'].disabled = True
self.fields['auto_case_update_limit'].help_text = (
'Case update rule limits are only modifiable by Dimagi admins. '
'Please reach out to support@dimagi.com if you wish to update this setting.'
)

@property
def current_values(self):
return {
Expand Down
5 changes: 3 additions & 2 deletions corehq/apps/domain/views/internal.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ def dispatch(self, request, *args, **kwargs):
def internal_settings_form(self):
can_edit_eula = toggles.CAN_EDIT_EULA.enabled(self.request.couch_user.username)
if self.request.method == 'POST':
return DomainInternalForm(self.request.domain, can_edit_eula, self.request.POST)
return DomainInternalForm(self.request.domain, can_edit_eula,
self.request.POST, user=self.request.user)
initial = {
'countries': self.domain_object.deployment.countries,
'is_test': self.domain_object.is_test,
Expand Down Expand Up @@ -150,7 +151,7 @@ def internal_settings_form(self):
initial['active_ucr_expressions'] = AllowedUCRExpressionSettings.get_allowed_ucr_expressions(
domain_name=self.domain_object.name
)
return DomainInternalForm(self.request.domain, can_edit_eula, initial=initial)
return DomainInternalForm(self.request.domain, can_edit_eula, initial=initial, user=self.request.user)

@property
def page_context(self):
Expand Down

0 comments on commit 5397f58

Please sign in to comment.