Exemplo n.º 1
0
def render_admin_page(portfolio, form=None):
    pagination_opts = Paginator.get_pagination_opts(http_request)
    audit_events = AuditLog.get_portfolio_events(portfolio, pagination_opts)
    members_data = get_members_data(portfolio)
    portfolio_form = PortfolioForm(data={"name": portfolio.name})
    member_perms_form = member_forms.MembersPermissionsForm(
        data={"members_permissions": members_data}
    )

    assign_ppoc_form = member_forms.AssignPPOCForm()
    for pf_role in portfolio.roles:
        if pf_role.user != portfolio.owner and pf_role.is_active:
            assign_ppoc_form.role_id.choices += [(pf_role.id, pf_role.full_name)]

    current_member = first_or_none(
        lambda m: m.user_id == g.current_user.id, portfolio.members
    )
    current_member_id = current_member.id if current_member else None

    return render_template(
        "portfolios/admin.html",
        form=form,
        portfolio_form=portfolio_form,
        member_perms_form=member_perms_form,
        member_form=member_forms.NewForm(),
        assign_ppoc_form=assign_ppoc_form,
        portfolio=portfolio,
        audit_events=audit_events,
        user=g.current_user,
        ppoc_id=members_data[0].get("member_id"),
        current_member_id=current_member_id,
        applications_count=len(portfolio.applications),
    )
Exemplo n.º 2
0
def render_admin_page(portfolio, form=None):
    pagination_opts = Paginator.get_pagination_opts(http_request)
    audit_events = AuditLog.get_portfolio_events(portfolio, pagination_opts)
    portfolio_form = PortfolioForm(obj=portfolio)
    member_list = portfolio.members
    assign_ppoc_form = member_forms.AssignPPOCForm()

    for pf_role in portfolio.roles:
        if pf_role.user != portfolio.owner and pf_role.is_active:
            assign_ppoc_form.role_id.choices += [(pf_role.id,
                                                  pf_role.full_name)]

    current_member = first_or_none(lambda m: m.user_id == g.current_user.id,
                                   portfolio.members)
    current_member_id = current_member.id if current_member else None

    return render_template(
        "portfolios/admin.html",
        form=form,
        portfolio_form=portfolio_form,
        members=filter_members_data(member_list, portfolio),
        new_manager_form=member_forms.NewForm(),
        assign_ppoc_form=assign_ppoc_form,
        portfolio=portfolio,
        audit_events=audit_events,
        user=g.current_user,
        current_member_id=current_member_id,
        applications_count=len(portfolio.applications),
    )
Exemplo n.º 3
0
def activity_history():
    if app.config.get("USE_AUDIT_LOG", False):
        pagination_opts = Paginator.get_pagination_opts(request)
        audit_events = AuditLog.get_all_events(pagination_opts)
        return render_template("audit_log/audit_log.html",
                               audit_events=audit_events)
    else:
        return redirect("/")
Exemplo n.º 4
0
def render_settings_page(application, **kwargs):
    environments_obj = get_environments_obj_for_app(application=application)
    new_env_form = EditEnvironmentForm()
    pagination_opts = Paginator.get_pagination_opts(http_request)
    audit_events = AuditLog.get_application_events(application,
                                                   pagination_opts)
    new_member_form = get_new_member_form(application)
    members = get_members_data(application)

    if "application_form" not in kwargs:
        kwargs["application_form"] = NameAndDescriptionForm(
            name=application.name, description=application.description)

    return render_template(
        "applications/settings.html",
        application=application,
        environments_obj=environments_obj,
        new_env_form=new_env_form,
        audit_events=audit_events,
        new_member_form=new_member_form,
        members=members,
        **kwargs,
    )