-
-
Save SmileyChris/7205e645237df5632a183b6bdff2c26a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def user_in_group(user, group_id=None, group_id_list=None): | |
if group_id_list is None: | |
group_id_list = set(group_id] | |
if not hasattr(user, 'group_ids'): | |
user.group_ids = set(user.groups.values_list('pk', flat=True)) | |
return user.group_ids.intersection(group_id_list) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment