コード例 #1
0
def edit_subscriber(id):
    subscriber = Subscriber.objects(id=id).first()
    form = SubscriberForm(obj=subscriber)
    if request.method == 'GET':
        return render_template('subscriber.html', form=form, id=id)
    elif request.method == 'POST':
        if form.submit.data:
            if form.validate_on_submit():
                subscriber.name = form.name.data
                subscriber.email = form.email.data
                subscriber.phone = form.phone.data
                subscriber.address = form.address.data
                subscriber.save()
                flash("Subscriber created successfully", 'success')
        return redirect("/list")
コード例 #2
0
def delete_subscriber(id):
    subscriber = Subscriber.objects(id=id).first()
    subscriber.delete()
    flash("Subscriber deleted successfully", 'success')
    return redirect("/list")