Application reference

Roles and permissions

REST framework permission helpers for role-based access.

class accounts.permissions.IsEditor[source]

Bases: BasePermission

Allow access only to editors.

has_permission(request, view)[source]

Return whether the request user may access this editor-only view.

class accounts.permissions.IsEditorOrJournalist[source]

Bases: BasePermission

Allow access to editors and journalists, including superusers.

has_permission(request, view)[source]

Check whether the request user may edit or submit content.

class accounts.permissions.IsInternalAPIRequest[source]

Bases: BasePermission

Restrict endpoint access to callers with the internal API key.

has_permission(request, view)[source]

Check whether the request includes the internal API key.

class accounts.permissions.IsJournalist[source]

Bases: BasePermission

Allow access only to journalists.

has_permission(request, view)[source]

Check whether the request user may access this view.

class accounts.permissions.IsReader[source]

Bases: BasePermission

Allow access only to readers.

has_permission(request, view)[source]

Return whether the request user may access this reader-only view.

accounts.permissions.user_has_role(user, role)[source]

Check a user’s role, matching group membership, or superuser status.

Approval services

Service helpers for article approval side effects.

articles.services.approve_article(article, editor)[source]

Save approval, log it internally, and notify subscribers.

The approval is persisted before either integration runs. Integration errors propagate to the caller without reverting the approval.

articles.services.article_subscribers(article)[source]

Return active readers subscribed to the author or publisher.

articles.services.log_approved_article(article)[source]

Post approval metadata to the configured internal API endpoint.

articles.services.notify_subscribers(article)[source]

Email subscribers and return the number of delivered messages.

Data models

Database models for articles, newsletters, and approval logs.

class articles.models.ApprovedArticleLog(*args, **kwargs)[source]

Bases: Model

An audit record for an approved article.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

class articles.models.Article(*args, **kwargs)[source]

Bases: Model

A journalist’s news article, optionally tied to a publisher.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

clean()[source]

Validate that an assigned article author is a journalist.

class articles.models.Newsletter(*args, **kwargs)[source]

Bases: Model

A curated newsletter containing approved articles.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

clean()[source]

Validate that an assigned newsletter author is a journalist.

Database models for publishers and affiliations.

class publications.models.Publisher(*args, **kwargs)[source]

Bases: Model

Group affiliated editors, journalists, and articles.

exception DoesNotExist

Bases: ObjectDoesNotExist

exception MultipleObjectsReturned

Bases: MultipleObjectsReturned

clean()[source]

Validate roles for affiliated editors and journalists.

Publisher workflows

Website views for creating and managing publishers.

publications.views.can_manage_publisher(user, publisher)[source]

Return True if the user is an editor affiliated with the publisher.

Superusers may manage every publisher.

publications.views.publisher_create_page(request)[source]

Let an editor create a publisher and join as an editor.

publications.views.publisher_delete_page(request, pk)[source]

Delete a publisher unless articles still reference it.

publications.views.publisher_edit_page(request, pk)[source]

Edit a publisher and its affiliated editors and journalists.

publications.views.publisher_list(request)[source]

List publishers; editors also see the management actions.