News Managers
Abstract News Manager
- class integreat_cms.news_managers.abstract_news_manager.AbstractNewsManager[source]
Bases:
ABC- collect_news_items(region_slug: str, language_slug: str, _channel: str) list[NewsItem][source]
Returns news items imported from the source
- find_post(region: Region, language: Language, news_raw_id: str) NewsItem[source]
Find and return a news item which matches the given ID
- get_cached_news_items(language_slug: str) list[NewsItem][source]
Return the cached news items for the given language.
If the cache key does not exist yet (i.e. the cache has not been warmed up), the news items are imported from the source on demand and the cache is populated before returning.
- get_single_news(request: HttpRequest, region: Region, language: Language, news_id: str) JsonResponse[source]
Returns a news item that is imported from the source and matches the id
- abstractmethod import_news_items() None[source]
Imports news items from the source
To be implemented in the inheriting model
- Return type:
None
Amalnews Manager
- class integreat_cms.news_managers.amalnews_manager.AmalnewsManager[source]
Bases:
AbstractNewsManager
Pushnews Manager
- class integreat_cms.news_managers.pushnews_manager.PushnewsManager[source]
Bases:
AbstractNewsManager- collect_news_items(region_slug: str, language_slug: str, channel: str) list[NewsItem][source]
Returns push notification news for common news endpoint
- collect_news_items_for_fcm(region_slug: str, language_slug: str, channel: str) list[dict[str, Any]][source]
Returns push notification news for fcm endpoint
- get_single_news(request: HttpRequest, region: Region, language: Language, news_id: str) JsonResponse[source]
Returns a push notification that matches the id
- import_news_items() None[source]
Push notifications live in our own database, so there is nothing to import.
- Return type:
None
- social_media_headers(request: HttpRequest, region: Region, language: Language, news_raw_id: str) HttpResponse[source]
Tries rendering the social media headers for a news page in a specified region and language
- transform_notification(pnt: PushNotificationTranslation) NewsItem[source]
Function to create a JSON from a single push notification translation Object.
- Parameters:
pnt (PushNotificationTranslation) – A push notification translation
- Returns:
data necessary for API
- Return type:
- transform_notification_for_fcm(pnt: PushNotificationTranslation) dict[str, Any][source]
Function to create a JSON from a single push notification translation Object for fcm endpoint
The endpoint fcm/ requires timestamp and id in int.
- Parameters:
pnt (PushNotificationTranslation) – A push notification translation
- Returns:
data necessary for API
- Return type:
Registry
Registry of the available news source managers.
Tunews Manager
- class integreat_cms.news_managers.tunews_manager.TunewsManager[source]
Bases:
AbstractNewsManager