aboutsummaryrefslogtreecommitdiffstats
path: root/python/fatcat_web
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2020-06-04 14:05:56 -0700
committerBryan Newbold <bnewbold@robocracy.org>2020-06-04 14:12:30 -0700
commit2f233a3b8c00385d4b215361a0fa09f93a05f8d9 (patch)
tree7c3226a9a961c1c4a7af00dbc0f47c11a3172ac2 /python/fatcat_web
parenta42d5f0d00e76bf8474647fae4e1d9d61693a7d9 (diff)
downloadfatcat-2f233a3b8c00385d4b215361a0fa09f93a05f8d9.tar.gz
fatcat-2f233a3b8c00385d4b215361a0fa09f93a05f8d9.zip
use ES 'best_url' in file download pages
Similar to recent change for release download pages.
Diffstat (limited to 'python/fatcat_web')
-rw-r--r--python/fatcat_web/entity_helpers.py2
-rw-r--r--python/fatcat_web/templates/file_view.html4
2 files changed, 4 insertions, 2 deletions
diff --git a/python/fatcat_web/entity_helpers.py b/python/fatcat_web/entity_helpers.py
index d82ea0e9..e3d538e0 100644
--- a/python/fatcat_web/entity_helpers.py
+++ b/python/fatcat_web/entity_helpers.py
@@ -30,6 +30,8 @@ def enrich_creator_entity(entity):
return entity
def enrich_file_entity(entity):
+ if entity.state == "active":
+ entity._es = file_to_elasticsearch(entity)
return entity
def enrich_fileset_entity(entity):
diff --git a/python/fatcat_web/templates/file_view.html b/python/fatcat_web/templates/file_view.html
index d60ea49d..02f47a91 100644
--- a/python/fatcat_web/templates/file_view.html
+++ b/python/fatcat_web/templates/file_view.html
@@ -44,8 +44,8 @@ No known public URL, mirror, or archive for this file.
</div>
<div class="column" style="flex: 0 0 24em;">
-{% if file.urls != None and file.urls != [] %}
-<a href="{{ file.urls[0].url }}" class="ui top attached fluid huge green button"><i class="file icon"></i>Download File</a>
+{% if file._es and file._es.best_url %}
+<a href="{{ file._es.best_url }}" class="ui top attached fluid huge green button"><i class="file icon"></i>Download File</a>
{% else %}
<span class="ui top attached fluid huge grey button"><i class="file cross icon"></i>No Download Available</span>
{% endif %}