From 7b9f08b1e213f1953a564e6722071fa9035af79b Mon Sep 17 00:00:00 2001 From: abc013 Date: Mon, 13 Oct 2025 22:44:05 +0200 Subject: [PATCH] Add automatic cleanup of local storage for saved forms of evaluations that have finished more than a year ago (closes (fixes e-valuation#2448) --- evap/static/ts/src/auto-form-saver.ts | 11 ++++ evap/student/templates/student_index.html | 64 +++++++++++++++++++++++ evap/student/templates/student_vote.html | 12 +++-- evap/student/urls.py | 1 + evap/student/views.py | 10 ++++ 5 files changed, 95 insertions(+), 3 deletions(-) diff --git a/evap/static/ts/src/auto-form-saver.ts b/evap/static/ts/src/auto-form-saver.ts index 633b102c7c..7f16584071 100644 --- a/evap/static/ts/src/auto-form-saver.ts +++ b/evap/static/ts/src/auto-form-saver.ts @@ -29,6 +29,13 @@ New portions and modifications are licensed under the conditions in LICENSE.md import { assert } from "./utils.js"; +type LocalStorageConstantsDictionary = Record; +export const localStorageConstants: LocalStorageConstantsDictionary = { + "local-storage-key-last-saved-at": "student-vote-last-saved-at", + "local-storage-key-language": "student-vote-language", + "local-storage-key-form-data": "student-vote", +}; + interface AutoFormSaverOptions { href: string; customKeySuffix: string; @@ -80,6 +87,10 @@ export class AutoFormSaver { getPrefix(field: Element) { return ( + localStorageConstants["local-storage-key-form-data"] + + "-" + + this.options.href.split("/").slice(-1)[0] + + "-" + this.options.href + this.target.id + this.target.name + diff --git a/evap/student/templates/student_index.html b/evap/student/templates/student_index.html index c31426427a..95cb6bfead 100644 --- a/evap/student/templates/student_index.html +++ b/evap/student/templates/student_index.html @@ -1,5 +1,6 @@ {% extends 'base.html' %} +{% load static %} {% load infotext_templatetags %} {% load evaluation_filters %} @@ -31,3 +32,66 @@ {% endif %} {% include 'student_index_semester_evaluations_list.html' %} {% endblock %} + +{% block additional_javascript %} + {% if not preview %} + + {% endif %} +{% endblock %} diff --git a/evap/student/templates/student_vote.html b/evap/student/templates/student_vote.html index c64ece197c..5dfd6b45cc 100644 --- a/evap/student/templates/student_vote.html +++ b/evap/student/templates/student_vote.html @@ -228,12 +228,12 @@

{{ text_answer_warnings|text_answer_warning_trigger_strings|json_script:'text-answer-warnings' }}