update: added force update button to admin page
This commit is contained in:
parent
484861eee5
commit
9d72dc1df4
5 changed files with 34 additions and 4 deletions
12
.env.template
Normal file
12
.env.template
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
export F42_CLIENT_ID=
|
||||
export F42_CLIENT_SECRET=
|
||||
export F42_BOCAL_KEY=a
|
||||
export F42_UPDATE_KEY=a
|
||||
|
||||
export F42_DEBUG=True
|
||||
export F42_DOMAIN=
|
||||
export F42_PORT=8080
|
||||
export F42_PROXY_DOMAIN=
|
||||
|
||||
export F42_REDIS_HOST=localhost
|
||||
export F42_REDIS_PORT=8091
|
||||
2
api42.py
2
api42.py
|
|
@ -24,8 +24,6 @@ class Api:
|
|||
|
||||
def get_token(self) -> bool:
|
||||
self.add_rate()
|
||||
print(f"{self.key=}")
|
||||
print(f"{self.secret=}")
|
||||
try:
|
||||
r = requests.post(
|
||||
f"{self.intra}/oauth/token",
|
||||
|
|
|
|||
|
|
@ -38,6 +38,7 @@ def admin(userid):
|
|||
tags=tags,
|
||||
piscines_dates=piscines_dates,
|
||||
custom_images=custom_images,
|
||||
update_key=config.update_key,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -67,7 +68,6 @@ def update_tutors(token):
|
|||
def update_user(login, userid):
|
||||
if not userid["admin"]:
|
||||
return "Not authorized", 401
|
||||
# 166 is the id of the badge Tutors
|
||||
with Db() as db:
|
||||
ret = db.get_user_profile(login, api)
|
||||
return ("OK", 200) if ret else ("Error", 503)
|
||||
|
|
|
|||
|
|
@ -83,4 +83,4 @@ log INFO "Mkdir redis directory: $(realpath ./redis)"
|
|||
mkdir -p ./redis
|
||||
cd ./redis || exit
|
||||
log INFO "Start redis-server in $(pwd)"
|
||||
exec $REDIS
|
||||
exec $REDIS --port "${F42_REDIS_PORT:-6379}"
|
||||
|
|
|
|||
|
|
@ -247,6 +247,10 @@
|
|||
<span class="badge badge-sm align-vertical bg-danger">{{ user.admin.tag | safe }}</span></h1>
|
||||
</div>
|
||||
|
||||
<div class="container mb-2 p-2 shadow rounded bg-body-tertiary text-center">
|
||||
<button class="btn btn-outline-danger text-center" onclick="updateLocation()">Force Refresh Clusters</button>
|
||||
<button class="btn btn-outline-danger text-center" onclick="updateTutors()">Force Refresh Tutors</button>
|
||||
</div>
|
||||
<div class="container mb-2 p-2 shadow rounded bg-body-tertiary">
|
||||
<form method="POST" id="changetagforme">
|
||||
<div class="input-group mb-3">
|
||||
|
|
@ -725,5 +729,21 @@
|
|||
}).catch(error => triggerToast(`Une erreur s'est produite (${error.status})`, false));
|
||||
});
|
||||
|
||||
const UPDATE_KEY={{ update_key|tojson }};
|
||||
|
||||
function updateLocation()
|
||||
{
|
||||
fetch(`/locations/${UPDATE_KEY}/1`).then(async response => {
|
||||
triggerToast("Locations has been refreshed", response.status === 200);
|
||||
}).catch(error => triggerToast(`Une erreur s'est produite (${error.status})`, false));
|
||||
}
|
||||
|
||||
function updateTutors()
|
||||
{
|
||||
fetch(`/admin/update/tutors/${UPDATE_KEY}`).then(async response => {
|
||||
triggerToast("Tutors has been refreshed", response.status === 200);
|
||||
}).catch(error => triggerToast(`Une erreur s'est produite (${error.status})`, false));
|
||||
}
|
||||
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue