예제 #1
0
 def test_get_groups(self):
     """Test getting groups according to community name"""
     groups = get_groups("Foo")
     self.assertSequenceEqual(groups, [])
     name = "Bar"
     create_groups(name)
     community_groups = Group.objects.all()
     groups = get_groups("Bar")
     self.assertCountEqual(community_groups, groups)
     create_groups("New")
     groups = get_groups("Bar")
     self.assertCountEqual(community_groups, groups)
예제 #2
0
파일: models.py 프로젝트: yashp03/portal
    def leave_groups(self, community_name):
        """Leave all groups that are related to a community.

        :param community: string name of Community
        """
        groups = get_groups(community_name)
        for group in groups:
            self.leave_group(group)
예제 #3
0
    def leave_groups(self, community_name):
        """Leave all groups that are related to a community.

        :param community: string name of Community
        """
        groups = get_groups(community_name)
        for group in groups:
            self.leave_group(group)
예제 #4
0
파일: forms.py 프로젝트: systers/portal
    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop('user')
        community = kwargs.pop('community')
        super(PermissionGroupsForm, self).__init__(*args, **kwargs)

        # get all community groups and remove community admin group
        # from the list of choices
        self.groups = list(get_groups(community.name))
        admin_group = Group.objects.get(
            name=COMMUNITY_ADMIN.format(community.name))
        self.groups.remove(admin_group)
        choices = [(group.pk, group.name) for group in self.groups]
        self.fields['groups'] = forms.\
            MultipleChoiceField(choices=choices, label="", required=False,
                                widget=forms.CheckboxSelectMultiple)
        self.member_groups = self.user.get_member_groups(self.groups)
        self.fields['groups'].initial = [group.pk for group in
                                         self.member_groups]

        self.helper = SubmitCancelFormHelper(
            self, cancel_href="{% url 'community_users' community.slug %}")
예제 #5
0
파일: forms.py 프로젝트: singhrash23/portal
    def __init__(self, *args, **kwargs):
        self.user = kwargs.pop('user')
        community = kwargs.pop('community')
        super(PermissionGroupsForm, self).__init__(*args, **kwargs)

        # get all community groups and remove community admin group
        # from the list of choices
        self.groups = list(get_groups(community.name))
        admin_group = Group.objects.get(
            name=COMMUNITY_ADMIN.format(community.name))
        self.groups.remove(admin_group)
        choices = [(group.pk, group.name) for group in self.groups]
        self.fields['groups'] = forms. \
            MultipleChoiceField(choices=choices, label="", required=False,
                                widget=forms.CheckboxSelectMultiple)
        self.member_groups = self.user.get_member_groups(self.groups)
        self.fields['groups'].initial = [
            group.pk for group in self.member_groups
        ]

        self.helper = SubmitCancelFormHelper(
            self, cancel_href="{% url 'community_users' community.slug %}")