Skip to content
Open
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
4 changes: 4 additions & 0 deletions exodus/exodus/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
from django.conf.urls.static import static
from django.contrib import admin

from reports.views import get_app_icon

from . import views

urlpatterns = [
path('i18n/', include('django.conf.urls.i18n')),
path('api/', include('restful_api.urls')),
path('admin/', admin.site.urls),
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
path('reports/<int:app_id>/icon/', get_app_icon, name='app_icon'),
path('reports/<handle>/latest/icon/', get_app_icon, name='app_icon_by_handle'),
]

urlpatterns += i18n_patterns(
Expand Down
2 changes: 1 addition & 1 deletion exodus/reports/templates/report_details.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

<div class="row justify-content-sm-center">
<div class="col-xl-2 col-lg-2 col-md-8 col-12 text-lg-left text-center mb-4">
<img src="/{{ LANGUAGE_CODE }}/reports/{{ report.application.id }}/icon/" class="rounded" width="115" height="115" alt="{{ report.application.handle }} logo">
<img src="{% url 'app_icon' report.application.id %}" class="rounded" width="115" height="115" alt="{{ report.application.handle }} logo">
</div>
<div class="col-xl-6 col-lg-6 col-md-8 col-12 text-center text-lg-left my-auto mb-4">
<h1 class="main-title">
Expand Down
10 changes: 10 additions & 0 deletions exodus/reports/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ def test_get_by_id(self, get_object):
self.assertTrue(get_object.called)
self.assertEqual(response.content, b'icon contents')

@patch('reports.views.Minio.get_object', autospec=True, return_value=Mock(data='icon contents'))
def test_icon_served_without_language_redirect(self, get_object):
r = Report.objects.create()
app = Application.objects.create(report=r, handle='com.example.app', version='1')

response = self.client.get('/reports/{}/icon/'.format(app.pk), follow=False)

self.assertEqual(response.status_code, 200)
self.assertTrue(get_object.called)


class ReportsViewTests(TestCase):
REPORTS_PATH = '/en/reports/list/'
Expand Down