- if request.method == "POST":
- form = forms.ChooseMasterForm(request.POST)
- if not choose_master or form.is_valid():
- if choose_master:
- first_master = form.cleaned_data['master']
-
- # do the actual fixing
- for c in chunks:
- if not c['fix']:
- continue
-
- text = c['chunk'].materialize()
- for fix in c['fix']:
- if fix == 'bad-master':
- text = xml_tools.change_master(text, first_master)
- elif fix == 'trim-begin':
- text = xml_tools.add_trim_begin(text)
- elif fix == 'trim-end':
- text = xml_tools.add_trim_end(text)
- elif fix == 'wl':
- text = xml_tools.basic_structure(text, first_master)
- author = request.user if request.user.is_authenticated() else None
- description = "auto-fix: " + ", ".join(c['fix'])
- c['chunk'].commit(text=text, author=author,
- description=description)
-
- return http.HttpResponseRedirect(book.get_absolute_url())
- elif choose_master:
- form = forms.ChooseMasterForm()
+# @never_cache
+# def revision(request, slug, chunk=None):
+# try:
+# doc = Chunk.get(slug, chunk)
+# except (Chunk.MultipleObjectsReturned, Chunk.DoesNotExist):
+# raise Http404
+# if not doc.book.accessible(request):
+# return HttpResponseForbidden("Not authorized.")
+# return http.HttpResponse(str(doc.revision()))
+
+
+@login_required
+def book_schedule(request, pk):
+ book = get_object_or_404(Document, pk=pk, deleted=False)
+ if request.method == 'POST':
+ Plan.objects.filter(document=book).delete()
+ for i, s in enumerate(STAGES):
+ user_id = request.POST.get('s%d-user' % i)
+ deadline = request.POST.get('s%d-deadline' % i) or None
+ Plan.objects.create(document=book, stage=s, user_id=user_id, deadline=deadline)
+
+ book.set_stage(request.POST.get('stage', ''))
+ return redirect('catalogue_user')
+
+ current = {}
+ for p in Plan.objects.filter(document=book):
+ current[p.stage] = (getattr(p.user, 'pk', None), (p.deadline.isoformat() if p.deadline else None))
+
+ schedule = [(i, s, current.get(s, ())) for (i, s) in enumerate(STAGES)]
+
+ if book.owner_organization:
+ people = [m.user for m in book.owner_organization.membership_set.exclude(status='pending')]