def events_delete(event_id): if request.method == "GET": events_index() if Event.get_event_owner(event_id) == current_user.id: c = Event.query.get(event_id) db.session.delete(c) db.session().commit() return redirect(url_for("events_index"))
def events_edit(event_id): if request.method == "GET": events_index() if Event.get_event_owner(event_id) == current_user.id: form = EventForm(request.form) if not form.validate(): form.description.data, form.duration.data = "", 0 return render_template( "events/list.html", events=list(Event.find_events_user_has_permissions_to(current_user.id)), category=Category.query.filter(Category.id == Event.category_id).first(), form=form ) c = Event.query.get(event_id) c.category_id = form.category_id.data.id c.description = form.description.data c.duration = form.duration.data db.session().commit() return redirect(url_for("events_index"))