Beispiel #1
0
def edit_slide(request, presentation_id, slide_id):
    presentation = get_object_or_404(Presentation, pk=presentation_id)
    slide =  get_object_or_404(Slide, pk=slide_id)
    position = get_object_or_404(Position, pk=slide_id)
    success = False
    
    slide_form = SlideForm(instance=slide)
    position_form = PositionForm(instance=position)
    
    if request.method == "POST":
        s_form = SlideForm(request.POST, instance=slide)
        p_form = PositionForm(request.POST, instance=position)
        if s_form.is_valid() and p_form.is_valid():
            s_form.save()
            p_form.save()
        success = True
    
    ctx = {
         "slide_form": slide_form,
         "position_form": position_form,
         "success": success,
         "edit": True,
         "presentation": presentation,
    }
    return render_to_response('presentation/add_slide.html', ctx)
Beispiel #2
0
def add_slide(request, presentation_id):
    
    presentation = get_object_or_404(Presentation, pk=presentation_id)
    success = False
    
    if request.method == "POST":
        slide_form = SlideForm(request.POST)
        position_form = PositionForm(request.POST)
        if slide_form.is_valid() and position_form.is_valid():
            s_form = SlideForm(request.POST)
            new_slide = s_form.save(commit=False)
            new_slide.presentation = presentation
            new_slide.order_number = presentation.get_max_slide_order_number()
            new_slide.save()
            
            p_form = PositionForm(request.POST)
            new_position = p_form.save(commit=False)
            new_position.id = new_slide
            new_position.save()
            success = True
    else:
        slide_form = SlideForm()
        position_form = PositionForm()
    ctx = {
           'presentation_id': presentation.id,
           'success': success,
           'slide_form': slide_form,
           'position_form': position_form,
           "presentation": presentation,
    }
    
    return render_to_response('presentation/add_slide.html', ctx)