From 8d09fd5389dc92f5d9a0a00c585ba598b1facf8b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= <jonas.havelka@volny.cz>
Date: Tue, 3 Dec 2024 19:10:36 +0100
Subject: [PATCH] =?UTF-8?q?Status=20opravy=20=C5=99e=C5=A1it=20p=C5=99es?=
 =?UTF-8?q?=20enum?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 korektury/templates/korektury/opraf.html | 16 ++++++++--------
 korektury/views.py                       | 19 ++-----------------
 2 files changed, 10 insertions(+), 25 deletions(-)

diff --git a/korektury/templates/korektury/opraf.html b/korektury/templates/korektury/opraf.html
index ec550b36..3b327d69 100644
--- a/korektury/templates/korektury/opraf.html
+++ b/korektury/templates/korektury/opraf.html
@@ -132,23 +132,23 @@
             <img src="{% static "korektury/imgs/delete.png"%}"/>
 					</button>
 					{% endif %} 
-					{% if o.status != 'k_oprave' %}
-					<button type='submit' name='action' value='undone' title='Označ jako neopravené'>
+					{% if o.status != o.STATUS.K_OPRAVE %}
+					<button type='submit' name='action' value='{{ o.STATUS.K_OPRAVE }}' title='Označ jako neopravené'>
             <img src="{% static "korektury/imgs/undo.png"%}"/>
 					</button>
 					{% endif %}
-					{% if o.status != 'opraveno' %}
-					<button type='submit' name='action' value='done' title='Označ jako opravené'>
+					{% if o.status != o.STATUS.OPRAVENO %}
+					<button type='submit' name='action' value='{{ o.STATUS.OPRAVENO }}' title='Označ jako opravené'>
             <img src="{% static "korektury/imgs/check.png"%}"/>
 					</button>
 					{% endif %}
-					{% if o.status != 'neni_chyba' %} 
-					<button type='submit' name='action' value='wontfix' title='Označ, že se nebude měnit'>
+					{% if o.status != o.STATUS.NENI_CHYBA %} 
+					<button type='submit' name='action' value='{{ o.STATUS.NENI_CHYBA }}' title='Označ, že se nebude měnit'>
             <img src="{% static "korektury/imgs/cross.png" %}"/>
 					</button>
 					{% endif %}
-					{% if o.status != 'k_zaneseni' %} 
-					<button type='submit' name='action' value='ready' title='Označ jako připraveno k zanesení'>
+					{% if o.status != o.STATUS.K_ZANESENI %} 
+					<button type='submit' name='action' value='{{ o.STATUS.K_ZANESENI }}' title='Označ jako připraveno k zanesení'>
             <img src="{% static "korektury/imgs/tex.png" %}"/>
 					</button>
 					{% endif %}
diff --git a/korektury/views.py b/korektury/views.py
index 861afac8..a89f9a79 100644
--- a/korektury/views.py
+++ b/korektury/views.py
@@ -94,25 +94,10 @@ class KorekturyView(generic.TemplateView):
 			op.autor = autor
 			op.text = text
 			op.save()
-		elif (action == 'undone'):
+		elif action in Oprava.STATUS.values:
 			id = int(q.get('id'))
 			op = Oprava.objects.get(id=id)
-			op.status = op.STATUS.K_OPRAVE
-			op.save()
-		elif (action == 'done'):
-			id = int(q.get('id'))
-			op = Oprava.objects.get(id=id)
-			op.status = op.STATUS.OPRAVENO
-			op.save()
-		elif (action == 'ready'):
-			id = int(q.get('id'))
-			op = Oprava.objects.get(id=id)
-			op.status = op.STATUS.K_ZANESENI
-			op.save()
-		elif (action == 'wontfix'):
-			id = int(q.get('id'))
-			op = Oprava.objects.get(id=id)
-			op.status = op.STATUS.NENI_CHYBA
+			op.status = action
 			op.save()
 		elif (action == 'comment'):
 			id = int(q.get('id'))