Skip to content

Commit

Permalink
spreadsheet: Change download file name and copy on page
Browse files Browse the repository at this point in the history
  • Loading branch information
jarofgreen committed Dec 16, 2022
1 parent 4facb65 commit 1fc9c73
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
14 changes: 6 additions & 8 deletions cove_ofds/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,9 +353,7 @@ def __init__(self, supplied_data):
self.csvs_zip_filename = os.path.join(
self.supplied_data.data_dir(), "flatten", "flattened.csvs.zip"
)
self.output_dir = os.path.join(
self.supplied_data.data_dir(), "flatten", "flattened"
)
self.output_dir = os.path.join(self.supplied_data.data_dir(), "flatten", "data")

def process(self, process_data: dict) -> dict:

Expand Down Expand Up @@ -401,24 +399,24 @@ def get_context(self):
context = {}
# XLSX
xlsx_filename = os.path.join(
self.supplied_data.data_dir(), "flatten", "flattened.xlsx"
self.supplied_data.data_dir(), "flatten", "data.xlsx"
)
if os.path.exists(xlsx_filename):
context["can_download_xlsx"] = True
context["download_xlsx_url"] = os.path.join(
self.supplied_data.data_url(), "flatten", "flattened.xlsx"
self.supplied_data.data_url(), "flatten", "data.xlsx"
)
context["download_xlsx_size"] = os.stat(xlsx_filename).st_size
else:
context["can_download_xlsx"] = False
# ODS
ods_filename = os.path.join(
self.supplied_data.data_dir(), "flatten", "flattened.ods"
self.supplied_data.data_dir(), "flatten", "data.ods"
)
if os.path.exists(ods_filename):
context["can_download_ods"] = True
context["download_ods_url"] = os.path.join(
self.supplied_data.data_url(), "flatten", "flattened.ods"
self.supplied_data.data_url(), "flatten", "data.ods"
)
context["download_ods_size"] = os.stat(ods_filename).st_size
else:
Expand All @@ -435,7 +433,7 @@ def get_context(self):
"name": f,
"size": os.stat(os.path.join(self.output_dir, f)).st_size,
"url": os.path.join(
self.supplied_data.data_url(), "flatten", "flattened", f
self.supplied_data.data_url(), "flatten", "data", f
),
}
for f in self._get_list_csv_filenames()
Expand Down
4 changes: 2 additions & 2 deletions cove_ofds/templates/cove_ofds/explore.html
Original file line number Diff line number Diff line change
Expand Up @@ -199,13 +199,13 @@ <h4 class="panel-title">
{% if can_download_ods %}
<li>
<span class="glyphicon glyphicon-download" aria-hidden="true"></span>
<a href="{{download_ods_url}}">Open Office, ODS ({{ download_ods_size|filesizeformat }})</a>
<a href="{{download_ods_url}}">data.ods ({{ download_ods_size|filesizeformat }})</a>
</li>
{% endif %}
{% if can_download_xlsx %}
<li>
<span class="glyphicon glyphicon-download" aria-hidden="true"></span>
<a href="{{download_xlsx_url}}">Excel, XLSX ({{ download_xlsx_size|filesizeformat }})</a>
<a href="{{download_xlsx_url}}">data.xlsx ({{ download_xlsx_size|filesizeformat }})</a>
</li>
{% endif %}
</ul>
Expand Down

0 comments on commit 1fc9c73

Please sign in to comment.