Esempio n. 1
0
class PartnersPage(Page):
    name_en = models.CharField(max_length=1000)
    name_be = models.CharField(max_length=1000)
    name_ru = models.CharField(max_length=1000)
    name = TranslatedField('name_en', 'name_be', 'name_ru')

    entry_en = RichTextField(default='')
    entry_be = RichTextField(default='')
    entry_ru = RichTextField(default='')
    entry = TranslatedField(
        'entry_en',
        'entry_be',
        'entry_ru'
    )

    season = models.ForeignKey(
        'cpm_data.Season',
        null=False,
        blank=False,
        related_name='+'
    )

    content_panels = Page.content_panels + [
        FieldPanel('name_en'),
        FieldPanel('name_be'),
        FieldPanel('name_ru'),
        FieldPanel('entry_en'),
        FieldPanel('entry_be'),
        FieldPanel('entry_ru'),
        FieldPanel('season')
    ]
Esempio n. 2
0
class JuryMember(ClusterableModel):
    name_en = models.CharField(max_length=250)
    name_be = models.CharField(max_length=250)
    name_ru = models.CharField(max_length=250)
    name = TranslatedField('name_en', 'name_be', 'name_ru')

    info_en = models.CharField(max_length=5000)
    info_be = models.CharField(max_length=5000)
    info_ru = models.CharField(max_length=5000)
    info = TranslatedField('info_en', 'info_be', 'info_ru')

    photo = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )
    country = models.CharField(max_length=2, choices=COUNTRIES)

    def __unicode__(self):
        return self.name

    panels = [
        FieldPanel('name_en'),
        FieldPanel('name_be'),
        FieldPanel('name_ru'),
        ImageChooserPanel('photo'),
        FieldPanel('country'),
        FieldPanel('info_en'),
        FieldPanel('info_be'),
        FieldPanel('info_ru'),
    ]
Esempio n. 3
0
class ResultsFact(Orderable):

    class Position(object):
        TOP = 't'
        BOTTOM = 'b'

        DEFAULT = BOTTOM
        CHOICES = [
            (TOP, _(u'Top')),
            (BOTTOM, _(u'Bottom')),
        ]

    page = ParentalKey('ResultsPage', related_name='related_facts')

    number = models.CharField(max_length=10, default='')

    caption_en = models.CharField(max_length=100, default='')
    position_en = models.CharField(max_length=1, choices=Position.CHOICES,
                                   default=Position.DEFAULT)

    caption_be = models.CharField(max_length=100, default='')
    position_be = models.CharField(max_length=1, choices=Position.CHOICES,
                                   default=Position.DEFAULT)

    caption_ru = models.CharField(max_length=100, default='')
    position_ru = models.CharField(max_length=1, choices=Position.CHOICES,
                                   default=Position.DEFAULT)

    caption = TranslatedField('caption_en', 'caption_be', 'caption_ru')
    position = TranslatedField('position_en', 'position_be', 'position_ru')
Esempio n. 4
0
class FilmProgram(Page):

    # TODO: add season
    # TODO: need remove section as required property
    section = models.IntegerField(choices=SECTIONS)

    name_en = models.CharField(max_length=1000)
    name_be = models.CharField(max_length=1000)
    name_ru = models.CharField(max_length=1000)
    name = TranslatedField('name_en', 'name_be', 'name_ru')

    description_en = RichTextField(default='')
    description_be = RichTextField(default='')
    description_ru = RichTextField(default='')
    description = TranslatedField('description_en', 'description_be',
                                  'description_ru')

    content_panels = Page.content_panels + [
        FieldPanel('section'),
        FieldPanel('name_en'),
        FieldPanel('name_be'),
        FieldPanel('name_ru'),
        FieldPanel('description_en'),
        FieldPanel('description_be'),
        FieldPanel('description_ru'),
        InlinePanel('related_films', label="Films"),
    ]
Esempio n. 5
0
class Partner(ClusterableModel):
    name_en = models.CharField(max_length=250)
    name_be = models.CharField(max_length=250)
    name_ru = models.CharField(max_length=250)
    name = TranslatedField('name_en', 'name_be', 'name_ru')

    link = models.CharField(max_length=250, blank=True, default='')

    image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

    def __unicode__(self):
        return self.name

    panels = [
        FieldPanel('name_en'),
        FieldPanel('name_be'),
        FieldPanel('name_ru'),
        FieldPanel('link'),
        ImageChooserPanel('image'),
    ]
Esempio n. 6
0
class SeasonRelatedJuryMember(Orderable):
    season = ParentalKey('Season', related_name='related_jury_members')
    jury_member = models.ForeignKey(
        'cpm_data.JuryMember',
        null=True,
        blank=True,
        related_name='+'
    )

    category_en = models.CharField(max_length=250, blank=True, default='')
    category_be = models.CharField(max_length=250, blank=True, default='')
    category_ru = models.CharField(max_length=250, blank=True, default='')
    category = TranslatedField('category_en', 'category_be', 'category_ru')

    name = property(lambda self: self.jury_member.name)
    info = property(lambda self: self.jury_member.info)
    photo = property(lambda self: self.jury_member.photo)
    country = property(lambda self: self.jury_member.country)

    panels = [
        AdminModelChooserPanel('jury_member'),
        FieldPanel('category_en'),
        FieldPanel('category_be'),
        FieldPanel('category_ru'),
    ]
Esempio n. 7
0
class ResultsRelatedWinner(Orderable):
    page = ParentalKey('ResultsPage', related_name='related_winners')
    film = models.ForeignKey(
        'cpm_data.Film',
        null=False,
        blank=False,
        related_name='+'
    )

    nomination_en = models.CharField(max_length=250, blank=True, default='')
    nomination_be = models.CharField(max_length=250, blank=True, default='')
    nomination_ru = models.CharField(max_length=250, blank=True, default='')
    nomination = TranslatedField('nomination_en',
                                 'nomination_be',
                                 'nomination_ru')

    film_title = property(lambda self: self.film.title)
    director = property(lambda self: self.film.director)
    country = property(lambda self: self.film.country)
    city = property(lambda self: self.film.city)
    year = property(lambda self: self.film.year)
    duration = property(lambda self: self.film.duration)
    genre = property(lambda self: self.film.genre)
    synopsis_short = property(lambda self: self.film.synopsis_short)
    synopsis = property(lambda self: self.film.synopsis)
    frame = property(lambda self: self.film.frame)

    panels = [
        AdminModelChooserPanel('film'),
        FieldPanel('nomination_en'),
        FieldPanel('nomination_be'),
        FieldPanel('nomination_ru'),
    ]
Esempio n. 8
0
class TimeTable(Page):

    # TODO: add season
    caption_en = models.CharField(max_length=250)
    caption_be = models.CharField(max_length=250)
    caption_ru = models.CharField(max_length=250)
    caption = TranslatedField('caption_en', 'caption_be', 'caption_ru')

    content_panels = Page.content_panels + [
        FieldPanel('caption_en'),
        FieldPanel('caption_be'),
        FieldPanel('caption_ru'),
        InlinePanel('related_events', label="Events"),
    ]

    def get_context(self, request, *args, **kwargs):
        context = super(TimeTable, self).get_context(request, *args, **kwargs)

        grouped_events = defaultdict(list)
        for event in self.related_events.all():
            group_key = event.starts_at.date()
            grouped_events[group_key].append(event)
        context['grouped_events'] = sorted(grouped_events.iteritems())

        is_legacy = bool(request.GET.get('legacy'))
        context['base_template'] = 'empty.html' if is_legacy else 'base.html'

        return context

    def serve(self, *args, **kwargs):
        """Serve page on new and legacy website"""
        response = super(TimeTable, self).serve(*args, **kwargs)
        response['Access-Control-Allow-Origin'] = '*'
        return response
Esempio n. 9
0
class Venue(index.Indexed, ClusterableModel):
    name_en = models.CharField(max_length=1000)
    name_be = models.CharField(max_length=1000)
    name_ru = models.CharField(max_length=1000)
    name = TranslatedField('name_en', 'name_be', 'name_ru')

    address_en = models.CharField(max_length=1000)
    address_be = models.CharField(max_length=1000)
    address_ru = models.CharField(max_length=1000)
    address = TranslatedField('address_en', 'address_be', 'address_ru')

    objects = SearchableManager()

    def __unicode__(self):
        return self.name

    panels = [
        FieldPanel('name_en'),
        FieldPanel('name_be'),
        FieldPanel('name_ru'),
        FieldPanel('address_en'),
        FieldPanel('address_be'),
        FieldPanel('address_ru'),
    ]
Esempio n. 10
0
class Season(ClusterableModel):
    name_en = models.CharField(max_length=250)
    name_be = models.CharField(max_length=250)
    name_ru = models.CharField(max_length=250)
    name = TranslatedField('name_en', 'name_be', 'name_ru')

    panels = [
        FieldPanel('name_en'),
        FieldPanel('name_be'),
        FieldPanel('name_ru'),
        InlinePanel('related_jury_members', label="Jury members"),
        InlinePanel('related_partners', label="Partners"),
    ]

    def __unicode__(self):
        return self.name

    @classmethod
    def get_current(cls):
        return cls.objects.get(name_en=u'2017')
Esempio n. 11
0
class PartnerPage(Page):
    name_en = models.CharField(max_length=250)
    name_be = models.CharField(max_length=250)
    name_ru = models.CharField(max_length=250)
    name = TranslatedField('name_en', 'name_be', 'name_ru')

    link = models.CharField(max_length=250, blank=True, default='')

    image = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

    content_panels = Page.content_panels + [
        FieldPanel('name_en'),
        FieldPanel('name_be'),
        FieldPanel('name_ru'),
        FieldPanel('link'),
        ImageChooserPanel('image'),
    ]
Esempio n. 12
0
class ResultsPage(Page):
    season = models.ForeignKey(
        'cpm_data.Season',
        null=False,
        blank=False,
        related_name='+'
    )
    caption_en = models.CharField(max_length=250)
    caption_be = models.CharField(max_length=250)
    caption_ru = models.CharField(max_length=250)
    caption = TranslatedField('caption_en', 'caption_be', 'caption_ru')

    content_panels = Page.content_panels + [
        FieldPanel('season'),
        FieldPanel('caption_en'),
        FieldPanel('caption_be'),
        FieldPanel('caption_ru'),
        # InlinePanel('nomination_films', label="Nominations"),
        # seems that we can have two or more different nomination
        # for the same film
        InlinePanel('related_winners', label="Winners"),
        InlinePanel('related_facts', label="Facts"),
        InlinePanel('related_partners', label="Partners"),
    ]
Esempio n. 13
0
class Film(index.Indexed, ClusterableModel):
    """Model representing accepted film

    Submissions contain raw data that need to be preprocessed/translated
    before publishing. This model contains all the data about an accepted
    submission that will be published.
    """
    submission = models.ForeignKey(
        'submissions.Submission',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

    title_en = models.CharField(max_length=1000, default='', blank=True)
    title_be = models.CharField(max_length=1000, default='', blank=True)
    title_ru = models.CharField(max_length=1000, default='', blank=True)
    title = TranslatedField('title_en', 'title_be', 'title_ru')

    director_en = models.CharField(max_length=1000, default='', blank=True)
    director_be = models.CharField(max_length=1000, default='', blank=True)
    director_ru = models.CharField(max_length=1000, default='', blank=True)
    director = TranslatedField('director_en', 'director_be', 'director_ru')

    country = models.CharField(max_length=2, choices=COUNTRIES,
                               null=True, blank=True)

    city_en = models.CharField(max_length=100, default='', blank=True)
    city_be = models.CharField(max_length=100, default='', blank=True)
    city_ru = models.CharField(max_length=100, default='', blank=True)
    city = TranslatedField('city_en', 'city_be', 'city_ru')

    year = models.IntegerField(null=True, blank=True)

    duration_en = models.CharField(max_length=100, default='', blank=True)
    duration_be = models.CharField(max_length=100, default='', blank=True)
    duration_ru = models.CharField(max_length=100, default='', blank=True)
    duration = TranslatedField('duration_en', 'duration_be', 'duration_ru')

    genre_en = models.CharField(max_length=1000, default='', blank=True)
    genre_be = models.CharField(max_length=1000, default='', blank=True)
    genre_ru = models.CharField(max_length=1000, default='', blank=True)
    genre = TranslatedField('genre_en', 'genre_be', 'genre_ru')

    synopsis_short_en = RichTextField(default='', blank=True)
    synopsis_short_be = RichTextField(default='', blank=True)
    synopsis_short_ru = RichTextField(default='', blank=True)
    synopsis_short = TranslatedField('synopsis_short_en',
                                     'synopsis_short_be',
                                     'synopsis_short_ru')

    synopsis_en = RichTextField(default='', blank=True)
    synopsis_be = RichTextField(default='', blank=True)
    synopsis_ru = RichTextField(default='', blank=True)
    synopsis = TranslatedField('synopsis_en', 'synopsis_be', 'synopsis_ru')

    frame = models.ForeignKey(
        'wagtailimages.Image',
        null=True,
        blank=True,
        on_delete=models.SET_NULL,
        related_name='+'
    )

    objects = SearchableManager()

    def __unicode__(self):
        return u'"{}" / {}'.format(self.title, self.director)

    panels = [
        FieldPanel('submission'),
        FieldPanel('title_en'),
        FieldPanel('title_be'),
        FieldPanel('title_ru'),
        FieldPanel('director_en'),
        FieldPanel('director_be'),
        FieldPanel('director_ru'),
        FieldPanel('country'),
        FieldPanel('city_en'),
        FieldPanel('city_be'),
        FieldPanel('city_ru'),
        FieldPanel('genre_en'),
        FieldPanel('genre_be'),
        FieldPanel('genre_ru'),
        FieldPanel('year'),
        FieldPanel('duration_en'),
        FieldPanel('duration_be'),
        FieldPanel('duration_ru'),
        FieldPanel('synopsis_short_en'),
        FieldPanel('synopsis_short_be'),
        FieldPanel('synopsis_short_ru'),
        FieldPanel('synopsis_en'),
        FieldPanel('synopsis_be'),
        FieldPanel('synopsis_ru'),
        ImageChooserPanel('frame'),
    ]

    search_fields = [
        index.SearchField('title_en', partial_match=True, boost=2),
        index.SearchField('title_be', partial_match=True, boost=2),
        index.SearchField('title_ru', partial_match=True, boost=2),
        index.SearchField('director_en', partial_match=True, boost=2),
        index.SearchField('director_be', partial_match=True, boost=2),
        index.SearchField('director_ru', partial_match=True, boost=2),
        index.SearchField('synopsis_short_en', partial_match=True),
        index.SearchField('synopsis_short_be', partial_match=True),
        index.SearchField('synopsis_short_ru', partial_match=True),
        index.SearchField('synopsis_en', partial_match=True),
        index.SearchField('synopsis_be', partial_match=True),
        index.SearchField('synopsis_ru', partial_match=True),
    ]