reader package

The app that handles configuration.

reader.default_app_config = 'reader.apps.ReaderConfig'

The config class of the app.

Submodules

reader.admin module

Admin models for the reader app.

class reader.admin.SeriesAliasInline(parent_model, admin_site)[source]

Bases: django.contrib.admin.options.StackedInline

Inline admin model for SeriesAlias.

model

alias of reader.models.SeriesAlias

extra = 1
class reader.admin.AuthorAliasInline(parent_model, admin_site)[source]

Bases: django.contrib.admin.options.StackedInline

Inline admin model for AuthorAlias.

model

alias of reader.models.AuthorAlias

extra = 1
class reader.admin.ArtistAliasInline(parent_model, admin_site)[source]

Bases: django.contrib.admin.options.StackedInline

Inline admin model for ArtistAlias.

model

alias of reader.models.ArtistAlias

extra = 1
class reader.admin.ChapterAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

Admin model for Chapter.

inlines = (<class 'reader.admin.PageInline'>,)
date_hierarchy = 'published'
list_display = ('preview', 'title', 'volume', '_number', 'published', 'modified', 'final')
ordering = ('-modified',)
search_fields = ('title', 'series__title')
list_filter = (('series', <class 'django.contrib.admin.filters.RelatedFieldListFilter'>), ('groups', <class 'MangAdventure.filters.title_filter.<locals>._GenericFilter'>), <class 'MangAdventure.filters.boolean_filter.<locals>._BooleanFilter'>, ('published', <class 'reader.admin.DateFilter'>))
actions = ('toggle_final',)
empty_value_display = 'N/A'
preview(obj)[source]

Get the first image of the chapter as an HTML <img>.

Parameters

obj (Chapter) – A Chapter model instance.

Return type

str

Returns

An <img> tag with the chapter preview.

toggle_final(request, queryset)[source]

Toggle the status of the selected chapters.

Parameters
  • request (HttpRequest) – The original request.

  • queryset (QuerySet) – The original queryset.

class reader.admin.SeriesAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

Admin model for Series.

form

alias of SeriesForm

inlines = (<class 'reader.admin.SeriesAliasInline'>,)
list_display = ('cover_image', 'title', 'created', 'modified', 'completed')
date_hierarchy = 'created'
ordering = ('-modified',)
search_fields = ('title',)
autocomplete_fields = ('categories',)
list_filter = (('authors', <class 'MangAdventure.filters.title_filter.<locals>._GenericFilter'>), ('artists', <class 'MangAdventure.filters.title_filter.<locals>._GenericFilter'>), ('categories', <class 'MangAdventure.filters.title_filter.<locals>._GenericFilter'>), <class 'MangAdventure.filters.boolean_filter.<locals>._BooleanFilter'>)
actions = ('toggle_completed',)
empty_value_display = 'N/A'
cover_image(obj)[source]

Get the cover of the series as an HTML <img>.

Parameters

obj (Series) – A Series model instance.

Return type

str

Returns

An <img> tag with the series cover.

toggle_completed(request, queryset)[source]

Toggle the status of the selected series.

Parameters
  • request (HttpRequest) – The original request.

  • queryset (QuerySet) – The original queryset.

class reader.admin.AuthorAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

Admin model for Author.

inlines = (<class 'reader.admin.AuthorAliasInline'>,)
list_display = ('name', 'aliases')
search_fields = ('name', 'aliases__alias')
aliases(obj)[source]

Get the author’s aliases as a string.

Parameters

obj (Author) – An Author model instance.

Return type

str

Returns

A comma-separated list of aliases.

class reader.admin.ArtistAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

Admin model for Artist.

inlines = (<class 'reader.admin.ArtistAliasInline'>,)
list_display = ('name', 'aliases')
search_fields = ('name', 'aliases__alias')
aliases(obj)[source]

Get the artist’s aliases as a string.

Parameters

obj (Artist) – An Artist model instance.

Return type

str

Returns

A comma-separated list of aliases.

class reader.admin.CategoryAdmin(model, admin_site)[source]

Bases: django.contrib.admin.options.ModelAdmin

Admin model for Category.

exclude = ('id',)
list_display = ('name', 'description')
search_fields = ('name', 'description')
get_readonly_fields(request, obj=None)[source]

Return the fields that cannot be changed.

Once a Category object has been created, its name cannot be altered.

Parameters
  • request (HttpRequest) – The original request.

  • obj (Optional[Category]) – A Category model instance.

Return type

Tuple

Returns

A tuple of readonly fields.

reader.apps module

App configuration.

class reader.apps.ReaderConfig(app_name, app_module)[source]

Bases: django.apps.config.AppConfig

Configuration for the users app.

name = 'reader'

str – The name of the app.

ready()[source]

Register the receivers when the app is ready.

reader.feeds module

class reader.feeds.LibraryRSS[source]

Bases: django.contrib.syndication.views.Feed

RSS feed for the series library.

ttl = 600
description = 'Updates when a new series is added'
author_name = 'MangAdventure'
title = 'Library - MangAdventure'
items()[source]

Get an iterable of the feed’s items.

Return type

Iterable[Series]

Returns

An iterable of Series objects.

item_description(item)[source]

Get the description of the item.

Parameters

item (Series) – A Series object.

Return type

str

Returns

The description of the series.

item_categories(item)[source]

Get the categories of the item.

Parameters

item (Series) – A Series object.

Return type

Iterable[str]

Returns

The names of the series’ categories.

item_pubdate(item)[source]

Get the publication date of the item.

Parameters

item (Series) – A Series object.

Return type

datetime

Returns

The date the series was created.

item_updateddate(item)[source]

Get the update date of the item.

Parameters

item (Series) – A Series object.

Return type

datetime

Returns

The date the series was modified.

item_enclosure_url(item)[source]

Get the enclosure URL of the item.

Parameters

item (Series) – A Series object.

Return type

Optional[str]

Returns

The URL of the series’ cover image, if available.

item_enclosure_length(item)[source]

Get the enclosure length of the item.

Parameters

item (Series) – A Series object.

Return type

Optional[int]

Returns

The size of the series’ cover image, if available.

item_enclosure_mime_type(item)[source]

Get the enclosure type of the item.

Parameters

item (Series) – A Series object.

Return type

Optional[str]

Returns

The mime type of the series’ cover image, if available.

class reader.feeds.LibraryAtom[source]

Bases: reader.feeds.LibraryRSS

Atom feed for the series library.

feed_type

alias of django.utils.feedgenerator.Atom1Feed

subtitle = 'Updates when a new series is added'
class reader.feeds.ReleasesRSS[source]

Bases: django.contrib.syndication.views.Feed

RSS feed for chapter releases.

ttl = 600
author_name = 'MangAdventure'
get_object(request, slug=None)[source]

Get a Series object from the request.

Parameters
  • request (HttpRequest) – The original request.

  • slug (Optional[str]) – The slug of the series.

Return type

Optional[Series]

Returns

The series that has the given slug, or None if the slug is None.

Get the link of the feed’s page.

Parameters

obj (Optional[Series]) – The object of the feed.

Return type

str

Returns

The URL of the series, or the home page.

title(obj)[source]

Get the title of the feed.

Parameters

obj (Optional[Series]) – The object of the feed.

Return type

str

Returns

The title of the series, or Releases.

description(obj)[source]

Get the description of the feed.

Parameters

obj (Optional[Series]) – The object of the feed.

Return type

str

Returns

A description with the title of the series, if available.

items(obj)[source]

Get an iterable of the feed’s items.

Parameters

obj (Optional[Series]) – The object of the feed.

Return type

Iterable[Chapter]

Returns

An iterable of Chapter objects.

item_description(item)[source]

Get the description of the item.

Parameters

item (Chapter) – A Chapter object.

Return type

str

Returns

The Chapter object as a string.

item_pubdate(item)[source]

Get the publication date of the item.

Parameters

item (Chapter) – A Chapter object.

Return type

datetime

Returns

The date the chapter was published.

item_updateddate(item)[source]

Get the update date of the item.

Parameters

item (Chapter) – A Chapter object.

Return type

datetime

Returns

The date the chapter was modified.

class reader.feeds.ReleasesAtom[source]

Bases: reader.feeds.ReleasesRSS

Atom feed for chapter releases.

feed_type

alias of django.utils.feedgenerator.Atom1Feed

subtitle(obj)

Get the description of the feed.

Parameters

obj (Optional[Series]) – The object of the feed.

Return type

str

Returns

A description with the title of the series, if available.

reader.models module

Database models for the reader app.

class reader.models.Author(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A model representing an author.

name

CharField – The name of the author.

__str__()[source]

Return a string representing the object.

Return type

str

Returns

The name of the author.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

objects = <django.db.models.manager.Manager object>
class reader.models.AuthorAlias(*args, **kwargs)[source]

Bases: MangAdventure.models.Alias

A model representing an author’s alias.

author

AliasKeyField – The author this alias belongs to.

alias: MangAdventure.models.AliasField

AliasField – The alias of the author.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

class reader.models.Artist(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A model representing an artist.

name

CharField – The name of the artist.

__str__()[source]

Return a string representing the object.

Return type

str

Returns

The name of the artist.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

objects = <django.db.models.manager.Manager object>
class reader.models.ArtistAlias(*args, **kwargs)[source]

Bases: MangAdventure.models.Alias

A model representing an author’s alias.

artist

AliasKeyField – The artist this alias belongs to.

alias: MangAdventure.models.AliasField

AliasField – The alias of the artist.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

class reader.models.Series(*args, **kwargs)[source]

Bases: django.db.models.base.Model

title

CharField – The title of the series.

slug

SlugField – The unique slug of the series.

description

TextField – The description of the series.

cover

ImageField – The cover image of the series.

completed

BooleanField – The status of the series.

created

DateTimeField – The date the series was created.

modified

DateTimeField – The modification date of the series.

format

CharField – The chapter name format of the series.

get_absolute_url()[source]

Get the absolute URL of the object.

Return type

str

Returns

The URL of reader.views.series().

get_directory()[source]

Get the storage directory of the object.

Return type

PurePath

Returns

A path relative to MEDIA_ROOT.

save(*args, **kwargs)[source]

Save the current instance.

__str__()[source]

Return a string representing the object.

Return type

str

Returns

The title of the series.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

get_next_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=True, **kwargs)
get_next_by_modified(*, field=<django.db.models.fields.DateTimeField: modified>, is_next=True, **kwargs)
get_previous_by_created(*, field=<django.db.models.fields.DateTimeField: created>, is_next=False, **kwargs)
get_previous_by_modified(*, field=<django.db.models.fields.DateTimeField: modified>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
class reader.models.SeriesAlias(*args, **kwargs)[source]

Bases: MangAdventure.models.Alias

A model representing a series’ alias.

series

AliasKeyField – The series this alias belongs to.

alias: MangAdventure.models.AliasField

AliasField – The alias of the series.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

class reader.models.Chapter(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A model representing a chapter.

title

CharField – The title of the chapter.

number

FloatField – The number of the chapter.

volume

PositiveSmallIntegerField – The volume of the chapter.

series

ForeignKey – The series this chapter belongs to.

file

FileField – The file which contains the chapter’s pages.

final

BooleanField – The status of the chapter.

published

DateTimeField – The publication date of the chapter.

modified

DateTimeField – The modification date of the chapter.

save(*args, **kwargs)[source]

Save the current instance.

property next

Chapter – Get the next chapter in the series.

property prev

Chapter – Get the previous chapter in the series.

property twitter_creator

str – Get the Twitter username of the chapter’s first group.

get_absolute_url()[source]

Get the absolute URL of the object.

Return type

str

Returns

The URL of reader.views.chapter_redirect().

get_directory()[source]

Get the storage directory of the object.

Return type

PurePath

Returns

A path relative to MEDIA_ROOT.

unzip()[source]

Unzip the chapter and save its images.

zip()[source]

Generate a zip file containing the pages of this chapter.

Return type

BytesIO

Returns

The file-like object of the generated file.

__str__()[source]

Return a string representing the object.

Return type

str

Returns

The chapter formatted according to the format.

__eq__(other)[source]

Check whether this object is equal to another.

If the other object is a tuple, the objects are equal if the tuple consists of the volume and number of the chapter.

Otherwise, the objects are equal if they have the same base model and their primary keys are equal.

Parameters

other (Any) – Any other object.

Return type

bool

Returns

True if the objects are equal.

__gt__(other)[source]

Check whether this object is greater than another.

If the other object is a tuple, this object is greater if its volume and number is greater than the tuple.

Otherwise, it’s greater if the objects have the same base model and the tuple of its volume and number is greater than the other’s.

Parameters

other (Any) – Any other object.

Return type

bool

Returns

True if this object is greater.

Raises

TypeError – If the other object is neither a tuple, nor a Chapter model.

__lt__(other)[source]

Check whether this object is less than another.

If the other object is a tuple, this object is lesser if its volume and number is less than the tuple.

Otherwise, it’s lesser if the objects have the same base model and the tuple of its volume and number is less than the other’s.

Parameters

other – Any other object.

Returns

True if this object is lesser.

Raises

TypeError – If the other object is neither a tuple, nor a Chapter model.

__hash__()[source]

Return the hash of the object.

Return type

int

Returns

An integer hash value.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

get_next_by_modified(*, field=<django.db.models.fields.DateTimeField: modified>, is_next=True, **kwargs)
get_next_by_published(*, field=<django.db.models.fields.DateTimeField: published>, is_next=True, **kwargs)
get_previous_by_modified(*, field=<django.db.models.fields.DateTimeField: modified>, is_next=False, **kwargs)
get_previous_by_published(*, field=<django.db.models.fields.DateTimeField: published>, is_next=False, **kwargs)
objects = <django.db.models.manager.Manager object>
class reader.models.Page(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A model representing a page.

chapter

ForeignKey – The chapter this page belongs to.

image

ImageField – The image of the page.

number

_PageNumberField – The number of the page.

get_absolute_url()[source]

Get the absolute URL of the object.

Return type

str

Returns

The URL of reader.views.chapter_page().

property preload

QuerySet – Get the pages that will be preloaded.

TODO

Make the number of preloaded pages configurable.

Returns

The three next pages of the chapter.

__str__()[source]

Return a string representing the object.

Return type

str

Returns

The title of the series, the volume, number, title of the chapter, and the file name of the page.

__eq__(other)[source]

Check whether this object is equal to another.

If the other object is a number, the objects are equal if the number of this object is equal to the other object.

Otherwise, the objects are equal if they have the same base model and their chapter and number are respectively equal.

Parameters

other (Any) – Any other object.

Return type

bool

Returns

True if the objects are equal.

__gt__(other)[source]

Check whether this object is greater than another.

If the other object is a number, this object is greater if its number is greater than the other object.

Otherwise, it’s greater if the objects have the same base model and the number of this object is greater than the other’s.

Parameters

other (Any) – Any other object.

Return type

bool

Returns

True if this object is greater.

Raises

TypeError – If the other object is neither a tuple, nor a Page model.

__lt__(other)[source]

Check whether this object is less than another.

If the other object is a number, this object is lesser if its number is less than the other object.

Otherwise, it’s lesser if the objects have the same base model and the number of this object is less than the other’s.

Parameters

other (Any) – Any other object.

Return type

bool

Returns

True if this object is lesser.

Raises

TypeError – If the other object is neither a tuple, nor a Page model.

__hash__()[source]

Return the hash of the object.

Return type

int

Returns

An integer hash value.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

objects = <django.db.models.manager.Manager object>
class reader.models.Category(*args, **kwargs)[source]

Bases: django.db.models.base.Model

A model representing a category.

id

CharField – The category’s ID.

name

CharField – The unique name of the category.

description

TextField – The description of the category.

save(*args, **kwargs)[source]

Save the current instance.

__str__()[source]

Return a string representing the object.

Return type

str

Returns

The name of the category.

exception DoesNotExist

Bases: django.core.exceptions.ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: django.core.exceptions.MultipleObjectsReturned

objects = <django.db.models.manager.Manager object>

reader.receivers module

Signal receivers for the reader app.

reader.receivers.redirect_series(sender, instance, **kwargs)[source]

Receive a signal when a series is about to be saved.

If the series exists and its slug has changed, rename its directory and create a new Redirect.

Parameters
  • sender (Type[Series]) – The model class that sent the signal.

  • instance (Series) – The instance of the model.

reader.receivers.redirect_chapter(sender, instance, **kwargs)[source]

Receive a signal when a series is about to be saved.

If the chapter exists and the slug of the series it belongs to has changed, rename its directory.

Parameters
  • sender (Type[Chapter]) – The model class that sent the signal.

  • instance (Chapter) – The instance of the model.

reader.receivers.remove_page(sender, instance, **kwargs)[source]

Receive a signal when a page is about to be deleted.

Remove the image file of the page.

Parameters
  • sender (Type[Page]) – The model class that sent the signal.

  • instance (Page) – The instance of the model.

reader.urls module

The URLconf of the reader app.

reader.urls.app_name = 'reader'

The URL namespace of the reader app.

reader.urls.urlpatterns = [<URLPattern '' [name='directory']>, <URLPattern '<slug:slug>/' [name='series']>, <URLPattern '<slug:slug>/<int:vol>/<float:num>/' [name='chapter']>, <URLPattern '<slug:slug>/<int:vol>/<float:num>/<int:page>/' [name='page']>, <URLPattern '<slug:slug>.atom' [name='series.atom']>, <URLPattern '<slug:slug>.rss' [name='series.rss']>, <URLPattern '<slug:slug>/<int:vol>/<float:num>.cbz' [name='cbz']>]

The URL namespace of the reader app.

reader.views module

The views of the reader app.

reader.views.directory(request)[source]

View that serves a page which lists all the series.

Parameters

request (HttpRequest) – The original request.

Return type

HttpResponse

Returns

A response with the rendered all_series.html template.

reader.views.series(request, slug)[source]

View that serves the page of a single series.

If the series doesn’t have any published chapters, only staff members will be able to see it.

Parameters
  • request (HttpRequest) – The original request.

  • slug (str) – The slug of the series.

Return type

HttpResponse

Returns

A response with the rendered series.html template.

Raises

Http404 – If there is no series with the specified slug.

reader.views.chapter_page(request, slug, vol, num, page)[source]

View that serves a chapter page.

Parameters
  • request (HttpRequest) – The original request.

  • slug (str) – The slug of the series.

  • vol (int) – The volume of the chapter.

  • num (float) – The number of the chapter.

  • page (int) – The number of the page.

Return type

HttpResponse

Returns

A response with the rendered chapter.html template.

Raises

Http404 – If there is no matching chapter or page.

reader.views.chapter_redirect(request, slug, vol, num)[source]

View that redirects a chapter to its first page.

Parameters
  • request (HttpRequest) – The original request.

  • slug (str) – The slug of the series.

  • vol (int) – The volume of the chapter.

  • num (float) – The number of the chapter.

Return type

HttpResponsePermanentRedirect

Returns

A redirect to chapter_page().

reader.views.chapter_download(request, slug, vol, num)[source]

View that generates a .cbz file from a chapter.

Parameters
  • request (HttpRequest) – The original request.

  • slug (str) – The slug of the chapter’s series.

  • vol (int) – The volume of the chapter.

  • num (float) – The number of the chapter.

Return type

FileResponse

Returns

A response with the .cbz file.