API

Apps

Meta information about the Integreat CMS API app

class integreat_cms.api.apps.ApiConfig(app_name, app_module)[source]

Bases: AppConfig

Configuration parameters for the API app

__init__(app_name, app_module)[source]
classmethod create(entry)[source]

Factory that creates an app config from an entry in INSTALLED_APPS.

default_auto_field[source]
get_model(model_name, require_ready=True)[source]

Return the model with the given case-insensitive model_name.

Raise LookupError if no model exists with this name.

get_models(include_auto_created=False, include_swapped=False)[source]

Return an iterable of models.

By default, the following models aren’t included:

  • auto-created models for many-to-many relations without an explicit intermediate table,

  • models that have been swapped out.

Set the corresponding keyword argument to True to include such models. Keyword arguments aren’t documented; they’re a private API.

import_models()[source]
name: Final[str] = 'integreat_cms.api'[source]

Full Python path to the application

ready()[source]

Override this method in subclasses to run code when Django starts.

verbose_name: Final[Promise] = 'API'[source]

Human-readable name for the application

Decorators

This module includes functions that are used as decorators in the API endpoints.

integreat_cms.api.decorators.feedback_handler(func: Callable) Callable[source]

Decorator definition for feedback API functions and methods

Parameters:

func (Callable) – decorated function

Returns:

The decorated feedback view function

Return type:

Callable

integreat_cms.api.decorators.json_response(function: Callable) Callable[source]

This decorator can be used to catch Http404 exceptions and convert them to a JsonResponse. Without this decorator, the exceptions would be converted to HttpResponse.

Parameters:

function (Callable) – The view function which should always return JSON

Returns:

The decorated function

Return type:

Callable

integreat_cms.api.decorators.matomo_tracking(func: Callable) Callable[source]

This decorator is supposed to be applied to API content endpoints. It will track the request in Matomo. The request to the Matomo API is executed asynchronously in its own thread to not block the Integreat CMS API request.

Only the URL and the User Agent will be sent to Matomo.

Parameters:

func (Callable) – decorated function

Returns:

The decorated feedback view function

Return type:

Callable

Urls

Expansion of API-Endpoints for the CMS

integreat_cms.api.urls.app_name: Final = 'api'[source]

The namespace for this URL config (see django.urls.ResolverMatch.app_name)

integreat_cms.api.urls.urlpatterns: list[URLPattern] = [<URLResolver <URLPattern list> (None:None) 'api/v3/regions/'>, <URLPattern 'api/v3/webhook/zammad/' [name='zammad_webhook']>, <URLResolver <URLPattern list> (None:None) 'wp-json/extensions/v3/sites/'>, <URLResolver <URLPattern list> (None:None) 'api/v3/social/'>, <URLResolver <URLPattern list> (None:None) 'api/v3/<slug:region_slug>/'>, <URLResolver <URLPattern list> (None:None) '<slug:region_slug>/'>][source]

The url patterns of this module (see URL dispatcher)

[
    <URLResolver <URLPattern list> (None:None) 'api/v3/regions/'>,
    <URLPattern 'api/v3/webhook/zammad/' [name='zammad_webhook']>,
    <URLResolver <URLPattern list> (None:None) 'wp-json/extensions/v3/sites/'>,
    <URLResolver <URLPattern list> (None:None) 'api/v3/social/'>,
    <URLResolver <URLPattern list> (None:None) 'api/v3/<slug:region_slug>/'>,
    <URLResolver <URLPattern list> (None:None) '<slug:region_slug>/'>,
]