Example #1
0
def edit_occurrence(request,
                    event_id,
                    template_name="schedule/edit_occurrence.html",
                    *args,
                    **kwargs):
    extra_context = kwargs.get('extra_context', None) or {}
    event, occurrence = get_occurrence(event_id, *args, **kwargs)
    next = kwargs.get('next', None)
    form = OccurrenceForm(data=request.POST or None, instance=occurrence)
    if form.is_valid():
        occurrence = form.save(commit=False)
        occurrence.event = event
        occurrence.save()
        next = next or get_next_url(request, occurrence.get_absolute_url())
        return HttpResponseRedirect(next)
    next = next or get_next_url(request, occurrence.get_absolute_url())
    context = {
        'form': form,
        'occurrence': occurrence,
        'next': next,
    }
    context.update(extra_context)
    return render_to_response(template_name,
                              context,
                              context_instance=RequestContext(request))
Example #2
0
def edit_occurrence(request, event_id, 
    template_name="schedule/edit_occurrence.html", *args, **kwargs):
    event, occurrence = get_occurrence(event_id, *args, **kwargs)
    form = OccurrenceForm(data=request.POST or None, instance=occurrence)
    if form.is_valid():
        occurrence = form.save(commit=False)
        occurrence.event = event
        occurrence.save()
        next = kwargs.get('next', None) or occurrence.get_absolute_url()
        return HttpResponseRedirect(get_next_url(request, next))
    return render_to_response(template_name, {
        'form': form,
        'occurrence': occurrence,
    }, context_instance=RequestContext(request))
Example #3
0
def edit_occurrence(request, event_id, template_name="schedule/edit_occurrence.html", *args, **kwargs):
    extra_context = kwargs.get("extra_context", None) or {}
    event, occurrence = get_occurrence(event_id, *args, **kwargs)
    next = kwargs.get("next", None)
    form = OccurrenceForm(data=request.POST or None, instance=occurrence)
    if form.is_valid():
        occurrence = form.save(commit=False)
        occurrence.event = event
        occurrence.save()
        next = next or get_next_url(request, occurrence.get_absolute_url())
        return HttpResponseRedirect(next)
    next = next or get_next_url(request, occurrence.get_absolute_url())
    context = {"form": form, "occurrence": occurrence, "next": next}
    context.update(extra_context)
    return render_to_response(template_name, context, context_instance=RequestContext(request))
Example #4
0
def edit_occurrence(request, reservation_id,
    template_name="schedule/edit_occurrence.html", *args, **kwargs):
    extra_context = kwargs.get('extra_context', None) or {}
    reservation, occurrence = get_occurrence(reservation_id, *args, **kwargs)
    next = kwargs.get('next', None)
    form = OccurrenceForm(data=request.POST or None, instance=occurrence)
    if form.is_valid():
        occurrence = form.save(commit=False)
        occurrence.reservation = reservation
        occurrence.save()
        next = next or get_next_url(request, occurrence.get_absolute_url())
        return HttpResponseRedirect(next)
    next = next or get_next_url(request, occurrence.get_absolute_url())
    context = {
        'form': form,
        'occurrence': occurrence,
        'next':next,
    }
    context.update(extra_context)
    return render_to_response(template_name, context, context_instance=RequestContext(request))