'Return True if the received user can administer the received repository.'

def user_can_administer_repository(self, user, repository):

    if user:
        if repository:
            repository_admin_role = repository.admin_role
            for rra in repository.roles:
                role = rra.role
                if (role.id == repository_admin_role.id):
                    for ura in role.users:
                        role_member = ura.user
                        if (role_member.id == user.id):
                            return True
                    for gra in role.groups:
                        group = gra.group
                        for uga in group.members:
                            member = uga.user
                            if (member.id == user.id):
                                return True
    return False
