def organisations():
    orgs = organisations_client.get_organisations()

    return render_template(
        'views/organisations/index.html',
        organisations=orgs,
        search_form=SearchByNameForm(),
    )
def link_service_to_organisation(service_id):

    all_organisations = organisations_client.get_organisations()

    form = LinkOrganisationsForm(
        choices=convert_dictionary_to_wtforms_choices_format(
            all_organisations, 'id', 'name'),
        organisations=current_service.organisation_id)

    if form.validate_on_submit():
        if form.organisations.data != current_service.organisation_id:
            organisations_client.update_service_organisation(
                service_id, form.organisations.data)
        return redirect(url_for('.service_settings', service_id=service_id))

    return render_template(
        'views/service-settings/link-service-to-organisation.html',
        has_organisations=all_organisations,
        form=form,
        search_form=SearchByNameForm(),
    )
def service_set_branding_and_org(service_id):
    organisations = organisations_client.get_organisations()

    form = ServiceBrandingOrg(branding_type=current_service.get('branding'))
    # dynamically create org choices, including the null option
    form.organisation.choices = [
        ('None', 'None')
    ] + get_branding_as_value_and_label(organisations)

    if form.validate_on_submit():
        organisation = None if form.organisation.data == 'None' else form.organisation.data
        service_api_client.update_service(service_id,
                                          branding=form.branding_type.data,
                                          organisation=organisation)
        return redirect(url_for('.service_settings', service_id=service_id))

    form.organisation.data = current_service['organisation'] or 'None'

    return render_template('views/service-settings/set-branding-and-org.html',
                           form=form,
                           branding_dict=get_branding_as_dict(organisations))
示例#4
0
def organisations(organisation_id=None):
    orgs = organisations_client.get_organisations()

    form = ServiceSelectOrg()
    form.organisation.choices = get_branding_as_value_and_label(orgs) + [('None', 'Create a new organisation')]

    if form.validate_on_submit():
        if form.organisation.data != 'None':
            session['organisation'] = [o for o in orgs if o['id'] == form.organisation.data][0]
        elif session.get('organisation'):
            del session['organisation']

        return redirect(url_for('.manage_org'))

    form.organisation.data = organisation_id if organisation_id in [o['id'] for o in orgs] else 'None'

    return render_template(
        'views/organisations/select-org.html',
        form=form,
        branding_dict=get_branding_as_dict(orgs),
        organisation_id=organisation_id
    )
def service_set_branding_and_org(service_id):
    organisations = organisations_client.get_organisations()

    form = ServiceBrandingOrg(branding_type=current_service.get('branding'))
    # dynamically create org choices, including the null option
    form.organisation.choices = [('None', 'None')] + get_branding_as_value_and_label(organisations)

    if form.validate_on_submit():
        organisation = None if form.organisation.data == 'None' else form.organisation.data
        service_api_client.update_service(
            service_id,
            branding=form.branding_type.data,
            organisation=organisation
        )
        return redirect(url_for('.service_settings', service_id=service_id))

    form.organisation.data = current_service['organisation'] or 'None'

    return render_template(
        'views/service-settings/set-branding-and-org.html',
        form=form,
        branding_dict=get_branding_as_dict(organisations)
    )
示例#6
0
def organisations():
    orgs = organisations_client.get_organisations()

    return render_template('views/organisations/index.html',
                           organisations=orgs)