# ====================
-@require_POST
+@login_required
def like_book(request, slug):
- if not request.user.is_authenticated:
- return HttpResponseForbidden('Login required.')
book = get_object_or_404(Book, slug=slug)
+ if request.method != 'POST':
+ return redirect(book.get_absolute_url())
+
book.like(request.user)
if is_ajax(request):
function upd_t() {
$text = $('#main-text #book-text');
+ if (!$text.length) return;
+
texttop = $text.offset().top;
$footnotes = $('#footnotes', $text);
}
var map_enabled = false;
- var marker = L.circleMarker([0,0]);
+ var marker = null;
var map = null;
function enable_map() {
+ if (!$("#reference-map").length) return;
+
$("#reference-map").show('slow');
if (map_enabled) return;
L.tileLayer('https://tile.thunderforest.com/cycle/{z}/{x}/{y}.png?apikey=a8a97f0ae5134403ac38c1a075b03e15', {
attribution: 'Maps © <a href="http://www.thunderforest.com">Thunderforest</a>, Data © <a href="http://www.openstreetmap.org/copyright">OpenStreetMap contributors</a>'
}).addTo(map);
+ marker = L.circleMarker([0,0]);
map_enabled = true;
}
},
error: function(e) {
if (e.status == 403) {
- $('#login-link').click();
+ window.location.href = $('#login-link').attr('href')
}
},
});