groups package

The app that handles groups.

Subpackages

Submodules

groups.admin module

Admin models for the groups app.

class groups.admin.MemberRoleInline(parent_model, admin_site)[source]

Bases: StackedInline

Inline admin model for Role.

model

alias of Role

extra = 1
get_formset(request, obj, **kwargs)[source]

Return a BaseInlineFormSet class for use in admin add/change views.

Parameters:
Return type:

Type[BaseInlineFormSet]

class groups.admin.MemberAdmin(model, admin_site)[source]

Bases: ModelAdmin

Admin model for Member.

inlines = (<class 'groups.admin.MemberRoleInline'>,)
ordering = [Lower(F(name))]
sortable_by = ('name',)
list_display = ('name', '_twitter', 'discord', 'irc', '_reddit')
search_fields = ('name', 'twitter', 'discord', 'irc', 'reddit')
list_filter = (('roles__group__name', <class 'MangAdventure.filters.title_filter.<locals>._GenericFilter'>), ('roles__role', <class 'MangAdventure.filters.title_filter.<locals>._GenericFilter'>))
class groups.admin.GroupAdmin(model, admin_site)[source]

Bases: ModelAdmin

Admin model for Group.

exclude = ('id',)
ordering = [Lower(F(name))]
sortable_by = ('name',)
list_display = ('image', 'name', '_website', 'manager', 'description')
search_fields = ('name', 'website', 'description')
list_filter = (('manager', <class 'MangAdventure.filters.title_filter.<locals>._GenericFilter'>),)
empty_value_display = 'N/A'
get_form(request, obj=None, change=False, **kwargs)[source]

Return a Form class for use in the admin add view. This is used by add_view and change_view.

Parameters:
Return type:

Type[ModelForm]

image(obj)[source]

Get the logo of the group as an HTML <img>.

Parameters:

obj (Group) – A Group model instance.

Return type:

str

Returns:

An <img> tag with the group’s logo.

has_change_permission(request, obj=None)[source]

Return True if editing the object is permitted.

Superusers can edit any group.
Scanlators can only edit groups they manage.
Parameters:
Return type:

bool

Returns:

True if the user is allowed to edit the group.

has_delete_permission(request, obj=None)[source]

Return True if deleting the object is permitted.

Superusers can delete any group.
Scanlators can only delete groups they manage.
Parameters:
Return type:

bool

Returns:

True if the user is allowed to delete the group.

groups.api module

API viewsets for the groups app.

class groups.api.GroupViewSet(**kwargs)[source]

Bases: CORSMixin, ModelViewSet

API endpoints for groups.

  • list: List groups.

  • read: View a certain group.

  • create: Create a new group.

  • patch: Edit the given group.

  • delete: Delete the given group.

schema

OpenAPISchema – Custom OpenAPI schema class.

queryset = QuerySet
serializer_class

alias of GroupSerializer

parser_classes = (<class 'rest_framework.parsers.MultiPartParser'>,)
http_method_names = ['get', 'post', 'patch', 'delete', 'head', 'options']
basename = None
description = None
detail = None
dispatch(request, *args, **kwargs)

.dispatch() is pretty much the same as Django’s regular dispatch, but with extra hooks for startup, finalize, and exception handling.

name = None
suffix = None
class groups.api.MemberViewSet(**kwargs)[source]

Bases: CORSMixin, ModelViewSet

API endpoints for members.

  • list: List members.

  • read: View a certain member.

  • create: Create a new member.

  • patch: Edit the given member.

  • delete: Delete the given member.

schema

OpenAPISchema – Custom OpenAPI schema class.

queryset = QuerySet
serializer_class

alias of MemberSerializer

parser_classes = (<class 'rest_framework.parsers.MultiPartParser'>,)
http_method_names = ['get', 'post', 'patch', 'delete', 'head', 'options']
basename = None
description = None
detail = None
dispatch(request, *args, **kwargs)

.dispatch() is pretty much the same as Django’s regular dispatch, but with extra hooks for startup, finalize, and exception handling.

name = None
suffix = None

groups.apps module

App configuration.

class groups.apps.GroupsConfig(app_name, app_module)[source]

Bases: AppConfig

Configuration for the groups app.

name = 'groups'

str – The name of the app.

groups.feeds module

RSS and Atom feeds for the groups app.

class groups.feeds.GroupRSS[source]

Bases: Feed

RSS feed for a group’s releases.

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

Get a Group object from the request.

Parameters:
  • request (HttpRequest) – The original request.

  • g_id (int) – The id of the group.

Return type:

Group

Returns:

The group that has the given id.

Get the link of the feed’s page.

Parameters:

obj (Group) – The object of the feed.

Return type:

str

Returns:

The URL of the group.

title(obj)[source]

Get the title of the feed.

Parameters:

obj (Group) – The object of the feed.

Return type:

str

Returns:

The name of the group.

description(obj)[source]

Get the description of the feed.

Parameters:

obj (Group) – The object of the feed.

Return type:

str

Returns:

A description with the name of the group.

items(obj)[source]

Get an iterable of the feed’s items.

Parameters:

obj (Group) – 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.

__call__(request, *args, **kwargs)

Call self as a function.

class groups.feeds.GroupAtom[source]

Bases: GroupRSS

Atom feed for a group’s releases.

feed_type

alias of Atom1Feed

subtitle(obj)

Get the description of the feed.

Parameters:

obj (Group) – The object of the feed.

Return type:

str

Returns:

A description with the name of the group.

__call__(request, *args, **kwargs)

Call self as a function.

groups.models module

Database models for the groups app.

class groups.models.Group(*args, **kwargs)[source]

Bases: Model

A model representing a group.

name

CharField – The group’s name.

website

URLField – The group’s website.

description

TextField – The group’s description.

email

EmailField – The group’s e-mail address.

discord

DiscordURLField – The Discord server URL of the group.

twitter

TwitterField – The Twitter username of the group.

irc

CharField – The group’s IRC.

reddit

RedditField – The Reddit username or subreddit name of the group.

ImageField – The group’s logo.

manager

ForeignKey – The person who manages this group.

get_absolute_url()[source]

Get the absolute URL of the object.

Return type:

str

Returns:

The URL of groups.views.group().

get_directory()[source]

Get the storage directory of the object.

Return type:

PurePath

Returns:

A path relative to MEDIA_ROOT.

__str__()[source]

Return a string representing the object.

Return type:

str

Returns:

The name of the group.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

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

Bases: Model

A model representing a member.

name

CharField – The name of the member.

twitter

TwitterField – The member’s Twitter username.

discord

DiscordNameField – The member’s Discord username and discriminator.

irc

CharField – The member’s IRC username.

reddit

RedditField – The member’s Reddit username.

get_roles(group)[source]

Get the roles of the member in the given group.

Parameters:

group (Group) – A group instance.

Return type:

str

Returns:

A comma-separated list of roles.

__str__()[source]

Return a string representing the object.

Return type:

str

Returns:

The name of the member.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

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

Bases: Model

A model representing a role.

class Choices(value)[source]

Bases: TextChoices

The possible role choices.

LD = 'LD'
TL = 'TL'
PR = 'PR'
CL = 'CL'
RD = 'RD'
TS = 'TS'
RP = 'RP'
QC = 'QC'
member

ForeignKey – The member this role belongs to.

group

ForeignKey – The group this role belongs to.

role

CharField – The value of the role.

__str__()[source]

Return a string representing the object.

Return type:

str

Returns:

The name and group of the role.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

get_role_display(*, field=<django.db.models.CharField: role>)
objects = <django.db.models.manager.Manager object>

groups.serializers module

Model serializers for the groups app.

class groups.serializers.GroupSerializer(*args, **kwargs)[source]

Bases: ModelSerializer

Serializer for groups.

create(validated_data)[source]

Create a new Group instance.

Parameters:

validated_data (Dict) –

Return type:

Group

class Meta[source]

Bases: object

model

alias of Group

fields = ('id', 'name', 'website', 'description', 'email', 'discord', 'twitter', 'reddit', 'irc', 'logo', 'members')
extra_kwargs = {'id': {'help_text': 'The unique ID of the group.', 'min_value': 1, 'read_only': True}}
class groups.serializers.MemberSerializer(*args, **kwargs)[source]

Bases: ModelSerializer

Serializer for members.

class Meta[source]

Bases: object

model

alias of Member

fields = ('id', 'name', 'twitter', 'discord', 'irc', 'reddit', 'groups')

groups.sitemaps module

Sitemaps for the groups app.

class groups.sitemaps.GroupSitemap[source]

Bases: Sitemap

Sitemap for groups.

priority = 0.4

float – The priority of the sitemap.

items()[source]

Get an iterable of the sitemap’s items.

Return type:

Iterable[Group]

Returns:

An iterable of Group objects.

groups.urls module

The URLconf of the groups app.

groups.urls.app_name = 'groups'

The URL namespace of the groups app.

groups.urls.urlpatterns = [<URLPattern '' [name='all_groups']>, <URLPattern '<int:g_id>/' [name='group']>, <URLPattern '<int:g_id>.atom' [name='group.atom']>, <URLPattern '<int:g_id>.rss' [name='group.rss']>, <URLPattern '<section>-sitemap.xml' [name='sitemap.xml']>]

The URL patterns of the groups app.

groups.views module

The views of the users app.

groups.views.all_groups(request)[source]

View that serves a page with all the groups.

Parameters:

request (HttpRequest) – The original request.

Return type:

HttpResponse

Returns:

A response with the rendered all_groups.html template.

groups.views.group(request, g_id)[source]

View that serves a single group’s page.

Parameters:
  • request (HttpRequest) – The original request.

  • g_id (int) – The ID of the group.

Return type:

HttpResponse

Returns:

A response with the rendered group.html template.

Raises:

Http404 – If the group does not exist.