コード例 #1
0
def service_edit_letter_contact(service_id, letter_contact_id):
    letter_contact_block = current_service.get_letter_contact_block(
        letter_contact_id)
    form = ServiceLetterContactBlockForm(
        letter_contact_block=letter_contact_block['contact_block'])
    if request.method == 'GET':
        form.is_default.data = letter_contact_block['is_default']
    if form.validate_on_submit():
        service_api_client.update_letter_contact(
            current_service.id,
            letter_contact_id=letter_contact_id,
            contact_block=form.letter_contact_block.data.replace('\r', '')
            or None,
            is_default=True
            if letter_contact_block['is_default'] else form.is_default.data)
        return redirect(
            url_for('.service_letter_contact_details', service_id=service_id))
    return render_template('views/service-settings/letter-contact/edit.html',
                           form=form,
                           letter_contact_id=letter_contact_block['id'])
コード例 #2
0
def service_edit_letter_contact(service_id, letter_contact_id):
    letter_contact_block = current_service.get_letter_contact_block(letter_contact_id)
    form = ServiceLetterContactBlockForm(
        letter_contact_block=letter_contact_block['contact_block']
    )
    if request.method == 'GET':
        form.is_default.data = letter_contact_block['is_default']
    if form.validate_on_submit():
        current_service.edit_letter_contact_block(
            id=letter_contact_id,
            contact_block=form.letter_contact_block.data.replace('\r', '') or None,
            is_default=letter_contact_block['is_default'] or form.is_default.data
        )
        return redirect(url_for('.service_letter_contact_details', service_id=service_id))

    if (request.endpoint == "main.service_confirm_delete_letter_contact"):
        flash("Are you sure you want to delete this contact block?", 'delete')
    return render_template(
        'views/service-settings/letter-contact/edit.html',
        form=form,
        letter_contact_id=letter_contact_block['id'])