Badge
A viewset for handling CRUD operations on Book objects. It provides custom
actions for managing book statuses like badges, flags, love reactions, and
saved states. The viewset allows filtering, searching, and retrieving book
data with enhanced context based on user interactions and permissions.
Standard HTTP methods:
- GET: Retrieve book data.
- HEAD: Retrieve HTTP headers only.
- POST: Create new book entries
(currently returns "Method Not Allowed").
- DELETE: Remove book entries (currently returns "Method Not Allowed").
Custom actions include:
- badge: Retrieve the badge information of a book.
- chapters_info: Get chapter details for specified indexes.
- flag: Flag a book or specific line with a reason.
- unflag: Remove flags from a book or specific line.
- flagged: Check if a book or line is flagged.
- myshelf: Add a book to the user's "My shelf" collection.
- delete_from_myshelf: Remove a book from the user's "My shelf".
- loved: Check if a book is loved by the user.
- saved_to_myshelf: Check if a book is saved to the user's shelf.
- saved_to_class: Check if a book is part of a class group.
- book_summary: Retrieve comprehensive book information,
including all status flags.
The queryset is filtered based on user permissions, and several helper
methods are provided to manage book interactions.
GET /api/books/23170/badge/?format=api
{
"badge": "Premium"
}