Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Df/update permissions max cases #34810

Merged
merged 3 commits into from
Jun 25, 2024
Merged

Conversation

dreesefadil
Copy link
Contributor

Product Description

This disables the custom max update field in the project information settings for non-developers (django users with an is_staff value of False).

Technical Summary

https://dimagi.atlassian.net/browse/SAAS-15607

Feature Flag

Safety Assurance

Safety story

I observed the local effects of this change when user.is_staff was both True and False.

Automated test coverage

QA Plan

Rollback instructions

  • This PR can be reverted after deploy with no further considerations

Labels & Review

  • Risk label is set correctly
  • The set of people pinged as reviewers is appropriate for the level of risk of the change

@dreesefadil dreesefadil requested review from gherceg and millerdev June 24, 2024 18:10
Copy link
Contributor

@millerdev millerdev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Descriptive commit messages are recommended. Otherwise, please squash the commits in this PR into a single commit to maintain a clean commit history.

Comment on lines 1170 to 1171
def __init__(self, domain, can_edit_eula, *args, **kwargs):
self.user = kwargs.pop('user', None)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Newer versions of Python have syntax for keyword-only arguments.

Suggested change
def __init__(self, domain, can_edit_eula, *args, **kwargs):
self.user = kwargs.pop('user', None)
def __init__(self, domain, can_edit_eula, *args, user=None, **kwargs):
self.user = user

@@ -1266,6 +1267,13 @@ def __init__(self, domain, can_edit_eula, *args, **kwargs):
),
)

if not self.user.is_staff:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible for self.user to be None? If yes, this will throw AttributeError. If not, the user arg in the constructor could be changed to a required keyword-only argument:

def __init__(self, domain, can_edit_eula, *args, user, **kwargs):

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not possible for self.user to be None since the dispatch in EditInternalDomainInfoView has the login_and_domain_required decorator.

@dreesefadil dreesefadil force-pushed the df/update_permissions_max_cases branch from eab75f2 to 5397f58 Compare June 24, 2024 19:45
@dreesefadil dreesefadil requested a review from millerdev June 24, 2024 20:38
Comment on lines 100 to 101
return DomainInternalForm(self.request.domain, can_edit_eula, self.request.user,
self.request.POST)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think user still has to be passed as a keyword argument, and as is it will raise TypeError.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry about that

@dreesefadil dreesefadil requested a review from millerdev June 25, 2024 12:41
@dreesefadil dreesefadil merged commit acd1658 into master Jun 25, 2024
13 checks passed
@dreesefadil dreesefadil deleted the df/update_permissions_max_cases branch June 25, 2024 18:14
@dreesefadil dreesefadil restored the df/update_permissions_max_cases branch July 2, 2024 12:03
@dreesefadil dreesefadil deleted the df/update_permissions_max_cases branch July 11, 2024 18:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants