Skip to content

Commit

Permalink
Merge pull request #34810 from dimagi/df/update_permissions_max_cases
Browse files Browse the repository at this point in the history
Df/update permissions max cases
  • Loading branch information
dreesefadil authored Jun 25, 2024
2 parents 7cc0f27 + 07c8c3a commit acd1658
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
10 changes: 9 additions & 1 deletion corehq/apps/domain/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1167,7 +1167,8 @@ class DomainInternalForm(forms.Form, SubAreaMixin):
required=False,
)

def __init__(self, domain, can_edit_eula, *args, **kwargs):
def __init__(self, domain, can_edit_eula, *args, user, **kwargs):
self.user = user
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 [email protected] 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 acd1658

Please sign in to comment.