Skip to content

fix: replacing access_types with access_tags adding transactions, removing direct celery calls#79

Merged
Kartikkumar-Shetty merged 25 commits into
mainfrom
fixes-and-refactor
Feb 22, 2023
Merged

fix: replacing access_types with access_tags adding transactions, removing direct celery calls#79
Kartikkumar-Shetty merged 25 commits into
mainfrom
fixes-and-refactor

Conversation

@Kartikkumar-Shetty
Copy link
Copy Markdown
Contributor

@Kartikkumar-Shetty Kartikkumar-Shetty commented Feb 21, 2023

Fixing the instances where access types is used instead of access tags
refactoring the code to user auth_user to improve code readability
Adding transactions for the add a user to a group
refactoring the code, the request will be moved to processing by the calling function instead accept_request.
removing instances where the celery methods are called directly.

Adding a new grant and revoke method, adding transactions scope for offboarding
… unrequired params, using the new method for access grant
…calls, adding error messages, replacing access type with access tag
@Kartikkumar-Shetty Kartikkumar-Shetty changed the title Fixes and refactor fix: replacing access_types with access_tags adding transactions, removing direct celery calls Feb 21, 2023
vedharish
vedharish previously approved these changes Feb 21, 2023
Comment thread Access/models.py Outdated

def change_state(self, final_state):
user_states = dict(USER_STATUS_CHOICES)
user_states = dict(self. USER_STATUS_CHOICES)
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

need to run linter on this file

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

yeah, will run after first round of reviews are done

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread Access/group_helper.py Outdated
)
new_memberships.append(member)
user_not_added.append(user.email)
if not group.needsAccessApprove:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

should it be "if group.needsAccessApprove:"?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread Access/group_helper.py
user_not_added = []
for user in selected_users:
try:
with transaction.atomic():
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

shouldn't this transaction be for the loop because even if one user failed to add then revert?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

no because the transaction will remain open for too long if we do it for all users. Since for every user we are also adding access

Comment thread Access/models.py Outdated
group_members = self.membership_group.all()
return group_members

def get_all_approved_members(self):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

redundant method?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

fixed, removed

Comment thread Access/group_helper.py Outdated
}
),
)
revoke_request(user_access_mapping = access, revoker = request.user.user)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

here access is an object of AccessV2, but no issues I have fixed it in my "revoke access to group" PR

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.

4 participants