def register(request): """ Display the register form. """ context, preferences = _get_context_pref() if request.method == 'POST': form = KursAnmeldungForm(request.POST) #self.page_msg(self.request.POST) if form.is_valid(): # Create, but don't save the new instance. new_entry = form.save(commit=False) rnd_hash = crypt.get_new_seed() new_entry.verify_hash = rnd_hash new_entry.log(request, "created") # Save the new instance. new_entry.save() # save many-to-many data form.save_m2m() _send_verify_email(request, preferences, new_entry, rnd_hash, new_entry) # Save new log entries new_entry.save() new_location = reverse("KursAnmeldung-register_done") return HttpResponseRedirect(new_location) else: form = KursAnmeldungForm() context["form"] = form return context
def register(request): """ Display the register form. """ context, preferences = _get_context_pref() is_active = _is_active(request, preferences) if not is_active: # Course registration is disabled by preferences # or there exist no active course disable_text = preferences["disable_text"] return mark_safe(disable_text) if request.method == "POST": form = KursAnmeldungForm(request.POST) # messages.debug(request, repr(request.POST)) if form.is_valid(): # Create, but don't save the new instance. new_entry = form.save(commit=False) rnd_hash = crypt.get_new_seed() new_entry.verify_hash = rnd_hash new_entry.log(request, "created") # Save the new instance. new_entry.save() # save many-to-many data form.save_m2m() _send_verify_email(request, preferences, new_entry, rnd_hash, new_entry) # Save new log entries new_entry.save() messages.success(request, message="data saved") new_location = reverse("KursAnmeldung-register_done") return HttpResponseRedirect(new_location) else: form = KursAnmeldungForm() context["form"] = form context["url"] = request.path return context