Пример #1
0
class ResourcesPage(Page, CossBaseModel):
    """Resources Page for Open Source Clubs."""
    heading_text = fields.RichTextField(verbose_name='Text', blank=True)
    heading_image = models.ForeignKey('wagtailimages.Image',
                                      null=True,
                                      blank=True,
                                      on_delete=models.SET_NULL,
                                      related_name='+',
                                      verbose_name='Image')
    mentors_description = fields.StreamField([
        (
            'info',
            InputTextContentBlock(required=True),
        ),
    ])
    resources_title = models.CharField(verbose_name='Title',
                                       blank=True,
                                       default='',
                                       max_length=50)
    resources_cta_text = models.CharField(verbose_name='CTA Text',
                                          blank=True,
                                          default='',
                                          max_length=50)
    resources_cta_link = models.URLField(verbose_name='Link',
                                         blank=True,
                                         default='')
    guides = fields.RichTextField(verbose_name='Guides', blank=True)
    bottom_content_block = fields.StreamField([
        (
            'cta',
            BottomCTAContentBlock(),
        ),
    ],
                                              null=True,
                                              blank=True)

    def get_mentors(self):
        # TODO: Add filter for mentors that belong to each club
        return ClubProfile.objects.filter(is_mentor=True)

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel('heading_text'),
            FieldPanel('heading_image'),
        ],
                        heading='Heading'),
        StreamFieldPanel('mentors_description'),
        MultiFieldPanel([
            FieldPanel('resources_title'),
            FieldPanel('resources_cta_text'),
            FieldPanel('resources_cta_link'),
            FieldPanel('guides'),
        ],
                        heading='Resources'),
        StreamFieldPanel('bottom_content_block'),
    ]
Пример #2
0
class FestivalPage(models.Page):
    '''
	Deze klasse beschrijft een festival. 
		* Via FestivalPageRateableAttribuut kunnen de te beoordelen aspecten van een festival toegekend worden
	'''

    name = djangomodels.CharField('Festival naam', max_length=40, default='')
    description = fields.RichTextField('Festival promo tekst',
                                       blank=True,
                                       default='')
    date = djangomodels.DateField('Festival datum', null=True)
    duration = djangomodels.PositiveIntegerField('Duur (# dagen)', default=1)

    location = djangomodels.ForeignKey('Location',
                                       related_name='festivals',
                                       null=True,
                                       blank=True)
    contact_person = djangomodels.ForeignKey('Person',
                                             related_name='festivals',
                                             null=True)

    tags = ClusterTaggableManager(through=FestivalPageTag, blank=True)

    class Meta:
        verbose_name = 'FestivalPagina'
        ordering = [
            '-date',
        ]
Пример #3
0
class HomePage(models.Page):

    template = 'home/home.html'
    test = fields.RichTextField(blank=True, null=True)

    class Meta:
        verbose_name = _('Startpagina')
Пример #4
0
class ActivitiesPage(Page, CossBaseModel):
    """Activities Page for Open Source Clubs."""
    description = fields.RichTextField(blank=True)
    activity = fields.StreamField([(
        'info',
        CardContentBlock(required=True),
    )])

    content_panels = Page.content_panels + [
        FieldPanel('description'),
        StreamFieldPanel('activity'),
    ]
Пример #5
0
class EntityDetailPage(Page, CossBaseModel):
    """Actual page for the Open Source clubs."""

    body_text = fields.RichTextField(blank=True)
    body_link = models.URLField(verbose_name='Description link',
                                blank=True,
                                default='')
    featured = models.BooleanField(default=False)
    is_flagged = models.BooleanField(default=False)
    club_name = models.CharField(max_length=128, default='')
    discourse_link = models.URLField(verbose_name='Discourse Link',
                                     blank=True,
                                     default='')
    contact_cta = models.URLField(verbose_name='Contact CTA link', blank=True)
    facebook_link = models.URLField(verbose_name='Facebook link',
                                    blank=True,
                                    default='')
    members = ParentalManyToManyField(ClubProfile,
                                      blank=True,
                                      related_name='profiles')
    tags = ClusterTaggableManager(through=EntityPageTag, blank=True)
    location = models.CharField(max_length=255, blank=True, default='')
    flag_email = models.EmailField(blank=True, default='')

    def get_first_image(self):
        item = self.gallery_images.first()
        if item:
            return item.image
        return None

    content_panels = Page.content_panels + [
        FieldPanel('body_text', classname='full'),
        FieldPanel('body_link'),
        FieldPanel('club_name'),
        FieldPanel('contact_cta'),
        FieldPanel('location'),
        MultiFieldPanel([
            FieldPanel('featured'),
            FieldPanel('is_flagged'),
        ],
                        heading='Entity Attributes'),
        FieldPanel('flag_email'),
        FieldPanel('discourse_link'),
        FieldPanel('facebook_link'),
        FieldPanel('tags'),
        InlinePanel('gallery_images', label='Gallery Images'),
        FieldPanel('members'),
    ]
Пример #6
0
class Testimonial(models.Model):
    quote = fields.RichTextField()
    person = models.CharField(max_length=100)
    photo = models.ForeignKey('wagtailimages.Image',
                              null=True,
                              blank=True,
                              on_delete=models.SET_NULL,
                              related_name='+')

    panels = [
        FieldPanel('quote'),
        FieldPanel('person'),
        ImageChooserPanel('photo'),
    ]

    def __str__(self):
        return self.person
Пример #7
0
class CategoryLandingPage(Page, CossBaseModel):
    """Category Landing page for Open Source Clubs."""
    heading_text = fields.RichTextField(
        verbose_name='Text',
        blank=True,
        default='',
    )
    heading_cta_text = models.CharField(verbose_name='CTA Text',
                                        blank=True,
                                        default='',
                                        max_length=50)
    heading_cta_link = models.URLField(verbose_name='CTA Link',
                                       blank=True,
                                       default='')

    content_panels = Page.content_panels + [
        MultiFieldPanel([
            FieldPanel('heading_text'),
            FieldPanel('heading_cta_text'),
            FieldPanel('heading_cta_link'),
        ],
                        heading='Heading'),
    ]
Пример #8
0
class AboutSnippet(models.Model):
    title = models.CharField(default='', max_length=50)
    header_text = fields.RichTextField(blank=True)
    body_title = models.CharField(verbose_name='Title',
                                  blank=True,
                                  default='',
                                  max_length=50)
    body_text = fields.RichTextField(verbose_name='Text', blank=True)
    body_image = models.ForeignKey('wagtailimages.Image',
                                   null=True,
                                   blank=True,
                                   on_delete=models.SET_NULL,
                                   related_name='+',
                                   verbose_name='Image')
    info_title = models.CharField(verbose_name='Title',
                                  blank=True,
                                  default='',
                                  max_length=50)
    info_text = fields.RichTextField(verbose_name='Text', blank=True)
    details_title = models.CharField(verbose_name='Title',
                                     blank=True,
                                     default='',
                                     max_length=50)
    details = fields.StreamField([
        (
            'section',
            InputTextContentBlock(),
        ),
    ],
                                 null=True,
                                 blank=True,
                                 verbose_name='Blocks')
    collaborators_title = models.CharField(verbose_name='Title',
                                           blank=True,
                                           default='',
                                           max_length=50)
    collaborators_text = fields.RichTextField(verbose_name='Text', blank=True)
    collaborators_cta_text = models.CharField(verbose_name='CTA Text',
                                              blank=True,
                                              default='',
                                              max_length=50)
    collaborators_cta_link = models.URLField(verbose_name='CTA Link',
                                             blank=True,
                                             default='')
    collaborators = fields.StreamField([
        (
            'info',
            CardContentBlock(),
        ),
    ],
                                       null=True,
                                       blank=True)
    bottom_content_block = fields.StreamField([
        (
            'cta',
            BottomCTAContentBlock(),
        ),
    ],
                                              null=True,
                                              blank=True)
    optional_text_block_title = models.CharField(verbose_name='Title',
                                                 blank=True,
                                                 default='',
                                                 max_length=50)
    optional_text_block = fields.StreamField([
        (
            'secondary_section',
            InputTextContentBlock(),
        ),
    ],
                                             null=True,
                                             blank=True,
                                             verbose_name='Blocks')

    panels = [
        FieldPanel('title'),
        FieldPanel('header_text'),
        MultiFieldPanel([
            FieldPanel('body_title'),
            FieldPanel('body_text'),
            ImageChooserPanel('body_image'),
        ],
                        heading='Body'),
        MultiFieldPanel([
            FieldPanel('info_title'),
            FieldPanel('info_text'),
        ],
                        heading='Info'),
        MultiFieldPanel([
            FieldPanel('details_title'),
            StreamFieldPanel('details'),
        ],
                        heading='Details'),
        MultiFieldPanel([
            FieldPanel('collaborators_title'),
            FieldPanel('collaborators_text'),
            FieldPanel('collaborators_cta_text'),
            FieldPanel('collaborators_cta_link'),
            StreamFieldPanel('collaborators'),
        ],
                        heading='Collaborators Section'),
        StreamFieldPanel('bottom_content_block'),
        MultiFieldPanel([
            FieldPanel('optional_text_block_title'),
            StreamFieldPanel('optional_text_block'),
        ],
                        heading='Secondary Input block'),
    ]

    class Meta:
        verbose_name_plural = 'About Snippets'

    def __str__(self):
        return self.title
Пример #9
0
class HomePage(Page, CossBaseModel):
    """Landing HomePage for OpenSource clubs."""

    logo = models.ForeignKey('wagtailimages.Image',
                             null=True,
                             blank=True,
                             on_delete=models.SET_NULL,
                             related_name='+')
    heading_text = fields.RichTextField(
        verbose_name='Text',
        blank=True,
        default='',
    )
    heading_cta_text = models.CharField(verbose_name='CTA Text',
                                        blank=True,
                                        default='',
                                        max_length=50)
    heading_cta_link = models.URLField(verbose_name='CTA Link',
                                       blank=True,
                                       default='')
    heading_image = models.ForeignKey('wagtailimages.Image',
                                      null=True,
                                      blank=True,
                                      on_delete=models.SET_NULL,
                                      related_name='+')
    discourse = models.ForeignKey('discourse.DiscourseCategory',
                                  null=True,
                                  blank=True,
                                  on_delete=models.SET_NULL,
                                  related_name='+')
    testimonial = models.ForeignKey('home.Testimonial',
                                    null=True,
                                    blank=True,
                                    on_delete=models.SET_NULL,
                                    related_name='+')
    bottom_content_block = fields.StreamField([
        (
            'cta',
            BottomCTAContentBlock(),
        ),
    ],
                                              null=True,
                                              blank=True)

    opengraph_image = models.ForeignKey('wagtailimages.Image',
                                        null=True,
                                        blank=True,
                                        on_delete=models.SET_NULL,
                                        related_name='+',
                                        verbose_name='Open Graph Image')

    def get_category_landing_page(self):
        if self.get_children().type(CategoryLandingPage):
            try:
                return CategoryLandingPage.objects.get()
            except (CategoryLandingPage.DoesNotExist,
                    CategoryLandingPage.MultipleObjectsReturned):
                pass
        return CategoryLandingPage.objects.none()

    content_panels = Page.content_panels + [
        FieldPanel('logo'),
        FieldPanel('opengraph_image'),
        MultiFieldPanel([
            FieldPanel('heading_text'),
            FieldPanel('heading_cta_text'),
            FieldPanel('heading_cta_link'),
            FieldPanel('heading_image'),
        ],
                        heading='Heading'),
        SnippetChooserPanel('discourse'),
        SnippetChooserPanel('testimonial'),
        StreamFieldPanel('bottom_content_block')
    ]
Пример #10
0
class FestivalPage(RoutablePageMixin, RatedModelMixin, models.Page):
    '''
	Deze klasse beschrijft een festival. 
		* Via FestivalPageRateableAttribuut kunnen de te beoordelen aspecten van een festival toegekend worden
	'''
    template = 'home/festival_page.html'

    # Core attributen
    name = djangomodels.CharField('Festival naam',
                                  max_length=40,
                                  default='',
                                  unique=True,
                                  help_text='Dit moet een unieke naam zijn!')
    description = fields.RichTextField(
        'Festival promo tekst',
        help_text=
        'Hier kan je een promo tekstje invullen, al dan niet voorzien van extra tekst styling',
        blank=True,
        default='')
    date = djangomodels.DateField('Festival datum', null=True)
    duration = djangomodels.PositiveIntegerField('Duur (# dagen)',
                                                 default=1,
                                                 validators=[
                                                     MaxValueValidator(21),
                                                 ])
    end_date = djangomodels.DateField('Eind datum', null=True, blank=True)
    #span_months = djangomodels.BooleanField('Meerdere maanden?', default=False)

    website = djangomodels.URLField(
        max_length=120,
        null=True,
        blank=True,
        help_text='De link naar de homepage van het festival')
    main_image = djangomodels.ForeignKey('home.CustomImage',
                                         null=True,
                                         blank=True,
                                         on_delete=djangomodels.SET_NULL,
                                         related_name='+')
    pricing = djangomodels.PositiveIntegerField(
        'Prijs (range 0 - 5)',
        default=0,
        help_text=
        '0 = gratis, 1 = <20€, 2 = <50€, 3 = <100€, 4 = <200€ en 5= >200€',
        validators=[MaxValueValidator(5),
                    MinValueValidator(0)])

    # Foreign key relaties
    contact_person = djangomodels.ForeignKey('Person',
                                             related_name='festivals',
                                             null=True,
                                             blank=True,
                                             on_delete=djangomodels.SET_NULL)
    location = djangomodels.ForeignKey('Location',
                                       related_name='festivals',
                                       null=True,
                                       blank=True,
                                       on_delete=djangomodels.SET_NULL)

    tags = ClusterTaggableManager(
        through=FestivalPageTag,
        blank=True,
        help_text=mark_safe(
            'Wordt gebruikt om festivals te filteren, dus het <b><u>genre</u></b> (of genres) zijn ideaal om hier in te geven.'
        ))

    # Rating functionality
    #general_rating = djangomodels.DecimalField(default=0, decimal_places=2, max_digits=4)
    #num_votes = djangomodels.PositiveIntegerField(default=0)

    # MODEL MANAGERS
    objects = djangomodels.Manager()  # default manager
    featured = HomePageFeaturedManager()
    upcoming = UpcomingFestivalManager()

    base_form_class = FestivalPageForm

    # ROUTABLE PAGE

    @route(r'^stats/$', name='stats')
    #@route(r'^stats/(\d+)/$')
    def stats(self, request):

        print('name: %s' % self.name)

        #print('kwargs %s' % kwargs)

        template = 'home/festival_stats.html'

        context = {}
        context['page'] = self

        return TemplateResponse(request, template=template, context=context)

    # PROPERTIES

    @property
    def date_representation(self):

        if self.duration == 0:
            return ''

        else:
            if self.duration == 1:
                return self.date.strftime('%d %B')

            else:
                end_date = self.date + timedelta(self.duration)

                if self.date.month == end_date.month:
                    return '%s - %s %s' % (self.date.strftime('%d'),
                                           end_date.strftime('%d'),
                                           self.date.strftime('%b'))

                else:
                    return '%s - %s' % (self.date.strftime('%d %b'),
                                        end_date.strftime('%d %b'))

        return ''

    @property
    def check_month_span(self):

        if self.duration == 1:
            return False

        else:
            end_date = self.date + timedelta(self.duration)

            if self.date.month != end_date.month:
                return True

            else:
                return False

        return False

    @property
    def ongoing(self):

        today = datetime.today().date()
        margin = timedelta(days=self.duration)

        return self.date <= today <= self.date + margin

    # METHODS

    def save(self, *args, **kwargs):
        '''
		Deze methode werd overschreven om de title en slug attributes van een Page model in te stellen
		Ze worden ingesteld op basis van de festival naam, en dit bespaart de content editor wat werk
		'''

        # -- MAIN IMAGE FUNCTIONALITY -- #
        main_image = None

        # Als er slechts 1 afbeelding is, dan zal deze steeds primair zijn
        if len(self.images.all()) == 1:

            main = self.images.all()[0]
            main_image = main.image

        # Als er meer dan 1 afbeelding is, zorgen we ervoor dat er slechts 1 primair is
        elif len(self.images.all()) > 1:

            main = self.images.all()[0]
            main_image = main.image

        # Update het main_image attribuut van de bijhorende FestivalPage
        self.main_image = main_image

        # -- END DATE FUNCTIONALITY -- #

        if not self.end_date:

            if self.duration == 0:
                pass

            elif self.duration == 1:
                pass

            else:
                end_date = self.date + timedelta(self.duration)
                self.end_date = end_date

        # -- PAGE TITLE AND PAGE SLUG FUNCTIONALITY -- #

        if self.slug == "" and self.title == "":
            self.title = self.name
            self.slug = slugify(self.name)

        return super(FestivalPage, self).save(*args, **kwargs)

    def update_rating(self, score):

        num_attributes = len(self.rateable_attributes.all())

        score = 0

        for attribute in self.rateable_attributes.all():

            rating = attribute.get_ratings()

            attr_score = rating.score / rating.num_votes

        return 1

    class Meta:
        verbose_name = 'Festival'
        ordering = [
            'date',
        ]