def remove_jury_member_pages(apps, schema_editor):
    HomePage = apps.get_model('home.HomePage')
    Image = get_image_model(apps)
    Collection = apps.get_model('wagtailcore.Collection')
    IndexPage = apps.get_model('cpm_generic.IndexPage')
    JuryMemberPage = apps.get_model("results.JuryMemberPage")

    index_page_ct = get_content_type(apps, 'cpm_generic', 'indexpage')
    jury_member_page_ct = get_content_type(apps, 'results', 'jurymemberpage')
    collection_id = Collection.objects.filter(depth=1)[0]

    homepage = HomePage.objects.get(slug='home')
    juryindex_page = IndexPage.objects.get(slug=_get_juryindex_kw()['slug'])

    for item in _get_data():
        photo = Image.objects.get(title=item['title'],
                                  collection=collection_id)
        photo.delete()

        remove_subpage(parent=juryindex_page,
                       model=JuryMemberPage,
                       content_type=jury_member_page_ct,
                       **_get_jurymember_kw(item))

    remove_subpage(parent=homepage,
                   model=IndexPage,
                   content_type=index_page_ct,
                   **_get_juryindex_kw())
def remove_jury_member_pages(apps, schema_editor):
    HomePage = apps.get_model('home.HomePage')
    Image = get_image_model(apps)
    Collection = apps.get_model('wagtailcore.Collection')
    IndexPage = apps.get_model('cpm_generic.IndexPage')
    JuryMemberPage = apps.get_model("results.JuryMemberPage")

    index_page_ct = get_content_type(apps, 'cpm_generic', 'indexpage')
    jury_member_page_ct = get_content_type(apps, 'results', 'jurymemberpage')
    collection_id = Collection.objects.filter(depth=1)[0]

    homepage = HomePage.objects.get(slug='home')
    juryindex_page = IndexPage.objects.get(slug=_get_juryindex_kw()['slug'])

    for item in _get_data():
        photo = Image.objects.get(title=item['title'],
                                  collection=collection_id)
        photo.delete()

        remove_subpage(
            parent=juryindex_page,
            model=JuryMemberPage,
            content_type=jury_member_page_ct,
            **_get_jurymember_kw(item)
        )

    remove_subpage(
        parent=homepage,
        model=IndexPage,
        content_type=index_page_ct,
        **_get_juryindex_kw()
    )
Beispiel #3
0
def remove_timetable_2017(apps, schema_editor):
    TimeTable = apps.get_model('events.TimeTable')

    HomePage = apps.get_model('home.HomePage')
    homepage = HomePage.objects.get(slug='home')

    remove_subpage(
        parent=homepage,
        model=TimeTable,
        title=TIMETABLE_TITLE,
    )
Beispiel #4
0
def remove_filmprograms_2017(apps, schema_editor):
    FilmProgram = apps.get_model('events.FilmProgram')

    HomePage = apps.get_model('home.HomePage')
    homepage = HomePage.objects.get(slug='home')

    for item in _get_data('filmprograms.json'):
        if FilmProgram.objects.filter(title=item['title']).exists():
            remove_subpage(
                parent=homepage,
                model=FilmProgram,
                title=item['title'],
            )
def remove_partners_page(apps, schema_editor):
    HomePage = apps.get_model('home.HomePage')
    PartnersPage = apps.get_model('partners.PartnersPage')

    partners_page_ct = get_content_type(apps, 'partners', 'partnerspage')

    homepage = HomePage.objects.get(slug='home')
    remove_subpage(
        homepage,
        PartnersPage,
        content_type=partners_page_ct,
        slug='partners'
    )
def remove_partners_pages(apps, schema_editor):
    Image = get_image_model(apps)
    Collection = apps.get_model('wagtailcore.Collection')
    PartnerPage = apps.get_model("results.PartnerPage")
    ResultsRelatedPartner = apps.get_model('results.ResultsRelatedPartner')

    partner_page_ct = get_content_type(apps, 'results', 'partnerpage')
    collection_id = Collection.objects.filter(depth=1)[0]

    HomePage = apps.get_model('home.HomePage')
    homepage = HomePage.objects.get(slug='home')

    IndexPage = apps.get_model('cpm_generic.IndexPage')
    partnersindex_page = IndexPage.objects.get(slug='Partners')
    partners_data = get_partners_2012_data()

    results2012_page = get_results_page(apps)

    related_film_ids = chain.from_iterable(
        ResultsRelatedPartner.objects.filter(
            partner=PartnerPage.objects.filter(title=item['name_en']),
            page=results2012_page,
        ).values_list('id', flat=True) for item in partners_data
    )

    ResultsRelatedPartner.objects.filter(id__in=related_film_ids).delete()

    for item in partners_data:
        title = slugify(item['name_en'])
        photo = Image.objects.get(title=title,
                                  collection=collection_id)
        photo.delete()

        remove_subpage(
            parent=partnersindex_page,
            model=PartnerPage,
            content_type=partner_page_ct,
            **_get_partner_kw(item)
        )

    index_page_ct = get_content_type(apps, 'cpm_generic', 'indexpage')
    remove_subpage(
        homepage,
        IndexPage,
        content_type=index_page_ct,
        slug='Partners',
    )
Beispiel #7
0
def clear_jury_data(apps, schema_editor):
    HomePage = apps.get_model('home.HomePage')
    IndexPage = apps.get_model('cpm_generic.IndexPage')
    JuryMemberPage = apps.get_model('results.JuryMemberPage')
    RelatedJuryMember = apps.get_model('results.ResultsRelatedJuryMember')

    homepage = HomePage.objects.get(slug='home')
    juryindex = IndexPage.objects.get(slug='jury')

    for obj in RelatedJuryMember.objects.all():
        obj.delete()

    for obj in JuryMemberPage.objects.all():
        obj.photo.delete()
        remove_subpage(parent=juryindex, model=JuryMemberPage, id=obj.id)

    remove_subpage(parent=homepage, model=IndexPage, id=juryindex.id)
def remove_films_pages(apps, schema_editor):
    Image = get_image_model(apps)
    Collection = apps.get_model('wagtailcore.Collection')
    FilmPage = apps.get_model("results.FilmPage")
    ResultsRelatedWinner = apps.get_model('results.ResultsRelatedWinner')

    film_page_ct = get_content_type(apps, 'results', 'filmpage')
    collection_id = Collection.objects.filter(depth=1)[0]

    HomePage = apps.get_model('home.HomePage')
    homepage = HomePage.objects.get(slug='home')

    IndexPage = apps.get_model('cpm_generic.IndexPage')
    filmsindex_page = IndexPage.objects.get(slug='films')
    films2012_data = get_films_2012_data()

    results2012_page = get_results_page(apps)

    related_film_ids = chain.from_iterable(
        ResultsRelatedWinner.objects.filter(
            film=FilmPage.objects.filter(title=item['film_title_en']),
            page=results2012_page,
        ).values_list('id', flat=True) for item in films2012_data)

    ResultsRelatedWinner.objects.filter(id__in=related_film_ids).delete()

    for item in films2012_data:
        title = slugify(item['film_title_en'])
        photo = Image.objects.get(title=title, collection=collection_id)
        photo.delete()

        remove_subpage(parent=filmsindex_page,
                       model=FilmPage,
                       content_type=film_page_ct,
                       **_get_film_kw(item))

    index_page_ct = get_content_type(apps, 'cpm_generic', 'indexpage')
    remove_subpage(
        homepage,
        IndexPage,
        content_type=index_page_ct,
        slug='films',
    )
Beispiel #9
0
def _remove_year_results(apps, page_kwargs, jury_members):
    HomePage = apps.get_model('home.HomePage')
    JuryMemberPage = apps.get_model("results.JuryMemberPage")
    RelatedJuryMember = apps.get_model('results.ResultsRelatedJuryMember')
    ResultsPage = apps.get_model('results.ResultsPage')

    results_page_ct = get_content_type(apps, 'results', 'resultspage')

    homepage = HomePage.objects.get(slug='home')
    results12_page = remove_subpage(homepage,
                                    ResultsPage,
                                    content_type=results_page_ct,
                                    **page_kwargs)

    related_jury_ids = chain.from_iterable(
        RelatedJuryMember.objects.filter(
            jury_member=JuryMemberPage.objects.get(title=title),
            page=results12_page,
        ).values_list('id', flat=True) for title in jury_members)
    RelatedJuryMember.objects.filter(id__in=related_jury_ids).delete()
def _remove_year_results(apps, page_kwargs, jury_members):
    HomePage = apps.get_model('home.HomePage')
    JuryMemberPage = apps.get_model("results.JuryMemberPage")
    RelatedJuryMember = apps.get_model('results.ResultsRelatedJuryMember')
    ResultsPage = apps.get_model('results.ResultsPage')

    results_page_ct = get_content_type(apps, 'results', 'resultspage')

    homepage = HomePage.objects.get(slug='home')
    results12_page = remove_subpage(
        homepage,
        ResultsPage,
        content_type=results_page_ct,
        **page_kwargs
    )

    related_jury_ids = chain.from_iterable(
        RelatedJuryMember.objects.filter(
            jury_member=JuryMemberPage.objects.get(title=title),
            page=results12_page,
        ).values_list('id', flat=True) for title in jury_members
    )
    RelatedJuryMember.objects.filter(id__in=related_jury_ids).delete()