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)
def post(self, request): presentation_converted = PresentationHandler(request.POST, request.FILES) presentation = Presentation(title=presentation_converted.title, presentation=presentation_converted.path['presentation']) presentation.save() for i in range(len(presentation_converted.path['images'])): presentation.presentationimages_set.add(PresentationImages(image=presentation_converted.path['images'][i], image_min = presentation_converted.path['thumbnail'][i])) presentation.save() return HttpResponseRedirect(reverse('upload_presentation'))