Skip to content
Snippets Groups Projects
Select Git revision
  • 163e56441ec1924d26e9ec26e3c3435184ad15cc
  • test default protected
  • master protected
  • niki_edit_branch
  • feat/custom-css
  • feat/redesign-improvements-10
  • feat/redesign-improvements-8
  • feat/redesign-fixes-3
  • feat/pirstan-changes
  • feat/separate-import-thread
  • feat/dary-improvements
  • features/add-pdf-page
  • features/add-typed-table
  • features/fix-broken-calendar-categories
  • features/add-embed-to-articles
  • features/create-mastodon-feed-block
  • features/add-custom-numbering-for-candidates
  • features/add-timeline
  • features/create-wordcloud-from-article-page
  • features/create-collapsible-extra-legal-info
  • features/extend-hero-banner
21 results

octopus_people_import.py

Blame
  • user avatar
    Alexa Valentová authored
    bba02fb8
    History
    octopus_people_import.py 2.19 KiB
    from django.core.management.base import BaseCommand
    from wagtail.models.media import Collection
    
    from district.models import DistrictManualOctopusPersonPage, DistrictPeoplePage
    from district.tasks import (
        import_manual_person,
        import_people_from_group,
        import_people_from_team,
    )
    
    
    class Command(BaseCommand):
        help = """Importuje Osoby z Chobotnice."""
    
        def handle(self, *args, **options):
            for people_page in DistrictPeoplePage.objects.all():
                for group in people_page.get_syncable_octopus_groups():
                    if not hasattr(people_page.root_page, "image_collection_id"):
                        # FIXME: This should not be UniwebHomePage, but sometimes it is.
                        continue
    
                    collection_id = people_page.root_page.image_collection_id
    
                    if collection_id is None:
                        collection_id = Collection.objects.first().id
    
                    import_people_from_group.delay(
                        people_page.id,
                        collection_id,
                        group["shortcut"],
                        group["title"],
                    )
    
            for people_page in DistrictPeoplePage.objects.all():
                for team in people_page.get_syncable_octopus_teams():
                    if not hasattr(people_page.root_page, "image_collection_id"):
                        # FIXME: This should not be UniwebHomePage, but sometimes it is.
                        continue
    
                    collection_id = people_page.root_page.image_collection_id
    
                    if collection_id is None:
                        collection_id = Collection.objects.first().id
    
                    import_people_from_team.delay(
                        people_page.id,
                        collection_id,
                        team["shortcut"],
                        team["title"],
                        team["roles"],
                    )
    
            for person_page in DistrictManualOctopusPersonPage.objects.all():
                import_manual_person.delay(
                    person_page.id,
                    (
                        person_page.root_page.image_collection_id
                        if hasattr(person_page.root_page, "image_collection_id")
                        else 0
                    ),
                )