1 # -*- coding: utf-8 -*-
2 # This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
3 # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
5 from django.shortcuts import get_object_or_404
6 from django.contrib.auth.decorators import login_required, user_passes_test
7 from piston.handler import BaseHandler
8 from piston.utils import rc, validate
9 from catalogue.models import Book
10 from catalogue.forms import BookImportForm
13 staff_required = user_passes_test(lambda user: user.is_staff)
16 class BookHandler(BaseHandler):
18 fields = ('slug', 'title')
21 def read(self, request, slug=None):
23 return get_object_or_404(Book, slug=slug)
25 return Book.objects.all()
28 def create(self, request):
29 form = BookImportForm(request.POST, request.FILES)