#1758: don't open new tab for book edit
{% if book.single %}
{% with book.0 as chunk %}
<tr>
{% if book.single %}
{% with book.0 as chunk %}
<tr>
- <td><a target="_blank" href="{% url catalogue_book book.slug %}" title='{% trans "Book settings" %}'>[B]</a></td>
+ <td><a href="{% url catalogue_book book.slug %}" title='{% trans "Book settings" %}'>[B]</a></td>
<td><a href="{% url catalogue_chunk_edit book.slug chunk.slug %}" title='{% trans "Chunk settings" %}'>[c]</a></td>
<td><a target="_blank"
href="{% url wiki_editor book.slug %}">
<td><a href="{% url catalogue_chunk_edit book.slug chunk.slug %}" title='{% trans "Chunk settings" %}'>[c]</a></td>
<td><a target="_blank"
href="{% url wiki_editor book.slug %}">
{% endwith %}
{% else %}
<tr>
{% endwith %}
{% else %}
<tr>
- <td><a target="_blank" href="{% url catalogue_book book.slug %}" title='{% trans "Book settings" %}'>[B]</a></td>
+ <td><a href="{% url catalogue_book book.slug %}" title='{% trans "Book settings" %}'>[B]</a></td>
<td></td>
<td>{{ book.title }}</td>
<td></td><td></td>
<td></td>
<td>{{ book.title }}</td>
<td></td><td></td>
{% load i18n %}
{% block leftcolumn %}
{% load i18n %}
{% block leftcolumn %}
- <form enctype="multipart/form-data" method="POST" action="">
+ <form enctype="multipart/form-data" method="POST" action="{% if go_next %}?next={{ go_next }}{% endif %}">
{% csrf_token %}
{{ form.as_p }}
{% csrf_token %}
{{ form.as_p }}
import logging
import os
from StringIO import StringIO
import logging
import os
from StringIO import StringIO
+from urllib import unquote
+from urlparse import urlsplit, urlunsplit
from django.contrib import auth
from django.contrib.auth.models import User
from django.contrib import auth
from django.contrib.auth.models import User
from django import http
from django.http import Http404
from django.shortcuts import get_object_or_404, render
from django import http
from django.http import Http404
from django.shortcuts import get_object_or_404, render
+from django.utils.encoding import iri_to_uri
from django.utils.http import urlquote_plus
from django.utils.translation import ugettext_lazy as _
from django.views.decorators.http import require_POST
from django.utils.http import urlquote_plus
from django.utils.translation import ugettext_lazy as _
from django.views.decorators.http import require_POST
form = forms.ChunkForm(request.POST, instance=doc)
if form.is_valid():
form.save()
form = forms.ChunkForm(request.POST, instance=doc)
if form.is_valid():
form.save()
- return http.HttpResponseRedirect(doc.book.get_absolute_url())
+ go_next = request.GET.get('next', None)
+ if go_next:
+ go_next = urlquote_plus(unquote(iri_to_uri(go_next)), safe='/?=&')
+ else:
+ go_next = doc.book.get_absolute_url()
+ return http.HttpResponseRedirect(go_next)
else:
form = forms.ChunkForm(instance=doc)
else:
form = forms.ChunkForm(instance=doc)
+
+ parts = urlsplit(request.META['HTTP_REFERER'])
+ parts = ['', ''] + list(parts[2:])
+ go_next = urlquote_plus(urlunsplit(parts))
+
return direct_to_template(request, "catalogue/chunk_edit.html", extra_context={
"chunk": doc,
"form": form,
return direct_to_template(request, "catalogue/chunk_edit.html", extra_context={
"chunk": doc,
"form": form,