Exemplo n.º 1
0
    def get_context_data(self, **kwargs):
        context = super(TrekDocumentPublicBase, self).get_context_data(**kwargs)
        trek = self.get_object()

        context['headerimage_ratio'] = settings.EXPORT_HEADER_IMAGE_SIZE['trek']

        information_desks = list(trek.information_desks.all())
        if settings.TREK_EXPORT_INFORMATION_DESK_LIST_LIMIT > 0:
            information_desks = information_desks[:settings.TREK_EXPORT_INFORMATION_DESK_LIST_LIMIT]
        context['information_desks'] = information_desks

        pois = list(trek.published_pois.all())
        if settings.TREK_EXPORT_POI_LIST_LIMIT > 0:
            pois = pois[:settings.TREK_EXPORT_POI_LIST_LIMIT]
        letters = alphabet_enumeration(len(pois))
        for i, poi in enumerate(pois):
            poi.letter = letters[i]
        context['pois'] = pois

        if not mapentity_settings['MAPENTITY_WEASYPRINT']:
            # Replace HTML text with plain text
            for attr in ['description', 'description_teaser', 'ambiance', 'advice', 'access',
                         'public_transport', 'advised_parking', 'disabled_infrastructure']:
                setattr(trek, attr, plain_text_preserve_linebreaks(getattr(trek, attr)))

            for poi in context['pois']:
                setattr(poi, 'description', plain_text_preserve_linebreaks(getattr(poi, 'description')))

        context['object'] = context['trek'] = trek

        return context
Exemplo n.º 2
0
    def get_context_data(self, **kwargs):
        context = super(TrekDocumentPublicBase,
                        self).get_context_data(**kwargs)
        trek = self.get_object()

        context['headerimage_ratio'] = settings.EXPORT_HEADER_IMAGE_SIZE[
            'trek']

        information_desks = list(trek.information_desks.all())
        if settings.TREK_EXPORT_INFORMATION_DESK_LIST_LIMIT > 0:
            information_desks = information_desks[:settings.
                                                  TREK_EXPORT_INFORMATION_DESK_LIST_LIMIT]
        context['information_desks'] = information_desks

        pois = list(trek.pois.filter(published=True))
        if settings.TREK_EXPORT_POI_LIST_LIMIT > 0:
            pois = pois[:settings.TREK_EXPORT_POI_LIST_LIMIT]
        context['pois'] = pois

        # Replace HTML text with plain text
        for attr in [
                'description', 'description_teaser', 'ambiance', 'advice',
                'access', 'public_transport', 'advised_parking',
                'disabled_infrastructure'
        ]:
            setattr(trek, attr,
                    plain_text_preserve_linebreaks(getattr(trek, attr)))

        for poi in context['pois']:
            setattr(
                poi, 'description',
                plain_text_preserve_linebreaks(getattr(poi, 'description')))

        #
        # POIs enumeration, like shown on the map
        # https://github.com/makinacorpus/Geotrek/issues/871
        enumeration = {}
        letters = alphabet_enumeration(len(trek.pois))
        for i, p in enumerate(trek.pois):
            enumeration[p.pk] = letters[i]
        context['enumeration'] = enumeration

        context['object'] = context['trek'] = trek

        return context
Exemplo n.º 3
0
    def get_context_data(self, **kwargs):
        context = super(TouristicEventDocumentPublic, self).get_context_data(**kwargs)
        event = self.get_object()

        context['headerimage_ratio'] = settings.EXPORT_HEADER_IMAGE_SIZE['touristicevent']

        # Replace HTML text with plain text
        for attr in ['description', 'description_teaser', 'contact', 'booking', 'practical_info']:
            setattr(event, attr, plain_text_preserve_linebreaks(getattr(event, attr)))

        context['object'] = context['event'] = event

        return context
Exemplo n.º 4
0
    def get_context_data(self, **kwargs):
        context = super(TouristicContentDocumentPublic, self).get_context_data(**kwargs)
        content = self.get_object()

        context['headerimage_ratio'] = settings.EXPORT_HEADER_IMAGE_SIZE['touristiccontent']

        if not mapentity_settings['MAPENTITY_WEASYPRINT']:
            # Replace HTML text with plain text
            for attr in ['description', 'description_teaser', 'contact', 'practical_info']:
                setattr(content, attr, plain_text_preserve_linebreaks(getattr(content, attr)))

        context['object'] = context['content'] = content

        return context
Exemplo n.º 5
0
    def get_context_data(self, **kwargs):
        context = super(TrekDocumentPublicBase, self).get_context_data(**kwargs)
        trek = self.get_object()

        context['headerimage_ratio'] = settings.EXPORT_HEADER_IMAGE_SIZE['trek']

        information_desks = list(trek.information_desks.all())
        if settings.TREK_EXPORT_INFORMATION_DESK_LIST_LIMIT > 0:
            information_desks = information_desks[:settings.TREK_EXPORT_INFORMATION_DESK_LIST_LIMIT]
        context['information_desks'] = information_desks

        pois = list(trek.pois.filter(published=True))
        if settings.TREK_EXPORT_POI_LIST_LIMIT > 0:
            pois = pois[:settings.TREK_EXPORT_POI_LIST_LIMIT]
        context['pois'] = pois

        # Replace HTML text with plain text
        for attr in ['description', 'description_teaser', 'ambiance', 'advice', 'access',
                     'public_transport', 'advised_parking', 'disabled_infrastructure']:
            setattr(trek, attr, plain_text_preserve_linebreaks(getattr(trek, attr)))

        for poi in context['pois']:
            setattr(poi, 'description', plain_text_preserve_linebreaks(getattr(poi, 'description')))

        #
        # POIs enumeration, like shown on the map
        # https://github.com/makinacorpus/Geotrek/issues/871
        enumeration = {}
        letters = alphabet_enumeration(len(trek.pois))
        for i, p in enumerate(trek.pois):
            enumeration[p.pk] = letters[i]
        context['enumeration'] = enumeration

        context['object'] = context['trek'] = trek

        return context
Exemplo n.º 6
0
    def get_context_data(self, **kwargs):
        context = super(TouristicContentDocumentPublic,
                        self).get_context_data(**kwargs)
        content = self.get_object()

        context['headerimage_ratio'] = settings.EXPORT_HEADER_IMAGE_SIZE[
            'touristiccontent']

        if not mapentity_settings['MAPENTITY_WEASYPRINT']:
            # Replace HTML text with plain text
            for attr in [
                    'description', 'description_teaser', 'contact',
                    'practical_info'
            ]:
                setattr(content, attr,
                        plain_text_preserve_linebreaks(getattr(content, attr)))

        context['object'] = context['content'] = content

        return context