Exemple #1
0
    def post(self, request,id, *args, **kwargs):
        document = get_object_or_404(Document, pk=id)
        document_form = DocumentForm(request.POST,request.FILES,instance=document)

        if document_form.is_valid() :
            document = document_form.save()
            messages.success(request, "The document '%s' was edited." % document.name)
            return redirect('main:list_documents')
        else:
            return render(request, self.template_name, {'document_form': document_form})
Exemple #2
0
    def post(self, request, *args, **kwargs):
        user = get_object_or_404(EmailUser, pk=request.user.id)

        document_form = DocumentForm(request.POST,request.FILES)

        if document_form.is_valid() :
            document = document_form.save()
            user.documents.add(document)
            messages.success(request, "The document '%s' was created." % document.name)
            return redirect('main:list_documents')
        else:
            return render(request, self.template_name, {'document_form': document_form})