def homepage(request): if request.method == "POST": form = WaitingListEntryForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse("waitinglist_sucess")) else: form = WaitingListEntryForm() return direct_to_template(request, "homepage.html", {"form": form})
def list_signup(request, post_save_redirect=None): if request.method == "POST": form = WaitingListEntryForm(request.POST) if form.is_valid(): form.save() if post_save_redirect is None: post_save_redirect = reverse("waitinglist_success") if not post_save_redirect.startswith("/"): post_save_redirect = reverse(post_save_redirect) return redirect(post_save_redirect) else: form = WaitingListEntryForm() ctx = { "form": form, } return render(request, "waitinglist/list_signup.html", ctx)
def list_signup(request, post_save_redirect=None): if request.method == "POST": form = WaitingListEntryForm(request.POST) if form.is_valid(): form.save() if post_save_redirect is None: post_save_redirect = reverse("waitinglist_success") if not post_save_redirect.startswith("/"): post_save_redirect = reverse(post_save_redirect) return HttpResponseRedirect(post_save_redirect) else: form = WaitingListEntryForm() context = { "form": form, } context = RequestContext(request, context) return render_to_response("waitinglist/list_signup.html", context)
def waitinglist_entry_form(): """ Get a (new) form object to post a new comment. Syntax:: {% waitinglist_entry_form as [varname] %} """ return WaitingListEntryForm()
def list_signup(request, post_save_redirect=None): if request.method == "POST": form = WaitingListEntryForm(request.POST) if form.is_valid(): entry = form.save() signed_up.send(sender=list_signup, entry=entry) try: post_save_redirect = reverse("waitinglist_survey", args=[entry.surveyinstance.code]) except SurveyInstance.DoesNotExist: pass if post_save_redirect is None: post_save_redirect = reverse("waitinglist_success") if not post_save_redirect.startswith("/"): post_save_redirect = reverse(post_save_redirect) return redirect(post_save_redirect) else: form = WaitingListEntryForm() ctx = { "form": form, } return render(request, "waitinglist/list_signup.html", ctx)
def ajax_list_signup(request): form = WaitingListEntryForm(request.POST) if form.is_valid(): entry = form.save() signed_up.send(sender=ajax_list_signup, entry=entry) try: data = { "location": reverse("waitinglist_survey", args=[entry.surveyinstance.code]) } except SurveyInstance.DoesNotExist: data = { "html": render_to_string("waitinglist/_success.html", { }, context_instance=RequestContext(request)) } else: data = { "html": render_to_string("waitinglist/_list_signup.html", { "form": form, }, context_instance=RequestContext(request)) } return HttpResponse(json.dumps(data), content_type="application/json")
def ajax_list_signup(request): form = WaitingListEntryForm(request.POST) if form.is_valid(): entry = form.save() signed_up.send(sender=ajax_list_signup, entry=entry) try: data = { "location": reverse("waitinglist_survey", args=[entry.surveyinstance.code]) } except SurveyInstance.DoesNotExist: data = { "html": render_to_string("waitinglist/_success.html", { }, context_instance=RequestContext(request)) } else: data = { "html": render_to_string("waitinglist/_list_signup.html", { "form": form, }, context_instance=RequestContext(request)) } return HttpResponse(json.dumps(data), mimetype="application/json")
def homepage(request): if request.method == "POST": form = WaitingListEntryForm(request.POST) if form.is_valid(): form.save() return HttpResponseRedirect(reverse("waitinglist_sucess")) else: form = WaitingListEntryForm() return direct_to_template(request, "homepage.html", { "form": form, })