add date to gallery page

This commit is contained in:
iou1name 2023-04-15 18:52:45 -04:00
parent 8025ce338c
commit 0000cc6540
2 changed files with 7 additions and 1 deletions

View File

@ -91,7 +91,7 @@ async def gallery(request):
async with request.app['pool'].acquire() as conn: async with request.app['pool'].acquire() as conn:
uploads = await conn.fetch( uploads = await conn.fetch(
"SELECT * FROM upload WHERE user_id = $1", "SELECT * FROM upload WHERE user_id = $1 ORDER BY upload_date DESC",
user_id) user_id)
upload_url = config.upload_url upload_url = config.upload_url
return render_template("gallery.html", request, locals()) return render_template("gallery.html", request, locals())
@ -201,6 +201,7 @@ def download_file(url, timeout=10, max_file_size=config.client_max_size):
r.headers['content-disposition']).group(1) r.headers['content-disposition']).group(1)
else: else:
fname = os.path.basename(url) fname = os.path.basename(url)
fname = re.sub('\?.*$', '', fname)
return (fname, temp) return (fname, temp)

View File

@ -13,8 +13,13 @@
<main> <main>
<section> <section>
<table> <table>
<tr>
<th>Upload Date</th>
<th>Filename</th>
</tr>
{% for upload in uploads %} {% for upload in uploads %}
<tr> <tr>
<td>{{ upload['upload_date'].strftime('%Y-%m-%d') }}</td>
<td><a href="{{ upload_url + upload['filename'] }}">{{ upload['filename'] }}</a></td> <td><a href="{{ upload_url + upload['filename'] }}">{{ upload['filename'] }}</a></td>
</tr> </tr>
{% endfor %} {% endfor %}