Skip to content

Commit

Permalink
Merge pull request #283 from the-deep/fix-report-export
Browse files Browse the repository at this point in the history
Add additional check for tabular field in Data Series Entry
  • Loading branch information
frozenhelium authored and thenav56 committed Apr 30, 2019
2 parents 5bef4bf + aea9547 commit 978f4d7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 2 additions & 2 deletions apps/export/entries/report_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,9 +66,9 @@ def _generate_for_entry(self, entry):
if entry.entry_type == Entry.IMAGE:
image = entry.image
# para.add_run().add_image(entry.image)
elif entry.entry_type == Entry.DATA_SERIES:
elif entry.entry_type == Entry.DATA_SERIES and entry.tabular_field:
image = viz_renderer.get_entry_image(entry)
health_stats = entry.tabular_field.cache.get('health_stats', {})
health_stats = (entry.tabular_field.cache or {}).get('health_stats', {})
image_text = ' Total values: {}, Invalid value: {}, Null value: {}'.format(
health_stats.get('total', 'N/A'),
health_stats.get('invalid', 'N/A'),
Expand Down
6 changes: 6 additions & 0 deletions apps/gallery/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ def DEFAULT_EXTRACTION_FUNCTION(file):
return {}


class FileView(View):
def get(self, request, file_id):
file = get_object_or_404(File, id=file_id)
return redirect(request.build_absolute_uri(file.file.url))


class PublicFileView(View):
def get(self, request, fidb64=None, token=None, filename=None):
file_id = force_text(urlsafe_base64_decode(fidb64))
Expand Down
2 changes: 2 additions & 0 deletions deep/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
unsubscribe_email,
)
from gallery.views import (
FileView,
FileViewSet,
GoogleDriveFileViewSet,
DropboxFileViewSet,
Expand Down Expand Up @@ -289,6 +290,7 @@ def get_api_path(path):
TokenRefreshView.as_view()),

# Gallery
url(r'^file/(?P<file_id>\d+)/$', FileView.as_view(), name='file'),
url(
r'^public-file/(?P<fidb64>[0-9A-Za-z]+)/(?P<token>.+)/(?P<filename>.*)$',
PublicFileView.as_view(),
Expand Down

0 comments on commit 978f4d7

Please sign in to comment.