Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Check pictogram exist on categories during generation of pdfs #3406

Merged
merged 2 commits into from
Jan 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ In preparation for HD Views developments (PR #3298)
- Recreate cache folders if missing. (#3384)
- Modify site's geometry before saving to avoid edition and export of shapefiles (#3399)
- Fix API V2 cache key with X-Forwarded-Proto header (#3404)
- Check pictogram exist on categories during generation of pdfs


2.94.0 (2022-12-12)
Expand Down
2 changes: 1 addition & 1 deletion geotrek/diving/templates/diving/dive_public_pdf_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
</header>
<div class="gray">
<div>
{% if object.practice %}
{% if object.practice and object.practice.pictogram %}
<div class="main-icon category-D{{ object.practice.pk }}" {% block picto_attr %}{% endblock picto_attr %}>
<img src="file://{{ object.practice.pictogram.path }}" alt="">
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</div>
</header>
<div class="gray">
{% if object.parent_sites.first.practice.pictogram %}
{% if object.parent_sites.first.practice and object.parent_sites.first.practice.pictogram %}
<div class="main-icon category-S{{ object.parent_sites.first.practice.pk }}">
<img src="file://{{ object.parent_sites.first.practice.pictogram.path }}" alt="">
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
</div>
</header>
<div class="gray">
{% if object.practice.pictogram %}
{% if object.practice and object.practice.pictogram %}
<div class="main-icon category-S{{ object.practice.pk }}" {% block picto_attr %}{% endblock picto_attr %}>
<img src="file://{{ object.practice.pictogram.path }}" alt="">
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
</header>
<div class="gray">
<div>
{% if object.practice %}
{% if object.practice and object.practice.pictogram %}
<div class="main-icon category-T{{ object.practice.pk }}" {% block picto_attr %}{% endblock picto_attr %}>
<img src="file://{{ object.practice.pictogram.path }}" alt="">
</div>
Expand Down
15 changes: 14 additions & 1 deletion geotrek/trekking/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
TrekNetworkFactory, WebLinkFactory, AccessibilityFactory,
TrekRelationshipFactory, ServiceFactory, ServiceTypeFactory,
TrekWithServicesFactory, TrekWithInfrastructuresFactory,
TrekWithSignagesFactory)
TrekWithSignagesFactory, PracticeFactory)
from ..models import POI, Trek, Service, OrderedTrekChild


Expand Down Expand Up @@ -500,6 +500,19 @@ def test_list_in_csv(self):
self.assertEqual(row['Cities'], "Trifouilli, Refouilli")
self.assertEqual(row['Districts'], self.district.name)

@mock.patch('mapentity.helpers.requests')
def test_document_public_export_without_pictogram(self, mock_requests):
if self.model is None:
return # Abstract test should not run
mock_requests.get.return_value.status_code = 200
mock_requests.get.return_value.content = b'<p id="properties">Mock</p>'
practice = PracticeFactory.create(pictogram=None)
obj = self.modelfactory.create(practice=practice)
response = self.client.get(
reverse(f'{self.model._meta.app_label}:{self.model._meta.model_name}_printable',
kwargs={'lang': 'en', 'pk': obj.pk, 'slug': obj.slug}))
self.assertEqual(response.status_code, 200)


class TrekViewsLiveTests(CommonLiveTest):
model = Trek
Expand Down