Example #1
0
def create_domain():
    if request.method == 'GET':
        return render_template('create_domain.html')

    domain = request.form.get('domain').strip()
    d = Domain.get_by_name(domain)
    if d:
        flash(u'Domain already exist.', 'info')
        return redirect(url_for('admin.create_domain'))

    d = Domain.create(domain)
    if not d:
        flash(u'创建失败', 'error')
        return redirect(url_for('admin.create_domain'))
    return redirect(url_for('admin.domain_show'))