Example #1
0
def change_preferences(request):
    user = request.user
    title = "Change preferences"
    try:
        prefs = UserPreferences.objects.get(user=user)
    except ObjectDoesNotExist:
        return HttpResponseRedirect('/waiting/')

    user_paid = prefs.paid
    definition = get_object_or_404(ZosiaDefinition, active_definition=True)
    user_opening_hour = definition.rooming_start - timedelta(minutes=prefs.minutes_early) # for sure to change

    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))
    if request.POST:
        # raise Http404 # the most nooby way of blocking evar (dreamer_)
        # bug with settings not updateble
        # after user paid
        post = prepare_data(request.POST, prefs)
        pref_form = preferences_form_fabric(definition, prefs)(post, instance=prefs)
        if pref_form.is_valid():
            prefs = pref_form.save()
            payment = prefs.count_payment()

    else:
        pref_form = preferences_form_fabric(definition, prefs)(instance=prefs)
        payment = prefs.count_payment()
    user_wants_bus = prefs.bus
    return render_to_response('change_preferences.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())