Ejemplo n.º 1
0
def record_add(zone_id):
    zone = manager.get_zone(zone_id)

    if not zone:
        flash('DNS zone not found.', 'error')
        return redirect(url_for('.index'))

    form = ZoneRecordForm(zone_id=zone_id)

    if form.validate_on_submit():
        fields = {}
        for field in form:
            if 'csrf_token' == field.name:
                continue

            fields[field.name] = field.data

        fields['rec_type'] = fields['type']
        del(fields['type'])

        manager.add_record(**fields)

        flash('Zone record created.', 'success')
        return redirect(url_for('.zone_view', zone_id=zone_id))

    payload = {
        'title': 'Add Zone Record',
        'form': form,
        'zone': zone,
        'action': url_for('.record_add', zone_id=zone_id),
        'action_name': 'Add',
    }

    return render_template('zone_update_record.html', **payload)
Ejemplo n.º 2
0
def zone_view(zone_id):
    zone = manager.get_zone(zone_id)

    if not zone:
        flash('DNS zone not found.', 'error')
        return redirect(url_for('.index'))

    payload = {
        'title': 'View Zone',
        'subheader': zone['name'],
        'submenu': [(url_for('.record_add', zone_id=zone_id), 'Add Record')],
        'zone': zone,
    }

    return render_template("zone_view.html", **payload)