Exemplo n.º 1
0
 def make_donor(self):
     """Take away all the user's permissions."""
     self.user.is_staff = False
     self.user.is_superuser = False
     self.user.groups.remove(get_group_by_name(self.ADMIN_GROUP))
     self.user.groups.remove(get_group_by_name(self.AMBASSADOR_GROUP))
     self.user.save()
Exemplo n.º 2
0
 def make_donor(self):
     """Take away all the user's permissions."""
     self.user.is_staff = False
     self.user.is_superuser = False
     self.user.groups.remove(get_group_by_name(self.ADMIN_GROUP))
     self.user.groups.remove(get_group_by_name(self.AMBASSADOR_GROUP))
     self.user.save()
Exemplo n.º 3
0
    def _assert_group_relationship(self, user, group_name, rel_in):
        """Assert that a user is or is not in a given group.

        :user: {User} the user to check
        :group_name: {string} the group name to check
        :rel_in: {boolean} if true, assert that the user is IN the group.
                 otherwise, assert that the user is NOT in the group
        """
        group = get_group_by_name(group_name)
        if rel_in:
            self.assertIn(group, user.groups.all())
        else:
            self.assertNotIn(group, user.groups.all())
Exemplo n.º 4
0
    def _assert_group_relationship(self, user, group_name, rel_in):
        """Assert that a user is or is not in a given group.

        :user: {User} the user to check
        :group_name: {string} the group name to check
        :rel_in: {boolean} if true, assert that the user is IN the group.
                 otherwise, assert that the user is NOT in the group
        """
        group = get_group_by_name(group_name)
        if rel_in:
            self.assertIn(group, user.groups.all())
        else:
            self.assertNotIn(group, user.groups.all())
Exemplo n.º 5
0
 def is_administrator(self):
     return get_group_by_name(self.ADMIN_GROUP) in self.user.groups.all()
Exemplo n.º 6
0
 def is_ambassador(self):
     return get_group_by_name(
         self.AMBASSADOR_GROUP
     ) in self.user.groups.all()
Exemplo n.º 7
0
 def make_ambassador(self):
     self.user.is_staff = False
     self.user.is_superuser = False
     self.user.groups.remove(get_group_by_name(self.ADMIN_GROUP))
     self.user.groups.add(get_group_by_name(self.AMBASSADOR_GROUP))
     self.user.save()
Exemplo n.º 8
0
 def make_administrator(self):
     self.user.groups.add(get_group_by_name(self.AMBASSADOR_GROUP))
     self.user.groups.add(get_group_by_name(self.ADMIN_GROUP))
     self.user.is_staff = True
     self.user.is_superuser = True
     self.user.save()
Exemplo n.º 9
0
 def make_ambassador(self):
     self.user.is_staff = False
     self.user.is_superuser = False
     self.user.groups.remove(get_group_by_name(self.ADMIN_GROUP))
     self.user.groups.add(get_group_by_name(self.AMBASSADOR_GROUP))
     self.user.save()
Exemplo n.º 10
0
 def make_administrator(self):
     self.user.groups.add(get_group_by_name(self.AMBASSADOR_GROUP))
     self.user.groups.add(get_group_by_name(self.ADMIN_GROUP))
     self.user.is_staff = True
     self.user.is_superuser = True
     self.user.save()
Exemplo n.º 11
0
 def is_administrator(self):
     return get_group_by_name(self.ADMIN_GROUP) in self.user.groups.all()
Exemplo n.º 12
0
 def is_ambassador(self):
     return get_group_by_name(
         self.AMBASSADOR_GROUP) in self.user.groups.all()
Exemplo n.º 13
0
 def test_correct_groups_exist(self):
     get_group_by_name(RevolvUserProfile.AMBASSADOR_GROUP)
     get_group_by_name(RevolvUserProfile.ADMIN_GROUP)
Exemplo n.º 14
0
 def test_correct_groups_exist(self):
     get_group_by_name(RevolvUserProfile.AMBASSADOR_GROUP)
     get_group_by_name(RevolvUserProfile.ADMIN_GROUP)