Skip to content

Commit

Permalink
fix - if capture is deleted, then mime type does not exist. Catch error
Browse files Browse the repository at this point in the history
  • Loading branch information
anastasia committed Aug 17, 2017
1 parent dd52dbd commit 55ec3fd
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions perma_web/perma/views/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,13 @@ def make_warcinfo(filename, guid, coll_title, coll_desc, rec_title, pages):

# Special handling for mobile pdf viewing because it can be buggy
# Redirecting to a download page if on mobile
redirect_to_download_view = redirect_to_download(capture.mime_type(), raw_user_agent)
try:
capture_mime_type = capture.mime_type()
redirect_to_download_view = redirect_to_download(capture.mime_type(), raw_user_agent)
except AttributeError:
# if capture is deleted, we will catch it here
capture_mime_type = None
redirect_to_download_view = False

# If this record was just created by the current user, show them a new record message
new_record = request.user.is_authenticated() and link.created_by_id == request.user.id and not link.user_deleted \
Expand All @@ -229,7 +235,7 @@ def make_warcinfo(filename, guid, coll_title, coll_desc, rec_title, pages):
context = {
'link': link,
'redirect_to_download_view': redirect_to_download_view,
'mime_type': capture.mime_type(),
'mime_type': capture_mime_type,
'can_view': request.user.can_view(link),
'can_edit': request.user.can_edit(link),
'can_delete': request.user.can_delete(link),
Expand Down

0 comments on commit 55ec3fd

Please sign in to comment.