Skip to content

Commit

Permalink
Add timestamp to csv download in attribution page
Browse files Browse the repository at this point in the history
  • Loading branch information
ffont committed Sep 18, 2023
1 parent 80b0e2a commit a9c8731
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
10 changes: 6 additions & 4 deletions accounts/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -1148,20 +1148,22 @@ def download_attribution(request):
response['Content-Disposition'] = f'attachment; filename="{filename}"'
output = io.StringIO()
if download == 'csv':
output.write('Download Type,File Name,User,License\r\n')
output.write('Download Type,File Name,User,License,Timestamp\r\n')
csv_writer = csv.writer(output, delimiter=',', quotechar='"', quoting=csv.QUOTE_MINIMAL)
for row in qs:
csv_writer.writerow(
[row['download_type'][0].upper(), row['sound__original_filename'],
row['sound__user__username'],
license_with_version(row['license__name'] or row['sound__license__name'],
row['license__deed_url'] or row['sound__license__deed_url'])])
row['license__deed_url'] or row['sound__license__deed_url']),
row['created']])
elif download == 'txt':
for row in qs:
output.write("{}: {} by {} | License: {}\n".format(row['download_type'][0].upper(),
output.write("{}: {} by {} | License: {} | Timestamp: {}\n".format(row['download_type'][0].upper(),
row['sound__original_filename'], row['sound__user__username'],
license_with_version(row['license__name'] or row['sound__license__name'],
row['license__deed_url'] or row['sound__license__deed_url'])))
row['license__deed_url'] or row['sound__license__deed_url']),
row['created']))
response.writelines(output.getvalue())
return response
else:
Expand Down
8 changes: 5 additions & 3 deletions templates_bw/accounts/attribution.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,12 @@

{% block page-content %}
<p>
This is the list of files you have downloaded. When you use freesound samples (under the "attribution" or "attribution non-commercial license"), you have to <a href="{% url "wiki-page" "faq" %}#how-do-i-creditattribute">credit the original creator of the sound</a> in your work. This list makes it a little bit easier to do so. "S" means sound, "P" means pack.<br/>
</p><p>
This is the list of files you have downloaded. When you use freesound samples under the Attribution or Attribution NonCommercial license, you have to <a href="{% url "wiki-page" "faq" %}#how-do-i-creditattribute">credit the original creator of the sound</a> in your work.
This list makes it easy to do so. "S" means sound, "P" means pack.
There are 3 flavors of this list: <a href="?format=regular">regular</a>, <a href="?format=html">html</a> or <a href="?format=plaintext">plain text</a>.
You can also <b>download</b> the complete list as <a href="{% url "accounts-download-attribution" %}?dl=csv">csv</a> or <a href="{% url "accounts-download-attribution" %}?dl=txt">plain text</a>.
Alternatively, you can download the <b>complete record of your downloaded sounds</b> in <a href="{% url "accounts-download-attribution" %}?dl=csv">csv</a> or <a href="{% url "accounts-download-attribution" %}?dl=txt">plain text</a> formats.
</p><p>

</p>

<div class="v-spacing-top-4 v-spacing-6">
Expand Down

0 comments on commit a9c8731

Please sign in to comment.