Example #1
0
def register(request):
    if is_registration_disabled():
        raise Http404

    if not is_free_rooms():
        return HttpResponseRedirect('/waiting/')

    title = "Registration"
    definition = get_object_or_404(ZosiaDefinition, active_definition=True)

    date_1, date_2, date_3, date_4 = definition.zosia_start, (definition.zosia_start + timedelta(days=1)),\
                                                 (definition.zosia_start + timedelta(days=2)),\
                                                 (definition.zosia_start + timedelta(days=3))
    user_form = RegistrationForm(request.POST or None)
    pref_form = preferences_form_fabric(definition)(request.POST or None)
    org_form = OrganizationForm(request.POST or None)

    f1 = user_form.is_valid()
    f2 = pref_form.is_valid()
    f3 = org_form.is_valid()
    if f1 and f2 and f3:
        user = user_form.save()
        org = org_form.save()

        send_confirmation_mail(request, user, definition)
        preference = pref_form.save(commit=False)
        preference.user = user
        preference.org = org
        preference.state = definition
        preference.save()

        return HttpResponseRedirect('/register/thanks/')
    return render_to_response('register_form.html', locals())
Example #2
0
def register(request):
    if is_registration_disabled():
        raise Http404

    if not is_free_rooms():
        return HttpResponseRedirect('/waiting/')

    title = "Registration"
    definition = get_object_or_404(ZosiaDefinition, active_definition=True)

    date_1, date_2, date_3, date_4 = definition.zosia_start, (definition.zosia_start + timedelta(days=1)),\
                                                 (definition.zosia_start + timedelta(days=2)),\
                                                 (definition.zosia_start + timedelta(days=3))
    user_form = RegistrationForm(request.POST or None)
    pref_form = preferences_form_fabric(definition)(request.POST or None)
    org_form = OrganizationForm(request.POST or None)

    f1 = user_form.is_valid()
    f2 = pref_form.is_valid()
    f3 = org_form.is_valid()
    if f1 and f2 and f3:
        user = user_form.save()
        org = org_form.save()

        send_confirmation_mail(request, user, definition)
        preference = pref_form.save(commit=False)
        preference.user = user
        preference.org = org
        preference.state = definition
        preference.save()

        return HttpResponseRedirect('/register/thanks/')
    return render_to_response('register_form.html', locals())