def unsubscribe(guest_id): email = request.args.get('email') guest = Guest.find(guest_id) if guest and email == guest.email: print(f"Guest {guest.id} removed") guest.delete() return render_template('unsubscribe.html') else: abort(404)
def edit_guest(guest_id): form = GuestForm() guest = Guest.find(guest_id) or abort(404) if form.validate_on_submit(): form.fill_model(guest) guest.filled_by_admin = True guest.save() return redirect(url_for("admin.list_guest")) form.set_model(guest) return render_template('guest_form.html', form=form, title=_("Edit guest"))
def rsvp_captcha(): guest_id = urlparse(request.args.get("next", "").split('/')[-1]).path if not guest_id: abort(404) form = RSVPCaptchaForm() if form.validate_on_submit() or not current_app.config["USE_RECAPTCHA_FOR_GUEST"]: guest = Guest.find(guest_id) if guest: login_user(guest, remember=True) return redirect(url_for("rsvp.rsvp_page", guest_id=guest_id)) else: abort(404) else: return render_template('rsvp_captcha.html', title=_('Wedding'), form=form)
def delete_guest(guest_id): guest = Guest.find(guest_id) or abort(404) guest.delete() flash(_("Guest {} removed".format(guest.name))) return redirect(url_for("admin.list_guest"))
def load_user(user_id): if request.blueprint == "admin": if user_id == "admin": return Admin() if request.blueprint == "rsvp": return Guest.find(user_id)