org.cli ======= .. py:module:: org.cli .. autoapi-nested-parse:: Provides commands used to initialize org websites. Attributes ---------- .. autoapisummary:: org.cli.cli Functions --------- .. autoapisummary:: org.cli.import_horw_laws org.cli.restore_page org.cli.add org.cli.import_digirez org.cli.fix_tags org.cli.close_ticket org.cli.fetch org.cli.fix_directory_files org.cli.fix_submission_file_sizes org.cli.migrate_town org.cli.migrate_links_cli org.cli.migrate_publications org.cli.delete_invisible_links org.cli.get_resources_and_forms org.cli.import_reservations org.cli.mtan_statistics org.cli.signing_service_statistics org.cli.ul org.cli.ol org.cli.li org.cli.p org.cli.b org.cli.em org.cli.br org.cli.a org.cli.h org.cli.img org.cli.import_news org.cli.content_to_markup org.cli.import_ogi_section org.cli.import_meetings org.cli.import_commissions org.cli.import_parliamentary_groups org.cli.import_political_business org.cli.import_parliamentarians org.cli.create_commission_memberships org.cli.create_polical_business_participants org.cli.create_parliamentarian_roles org.cli.connect_political_business_meeting_items org.cli.ris_shipping_to_private_address org.cli.ris_set_end_date_for_inactive_parliamentarians org.cli.ris_resolve_parliamentarian_doublette org.cli.ris_rename_imported_participation_types_to_english org.cli.ris_rebuild_political_business_links_to_meetings org.cli.ris_make_imported_files_general_file org.cli.ris_wil_meetings_shorten_audio_links org.cli.fix_custom_event_tags org.cli.subscribe_parliamentarians_to_newsletter org.cli.wil_rename_imported_meeting_files org.cli.list_resources org.cli.check_forms org.cli.migrate_agency org.cli.import_directory_from_ogi_scraper org.cli.import_ris Module Contents --------------- .. py:data:: cli .. py:function:: import_horw_laws(path: pathlib.Path, dry_run: bool) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Import Horw's law collection from an uploaded ZIP snapshot. Defaults to /onegov_town6/horw and PATH=/tmp/horw-laws.zip. Upload a ZIP containing records.json and documents before running. Existing entries are backed up before importing. Changes are committed automatically unless --dry-run is given. .. py:function:: restore_page(snapshot: IO[str], dry_run: bool, skip_missing_files: bool) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Restore a page and included descendants from audit snapshot JSON. Existing pages are overwritten by ID. Children absent from the snapshot are retained. File IDs reconnect existing files; binaries are not restored. .. py:function:: add(group_context: onegov.core.cli.core.GroupContext, name: str, locale: str) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Adds an org with the given name to the database. For example: .. code-block:: bash onegov-org --select '/onegov_org/evilcorp' add "Evilcorp" .. py:function:: import_digirez(accessdb: str, min_date: str, ignore_booking_conflicts: bool) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Imports a Digirez reservation database into onegov.org. Example: .. code-block:: bash onegov-org --select '/orgs/govikon' import-digirez room_booking.mdb .. py:function:: fix_tags(group_context: onegov.core.cli.core.GroupContext, dry_run: bool) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] .. py:function:: close_ticket(ticket: onegov.ticket.Ticket, user: onegov.user.User, request: onegov.org.request.OrgRequest) -> None .. py:function:: fetch(group_context: onegov.core.cli.core.GroupContext, source: collections.abc.Sequence[str], tag: collections.abc.Sequence[str], location: collections.abc.Sequence[str], create_tickets: bool, state_transfers: collections.abc.Sequence[str], published_only: bool, delete_orphaned_tickets: bool, include_imported: bool, include_imported_source: collections.abc.Sequence[str], cross_namespace: bool) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Fetches events from other instances. Only fetches events from the same namespace which have not been imported themselves. Examples .. code-block:: bash onegov-org --select '/veranstaltungen/zug' fetch \ --source menzingen --source steinhausen \ --tag Sport --tag Konzert \ --location Zug To fetch from an entity in another namespace, pass the full ``-`` source schema together with ``--cross-namespace``: .. code-block:: bash onegov-org --select '/onegov_town6/tools_zg' fetch \ --source onegov_town6_without_yubikey-huenenberg \ --published-only \ --cross-namespace Additional parameters: - ``--state-transfers published:withdrawn`` Will update the local event.state from published to withdrawn automatically. If there are any tickets associated with the event, the will be closed automatically. - ``--pusblished-only`` When passing the remote items to the EventCollection, only add events if they are published. - ``--delete-orphaned-tickets`` Delete Tickets, TicketNotes and TicketMessasges if an event gets deleted automatically. - ``--include-imported`` By default skip events that have a source attribute, which means they have been imported. If the flag is set, imported events will be included in the fetch transfer. - ``--include-imported-source ical-`` Includes only those imported events whose source starts with the given prefix, e.g. events imported from an iCal feed. May be passed multiple times. Use separate fetch calls to only apply this to some of the sources. - ``--cross-namespace`` By default a source refers to an entity within the selected app's own namespace (``-``). If the flag is set, a source that already contains a namespace (e.g. ``namespace1-bar``) is used as the remote schema as-is, allowing fetches across namespaces. The following example will close tickets automatically for submitted and published events that were withdrawn on the remote. .. code-block:: bash onegov-event --select '/veranstaltungen/zug' fetch \ --source menzingen --source steinhausen \ --published-only \ --create-tickets \ --state-transfers published:withdrawn \ --state-transfers submitted:withdrawm .. py:function:: fix_directory_files(group_context: onegov.core.cli.core.GroupContext) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Not sure of this doubles the files, but actually the file reference remains, so it shouldn't This command will become obsolete as soon as the type of files in submissions are set correctly with type 'directory'. .. py:function:: fix_submission_file_sizes(group_context: onegov.core.cli.core.GroupContext) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Updates the file size stored in form submission data to reflect the actual stored size (after resizing/compression) rather than the original upload size. `onegov-org --select /onegov_org/* fix-submission-file-sizes` `onegov-org --select /onegov_town6/* fix-submission-file-sizes` .. py:function:: migrate_town(group_context: onegov.core.cli.core.GroupContext) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Migrates the database from an old town to the new town like in the upgrades. .. py:function:: migrate_links_cli(group_context: onegov.core.cli.core.GroupContext, old_uri: str, dry_run: bool) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Migrates url's in pages. Supports domains and full urls. Most of the urls are located in meta and content fields. .. py:function:: migrate_publications(group_context: onegov.core.cli.core.GroupContext, dry_run: bool) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Marks signed files for publication. .. py:function:: delete_invisible_links() -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Deletes all the data associated with a period, including: Example: .. code-block:: bash onegov-org --select /foo/bar delete-invisible-links .. py:function:: get_resources_and_forms(option_file: IO[bytes]) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Get the resources and forms from the option file. .. py:function:: import_reservations(reservation_file: IO[bytes], option_file: IO[bytes], mapping_yaml: IO[bytes], dry_run: bool, masked: bool) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Imports reservations from a Excel file (needs to be .xlsx). Creates no resources or allocations, so the availabilty periods need to be set in the resource settings. .. py:function:: mtan_statistics(group_context: onegov.core.cli.core.GroupContext, year: int, month: int) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Generate mTAN SMS statistics for the given year and month. .. py:function:: signing_service_statistics(group_context: onegov.core.cli.core.GroupContext, year: int, month: int) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Generate mTAN SMS statistics for the given year and month. .. py:function:: ul(inner: str) -> str .. py:function:: ol(inner: str) -> str .. py:function:: li(inner: str) -> str .. py:function:: p(inner: str) -> str .. py:function:: b(inner: str) -> str .. py:function:: em(inner: str) -> str .. py:function:: br() -> str .. py:function:: a(href: str, text: str) -> str .. py:function:: h(level: int, text: str) -> str .. py:function:: img(src: str, alt: str) -> str .. py:function:: import_news(path: str, start_date: datetime.datetime | None, end_date: datetime.datetime | None, overwrite_content: bool, dry_run: bool, local: bool) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Imports news from archive of json files Example: .. code-block:: bash onegov-org --select '/foo/bar' import-news /path/to/news .. py:function:: content_to_markup(element: dict[str, Any]) -> str .. py:function:: import_ogi_section(path: str, dry_run: bool, section: str) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] .. py:function:: import_meetings(path: str, dry_run: bool) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Import OGI meetings JSON, updating records by source ID. .. py:function:: import_commissions(path: str, dry_run: bool) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Import OGI commissions JSON, updating records by source ID. .. py:function:: import_parliamentary_groups(path: str, dry_run: bool) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Import OGI parliamentary_groups JSON, updating records by source ID. .. py:function:: import_political_business(path: str, dry_run: bool) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Import OGI political-business JSON, updating records by source ID. .. py:function:: import_parliamentarians(path: str, dry_run: bool) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Import OGI parliamentarians JSON, updating records by source ID. .. py:function:: create_commission_memberships() -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Connect imported RIS records; safe to repeat. .. py:function:: create_polical_business_participants() -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Connect imported RIS records; safe to repeat. .. py:function:: create_parliamentarian_roles() -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Connect imported RIS records; safe to repeat. .. py:function:: connect_political_business_meeting_items() -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Connect imported RIS records; safe to repeat. .. py:function:: ris_shipping_to_private_address() -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Sets the RIS shipping address to the private address onegov-org --select /foo/bar ris-shipping-to-private-address .. py:function:: ris_set_end_date_for_inactive_parliamentarians() -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Sets the end date for inactive parliamentarians onegov-org --select /foo/bar ris-set-end-date-for-inactive-parliamentarians .. py:function:: ris_resolve_parliamentarian_doublette() -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] ogc-2394 replace participants reference for business and delete parliamentarian (id_1) .. py:function:: ris_rename_imported_participation_types_to_english() -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Renames imported participation types to English onegov-org --select /foo/bar ris-rename-imported-participation-types-to-english .. py:function:: ris_rebuild_political_business_links_to_meetings() -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Rebuilds political business links to meetings. .. py:function:: ris_make_imported_files_general_file() -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] onegov-org --select /onegov_town6/wil ris-make-imported-files-general-file .. py:function:: ris_wil_meetings_shorten_audio_links() -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] .. py:function:: fix_custom_event_tags(auto: bool, dry_run: bool) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] .. py:function:: subscribe_parliamentarians_to_newsletter() -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] onegov-org --select /foo/bar subscribe-parliamentarians-to-newsletter .. py:function:: wil_rename_imported_meeting_files() -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] onegov-org --select /foo/bar wil-rename-imported-meeting-files .. py:function:: list_resources() -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Lists all resources of the selected org ordered by type onegov-org --select '/foo/bar' list-resources .. py:function:: check_forms() -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Check stored formcode for parseability. Scans form definitions, form submissions and directory structures stored in the database and attempts to parse their formcode using `onegov.form.parse_formcode`. This helps detect changes to the parser that would cause existing formcode to fail when loading (`enable_edit_checks=False`). NOTE: Currently resource form definition is option input on the form. However this causes an error when parsing the formcode Usage: onegov-org --select /onegov_town6/* check-formcode .. py:function:: migrate_agency(group_context: onegov.core.cli.core.GroupContext) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Migrates the database from an old agency to the new agency like in the upgrades. .. py:function:: import_directory_from_ogi_scraper(file: str, dry_run: bool) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Imports a directory from a self-describing ogi-scraper JSON export. The file carries both the directory spec and its entries:: { "directory": { "title": "Vereine", "structure": "Name *= ___\\n...", # onegov formcode "configuration": { ... }, # DirectoryConfiguration "fields": { "": "", ... } }, "entries": [ { ...record... }, ... ] } The scraper is the source that knows the target shape, so this command needs no per-directory knowledge. The directory is created if missing and entries are matched by name and updated in place, so the import is idempotent. Example: onegov-town6 --select /onegov_town6/malters \\ import-from-ogi-scraper vereinsliste.json .. py:function:: import_ris(path: pathlib.Path, dry_run: bool) -> collections.abc.Callable[[onegov.org.request.OrgRequest, onegov.org.app.OrgApp], None] Import a complete OGI RIS download, including local documents. Runs the same imports as the individual RIS commands, in dependency order, committing each stage and batches of 100 businesses. Repeat the command to resume. Run org upgrades first. This command performs no HTTP requests.