30 lines
791 B
Python
30 lines
791 B
Python
from django.shortcuts import render, redirect
|
|
from .models import Section
|
|
from .forms import SectionForm
|
|
|
|
|
|
def home(request):
|
|
return render(request, 'writer/home.html', {})
|
|
|
|
|
|
def edit_section(request, document_id, section_id):
|
|
section = Section.objects.get(document=document_id, pk=section_id)
|
|
|
|
if request.method == "POST":
|
|
form = SectionForm(request.POST, instance=section)
|
|
if form.is_valid():
|
|
form.save()
|
|
return redirect('document_details', pk=document_id)
|
|
else:
|
|
form = SectionForm(instance=section)
|
|
|
|
return render(
|
|
request,
|
|
'writer/edit_section.html',
|
|
{
|
|
'document_id': document_id,
|
|
'section': section,
|
|
'form': form
|
|
}
|
|
)
|