Пример #1
0
def settings(id):
    project = get_project(id, for_management=False)
    members = project.members.join(Membership).with_entities(
        User, Membership.allows_management).all()
    kwargs = {
        'fqdn':
        current_app.config['SERVER_NAME'],
        'protocol':
        ('https'
         if current_app.config['KOZMIC_USE_HTTPS_FOR_BADGES'] else 'http'),
        'project_id':
        project.id,
        'project_full_name':
        project.gh_full_name,
    }
    example_badge_href = ('http://{fqdn}/projects/{project_id}/'
                          'builds/latest/?ref=master'.format(**kwargs))
    example_badge_src = ('{protocol}://{fqdn}/badges/{project_full_name}/'
                         'master'.format(**kwargs))
    return render_template(
        'projects/settings.html',
        project=project,
        members=members,
        is_current_user_a_manager=perms.manage_project(id).can(),
        can_current_user_delete_a_project=perms.delete_project(id).can(),
        example_badge_href=example_badge_href,
        example_badge_src=example_badge_src)
Пример #2
0
def get_project(id, for_management=True):
    project = Project.query.get_or_404(id)
    if for_management:
        permission_to_test = perms.manage_project(id)
    else:
        permission_to_test = perms.view_project(id)
    permission_to_test.test(http_exception=403)
    return project
Пример #3
0
def get_project(id, for_management=True):
    project = Project.query.get_or_404(id)
    if for_management:
        permission_to_test = perms.manage_project(id)
    else:
        permission_to_test = perms.view_project(id)
    permission_to_test.test(http_exception=403)
    return project
Пример #4
0
def settings(id):
    project = get_project(id, for_management=False)
    members = project.members.join(Membership).with_entities(
        User, Membership.allows_management).all()
    kwargs = {
        'fqdn': current_app.config['SERVER_NAME'],
        'protocol': ('https' if current_app.config['KOZMIC_USE_HTTPS_FOR_BADGES']
                     else 'http'),
        'project_id': project.id,
        'project_full_name': project.gh_full_name,
    }
    example_badge_href = ('http://{fqdn}/projects/{project_id}/'
                          'builds/latest/?ref=master'.format(**kwargs))
    example_badge_src = ('{protocol}://{fqdn}/badges/{project_full_name}/'
                         'master'.format(**kwargs))
    return render_template(
        'projects/settings.html',
        project=project,
        members=members,
        is_current_user_a_manager=perms.manage_project(id).can(),
        can_current_user_delete_a_project=perms.delete_project(id).can(),
        example_badge_href=example_badge_href,
        example_badge_src=example_badge_src)