Commands

Duplicate Pages

class integreat_cms.core.management.commands.duplicate_pages.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Bases: DebugCommand

Management command to duplicate all pages of a region

add_arguments(parser: CommandParser) None[source]

Define the arguments of this command

Parameters:

parser (CommandParser) – The argument parser

Return type:

None

handle(*args: Any, region_slug: str, **options: Any) None[source]

Try to run the command

Parameters:
  • *args (Any) – The supplied arguments

  • region_slug (str) – The slug of the given region

  • **options (Any) – The supplied keyword options

Raises:

CommandError – When the input is invalid

Return type:

None

integreat_cms.core.management.commands.duplicate_pages.duplicate_page(old_page: Page, new_parent: Page | None = None) Page[source]

Duplicate a page and insert it as child of the given new parent

Parameters:
  • old_page (Page) – The old page which should be copied

  • new_parent (Page | None) – The new parent where the duplicate should reside

Returns:

The copied page

Return type:

Page

integreat_cms.core.management.commands.duplicate_pages.duplicate_pages(region: Region, old_parent: Page | None = None, new_parent: Page | None = None) None[source]

Duplicate pages recursively for the given region

Parameters:
  • region (Region) – The given region

  • old_parent (Page | None) – The old parent page which descendants should be copied

  • new_parent (Page | None) – The new parent where the duplicates should reside

Return type:

None

Find Large Files

class integreat_cms.core.management.commands.find_large_files.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Bases: LogCommand

Management command to find large media files

add_arguments(parser: CommandParser) None[source]

Define the arguments of this command

Parameters:

parser (CommandParser) – The argument parser

Return type:

None

handle(*args: Any, limit: int, threshold: int, **options: Any) None[source]

Try to run the command

Parameters:
  • *args (Any) – The supplied arguments

  • limit (int) – Limit the result to this number

  • threshold (int) – Only show the files larger than this value

  • **options (Any) – The supplied keyword options

Raises:

CommandError – When the input is invalid

Return type:

None

Find Missing Versions

class integreat_cms.core.management.commands.find_missing_versions.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Bases: LogCommand

Management command to find missing versions

add_arguments(parser: CommandParser) None[source]

Define the arguments of this command

Parameters:

parser (CommandParser) – The argument parser

Return type:

None

handle(*args: Any, model: ModelBase, **options: Any) None[source]

Try to run the command

Parameters:
  • *args (Any) – The supplied arguments

  • model (ModelBase) – The model to check

  • **options (Any) – The supplied keyword options

Return type:

None

integreat_cms.core.management.commands.find_missing_versions.MODELS: dict[str, ModelBase] = {'event': <class 'integreat_cms.cms.models.events.event_translation.EventTranslation'>, 'page': <class 'integreat_cms.cms.models.pages.page_translation.PageTranslation'>, 'poi': <class 'integreat_cms.cms.models.pois.poi_translation.POITranslation'>}[source]

The possible model choices

{
    'event': <class 'integreat_cms.cms.models.events.event_translation.EventTranslation'>,
    'page': <class 'integreat_cms.cms.models.pages.page_translation.PageTranslation'>,
    'poi': <class 'integreat_cms.cms.models.pois.poi_translation.POITranslation'>,
}
integreat_cms.core.management.commands.find_missing_versions.get_model(model_str: str) ModelBase[source]

Convert a model string to a translation model class

Parameters:

model_str (str) – The model string

Returns:

The model class

Raises:

ArgumentTypeError – When the input is invalid

Return type:

ModelBase

Hix Bulk

class integreat_cms.core.management.commands.hix_bulk.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Bases: LogCommand

Command to calculate the hix values for public page translations which do not currently have a score

add_arguments(parser: CommandParser) None[source]

Define the arguments of this command

Parameters:

parser (CommandParser) – The argument parser

Return type:

None

handle(*args: Any, region_slugs: list[str], **options: Any) None[source]

Try to run the command

Parameters:
  • *args (Any) – The supplied arguments

  • region_slugs (list[str]) – The slugs of the given regions

  • **options (Any) – The supplied keyword options

Return type:

None

integreat_cms.core.management.commands.hix_bulk.calculate_hix_for_region(region: Region) None[source]

Calculates the hix score for all missing pages in the region. Assumes that hix is globally enabled and enabled for the region

Parameters:

region (Region) – The region

Return type:

None

Repair Tree

class integreat_cms.core.management.commands.repair_tree.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Bases: LogCommand

Management command to repair a broken Treebeard page tree

add_arguments(parser: CommandParser) None[source]

Define the arguments of this command

Parameters:

parser (CommandParser) – The argument parser

Return type:

None

calculate_left_right_values(tree_node: Page, left: int, commit: bool) int[source]

Recursively calculate the left and right value for a given node and its children.

Parameters:
  • tree_node (Page) – A node of a MPTT tree

  • left (int) – The new left value of the node

  • commit (bool) – Whether changes should be written to the database

Returns:

The new right value of the node

Return type:

int

check_for_orphans(tree_id: int) None[source]

Check whether orphans exist (pages with the same tree_id, but its ancestors are in another tree)

Parameters:

tree_id (int) – The current tree id

Return type:

None

check_tree_fields(tree_node: Page, left: int, right: int) bool[source]

Check whether the tree fields are correct

Parameters:
  • tree_node (Page) – The current node

  • left (int) – The new left value of the node

  • right (int) – The new right value of the node

Returns:

Whether the tree fields of the node are valid

Return type:

bool

handle(*args: Any, page_id: int, commit: bool, **options: Any) None[source]

Try to run the command

Parameters:
  • *args (Any) – The supplied arguments

  • page_id (int) – The page ID (node) of a broken tree

  • commit (bool) – Whether changes should be written to the database

  • **options (Any) – The supplied keyword options

Raises:

CommandError – When the input is invalid

Return type:

None

Reset Mt Budget

class integreat_cms.core.management.commands.reset_mt_budget.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Bases: LogCommand

Management command to reset MT budget

add_arguments(parser: CommandParser) None[source]

Define the arguments of this command

Parameters:

parser (CommandParser) – The argument parser

Return type:

None

handle(*args: Any, force: bool, **options: Any) None[source]

Try to run the command

Parameters:
  • args (Any) –

  • force (bool) –

  • options (Any) –

Return type:

None

Send Push Notifications

class integreat_cms.core.management.commands.send_push_notifications.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Bases: LogCommand

Management command to send timed push notifications

handle(*args: Any, **options: Any) None[source]

Try to run the command

Parameters:
  • *args (Any) – The supplied arguments

  • **options (Any) – The supplied keyword options

Return type:

None

send_push_notification(counter: int, total: int, push_notification: PushNotification) None[source]

Sends a push notification

Parameters:
  • counter (int) – The current counter

  • total (int) – How many push notifications are scheduled for this slot

  • push_notification (PushNotification) – The push notification object

Return type:

None

SUMM.AI Bulk

class integreat_cms.core.management.commands.summ_ai_bulk.Command(stdout=None, stderr=None, no_color=False, force_color=False)[source]

Bases: LogCommand

Management command to create an initial translation for Easy German via SUMM.AI

add_arguments(parser: CommandParser) None[source]

Define the arguments of this command

Parameters:

parser (CommandParser) – The argument parser

Return type:

None

handle(*args: Any, region_slug: str, username: str, initial: bool, **options: Any) None[source]

Try to run the command

Parameters:
  • *args (Any) – The supplied arguments

  • region_slug (str) – The slug of the given region

  • username (str) – The username of the creator

  • initial (bool) – Whether existing translations should not be updated

  • **options (Any) – The supplied keyword options

Return type:

None

integreat_cms.core.management.commands.summ_ai_bulk.summ_ai_bulk(region: Region, username: str, initial: bool = True) None[source]

Translate a complete region into Easy German

Parameters:
  • region (Region) – The current region

  • username (str) – The username of the creator of the translation objects

  • initial (bool) – Whether existing translations should not be updated

Return type:

None