fix: image cache busting
This commit is contained in:
parent
5aa3d2e4c2
commit
2f79377c09
12 changed files with 34 additions and 12 deletions
13
CHANGELOG.md
13
CHANGELOG.md
|
@ -1,5 +1,18 @@
|
|||
# Matemat Changelog
|
||||
|
||||
<!-- BEGIN RELEASE v0.3.2 -->
|
||||
## Version 0.3.2
|
||||
|
||||
Caching fix
|
||||
|
||||
### Changes
|
||||
|
||||
<!-- BEGIN CHANGES 0.3.2-->
|
||||
- Cache busting for profile and product pictures
|
||||
<!-- END CHANGES 0.3.2 -->
|
||||
|
||||
<!-- END RELEASE v0.3.2 -->
|
||||
|
||||
<!-- BEGIN RELEASE v0.3.1 -->
|
||||
## Version 0.3.1
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
|
||||
__version__ = '0.3.1'
|
||||
__version__ = '0.3.2'
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
from datetime import datetime
|
||||
from io import BytesIO
|
||||
from shutil import copyfile
|
||||
|
||||
|
@ -47,9 +48,10 @@ def admin():
|
|||
users = db.list_users()
|
||||
products = db.list_products()
|
||||
# Render the "Admin/Settings" page
|
||||
now = str(int(datetime.utcnow().timestamp()))
|
||||
return template.render('admin.html',
|
||||
authuser=user, authlevel=authlevel, users=users, products=products,
|
||||
receipt_preference_class=ReceiptPreference,
|
||||
receipt_preference_class=ReceiptPreference, now=now,
|
||||
setupname=config['InstanceName'], config_smtp_enabled=config['SmtpSendReceipts'])
|
||||
|
||||
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
from datetime import datetime
|
||||
|
||||
from bottle import route, redirect
|
||||
|
||||
from matemat.db import MatematDatabase
|
||||
|
@ -12,6 +14,7 @@ def main_page():
|
|||
"""
|
||||
config = get_app_config()
|
||||
session_id: str = session.start()
|
||||
now = str(int(datetime.utcnow().timestamp()))
|
||||
with MatematDatabase(config['DatabaseFile']) as db:
|
||||
# Check whether a user is logged in
|
||||
if session.has(session_id, 'authenticated_user'):
|
||||
|
@ -26,7 +29,7 @@ def main_page():
|
|||
# Prepare a response with a jinja2 template
|
||||
return template.render('productlist.html',
|
||||
authuser=user, users=users, products=products, authlevel=authlevel,
|
||||
stock=get_stock_provider(), setupname=config['InstanceName'])
|
||||
stock=get_stock_provider(), setupname=config['InstanceName'], now=now)
|
||||
else:
|
||||
# If there are no admin users registered, jump to the admin creation procedure
|
||||
if not db.has_admin_users():
|
||||
|
@ -34,5 +37,5 @@ def main_page():
|
|||
# If no user is logged in, fetch the list of users and render the userlist template
|
||||
users = db.list_users(with_touchkey=True)
|
||||
return template.render('userlist.html',
|
||||
users=users, setupname=config['InstanceName'],
|
||||
users=users, setupname=config['InstanceName'], now=now,
|
||||
signup=(config.get('SignupEnabled', '0') == '1'))
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
import os
|
||||
from io import BytesIO
|
||||
from datetime import datetime
|
||||
from typing import Dict
|
||||
|
||||
import magic
|
||||
|
@ -55,9 +56,10 @@ def modproduct():
|
|||
redirect('/admin')
|
||||
|
||||
# Render the "Modify Product" page
|
||||
now = str(int(datetime.utcnow().timestamp()))
|
||||
return template.render('modproduct.html',
|
||||
authuser=authuser, product=product, authlevel=authlevel,
|
||||
setupname=config['InstanceName'])
|
||||
setupname=config['InstanceName'], now=now)
|
||||
|
||||
|
||||
def handle_change(args: FormsDict, files: FormsDict, product: Product, db: MatematDatabase) -> None:
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
from datetime import datetime
|
||||
from io import BytesIO
|
||||
from typing import Dict, Optional
|
||||
|
||||
|
@ -55,8 +56,9 @@ def moduser():
|
|||
redirect('/admin')
|
||||
|
||||
# Render the "Modify User" page
|
||||
now = str(int(datetime.utcnow().timestamp()))
|
||||
return template.render('moduser.html',
|
||||
authuser=authuser, user=user, authlevel=authlevel,
|
||||
authuser=authuser, user=user, authlevel=authlevel, now=now,
|
||||
receipt_preference_class=ReceiptPreference,
|
||||
setupname=config['InstanceName'], config_smtp_enabled=config['SmtpSendReceipts'])
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
Package: matemat
|
||||
Version: 0.3.1
|
||||
Version: 0.3.2
|
||||
Maintainer: s3lph <1375407-s3lph@users.noreply.gitlab.com>
|
||||
Section: web
|
||||
Priority: optional
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
<h2>Avatar</h2>
|
||||
|
||||
<form id="admin-avatar-form" method="post" action="/admin?change=avatar" enctype="multipart/form-data" accept-charset="UTF-8">
|
||||
<img src="/static/upload/thumbnails/users/{{ authuser.id }}.png" alt="Avatar of {{ authuser.name }}" /><br/>
|
||||
<img src="/static/upload/thumbnails/users/{{ authuser.id }}.png?cacheBuster={{ now }}" alt="Avatar of {{ authuser.name }}" /><br/>
|
||||
|
||||
<label for="admin-avatar-avatar">Upload new file: </label>
|
||||
<input id="admin-avatar-avatar" type="file" name="avatar" accept="image/*" /><br/>
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
<input id="modproduct-balance" name="stock" type="text" value="{{ product.stock }}" /><br/>
|
||||
|
||||
<label for="modproduct-image">
|
||||
<img height="150" src="/static/upload/thumbnails/products/{{ product.id }}.png" alt="Image of {{ product.name }}" />
|
||||
<img height="150" src="/static/upload/thumbnails/products/{{ product.id }}.png?cacheBuster={{ now }}" alt="Image of {{ product.name }}" />
|
||||
</label><br/>
|
||||
<input id="modproduct-image" type="file" name="image" accept="image/*" /><br/>
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
<input id="moduser-account-balance-reason" type="text" name="reason" placeholder="Shows up on receipt" /><br/>
|
||||
|
||||
<label for="moduser-account-avatar">
|
||||
<img src="/static/upload/thumbnails/users/{{ user.id }}.png" alt="Avatar of {{ user.name }}" />
|
||||
<img src="/static/upload/thumbnails/users/{{ user.id }}.png?cacheBuster={{ now }}" alt="Avatar of {{ user.name }}" />
|
||||
</label><br/>
|
||||
<input id="moduser-account-avatar" type="file" name="avatar" accept="image/*" /><br/>
|
||||
|
||||
|
|
|
@ -68,7 +68,7 @@
|
|||
</span><br/>
|
||||
{% endif %}
|
||||
<div class="imgcontainer">
|
||||
<img src="/static/upload/thumbnails/products/{{ product.id }}.png" alt="Picture of {{ product.name }}" draggable="false"/>
|
||||
<img src="/static/upload/thumbnails/products/{{ product.id }}.png?cacheBuster={{ now }}" alt="Picture of {{ product.name }}" draggable="false"/>
|
||||
{% set pstock = stock.get_stock(product) %}
|
||||
{% if pstock is not none %}
|
||||
<span class="thumblist-stock">{{ pstock }}</span>
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<a href="/touchkey?uid={{ user.id }}&username={{ user.name }}">
|
||||
<span class="thumblist-title">{{ user.name }}</span><br/>
|
||||
<div class="imgcontainer">
|
||||
<img src="/static/upload/thumbnails/users/{{ user.id }}.png" alt="Avatar of {{ user.name }}" draggable="false"/>
|
||||
<img src="/static/upload/thumbnails/users/{{ user.id }}.png?cacheBuster={{ now }}" alt="Avatar of {{ user.name }}" draggable="false"/>
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
|
Loading…
Reference in a new issue