예제 #1
0
def add_presentation(request, presentation_id=None):
    
    
    if presentation_id:
        presentation = get_object_or_404(Presentation, pk=presentation_id)
    
    success = False
    title = ""
    description = ""
    new_presentation = None
    
    if request.method == "POST":
        presentation_form = PresentationForm(request.POST)
        if presentation_form.is_valid():
            title = presentation_form.cleaned_data['title']
            description = presentation_form.cleaned_data['description']
            
            new_presentation = Presentation()
            new_presentation.title = title
            new_presentation.description = description
            new_presentation.save()
            success = True
    else:
        presentation_form = PresentationForm()
            
    ctx = { 'presentation_form': presentation_form,
           'title': title,
           'description': description,
           'success': success,
           'presentation': new_presentation,
    }
    return render_to_response('presentation/add_presentation.html', ctx)
예제 #2
0
def edit_presentation(request, presentation_id):
    presentation = get_object_or_404(Presentation, pk=presentation_id)
    success = False
    edit = True
    
    if request.method == "POST":
        presentation_form = PresentationForm(request.POST)
        if presentation_form.is_valid():
            presentation_form = PresentationForm(request.POST, instance=presentation)
            presentation_form.save()
        success = True
    
    else:
        presentation_form = PresentationForm(instance=presentation)
    
    ctx = {
           'success': success,
           'presentation_form': presentation_form,
           'edit': edit,
    }
    return render_to_response('presentation/add_presentation.html', ctx)