Exemplo n.º 1
0
    def form_valid(self, form):
        success = leave_non_owned_map_group(self.request.user, self.mapgroup)
        if not success:
            # Then we weren't able to leave the group, probably because we
            # own it or are a member
            pass

        return super(LeaveMapGroupActionView, self).form_valid(form)
Exemplo n.º 2
0
    def test_leave_group(self):
        user = self.users['usr2']
        group = self.group
        result = join_map_group(user, group)
        self.assertIsInstance(result, MapGroupMember)

        self.assertTrue(group.has_member(user))
        self.assertTrue(group.permission_group.user_set.filter(pk=user.pk).exists())

        result = leave_non_owned_map_group(user, group)

        self.assertTrue(result)
        self.assertFalse(group.has_member(user))
        self.assertFalse(group.permission_group.user_set.filter(pk=user.pk).exists())