def edit_entry(eid): entry = Entry.query.get_or_404(eid) cities = City.query.ascending(City._no) cates = Cate.query.ascending(City._no) form = EntryForm(request.form, entry, next=request.args.get('next','')) if form.validate_on_submit(): next_url = form.next.data if entry.status == 'block': next_entry = Entry.query.filter( Entry.mongo_id!=entry.mongo_id, Entry.city_label==entry.city_label, Entry.status=='block').first() if next_entry: next_url = url_for('edit_entry', eid=next_entry.pk) else: if not next_url: next_url = url_for('list_entry') form.populate_obj(entry) entry.city_label = request.form.get('city_label', 'hangzhou') entry.status = 'wait' # wait for check again entry.save() flash(u"更新成功") return redirect(next_url) return render_template("admin/entry_add.html", form=form, cities=cities, city_label=entry.city_label, entry=entry, cates=cates)
def add_entry(): form = EntryForm(request.form, next=request.args.get('next', '')) cities = City.query.ascending(City.no) cates = Cate.query.ascending(City.no) if form.validate_on_submit(): entry = Entry() entry.updated = now() entry.created = now() entry.init_counters() entry.city_label = request.form.get('city_label') form.populate_obj(entry) entry.save() flash(u"保存成功") next_url = form.next.data if not next_url: next_url = url_for('list_entry') return redirect(next_url) return render_template("admin/entry_add.html", form=form, cities=cities, cates=cates)
def add_entry(): form = EntryForm(request.form, next=request.args.get('next','')) cities = City.query.ascending(City.no) cates = Cate.query.ascending(City.no) if form.validate_on_submit(): entry = Entry() entry.updated = now() entry.created = now() entry.init_counters() entry.city_label = request.form.get('city_label') form.populate_obj(entry) entry.save() flash(u"保存成功") next_url = form.next.data if not next_url: next_url = url_for('list_entry') return redirect(next_url) return render_template("admin/entry_add.html",form=form, cities=cities, cates=cates)
def edit_entry(eid): entry = Entry.query.get_or_404(eid) cities = City.query.ascending(City._no) cates = Cate.query.ascending(City._no) form = EntryForm(request.form, entry, next=request.args.get('next', '')) if form.validate_on_submit(): next_url = form.next.data if entry.status == 'block': next_entry = Entry.query.filter( Entry.mongo_id != entry.mongo_id, Entry.city_label == entry.city_label, Entry.status == 'block').first() if next_entry: next_url = url_for('edit_entry', eid=next_entry.pk) else: if not next_url: next_url = url_for('list_entry') form.populate_obj(entry) entry.city_label = request.form.get('city_label', 'hangzhou') entry.status = 'wait' # wait for check again entry.save() flash(u"更新成功") return redirect(next_url) return render_template("admin/entry_add.html", form=form, cities=cities, city_label=entry.city_label, entry=entry, cates=cates)