Example #1
0
 def test_admin_group_access(self):
     # sean go superuser har admin rettigheder
     # normaluser skal fejle. 
     
     # admin_group_access(user)
     self.assertEquals(admin_group_access(self.anonuser), False) 
     self.assertEquals(admin_group_access(self.normaluser), False)
     self.assertEquals(admin_group_access(self.sean), True) # In admin group
     self.assertEquals(admin_group_access(self.superuser), True) # 
Example #2
0
def has_member(tribe, user):
    if user.is_authenticated():
        if TribeMember.objects.filter(tribe=tribe, user=user).count() > 0:
            return True
        elif admin_group_access(user):
            return True
    return False
Example #3
0
def can_delete_comment(comment, user):
    """
    Default callback function to determine wether the given user has the
    ability to delete the given comment.
    """
    if user.is_staff or admin_group_access(user):
        return True
    if hasattr(comment, 'user') and comment.user == user:
        return True
    return False
Example #4
0
@condition_tag
def if_can_edit_topic(topic='topic', user='******'):
    ''' Determin if a user can edit a topic.
        
        A user can always edit a topic if she is the creator of the tribe.
        
        Other users have got 15 minutes from they posted the topic.
    '''

    if topic.tribe.creator.id == user.id or admin_group_access(user):
        return True
    if topic.creator.id == user.id:
        created = topic.created
        now = datetime.now()
        time_since = now - created
        if time_since.seconds > 60*15:
            return False
        else: 
            return True
Example #5
0
def if_in_admin_group(user='******'):
    return admin_group_access(user)