Aktualizování počtu korektur a zásluh
This commit is contained in:
parent
b99b4ffdc4
commit
0f1cd2e32a
6 changed files with 53 additions and 29 deletions
|
@ -35,6 +35,7 @@
|
||||||
#autor; #text;
|
#autor; #text;
|
||||||
htmlElement;
|
htmlElement;
|
||||||
id; oprava; {# komentar_data; #}
|
id; oprava; {# komentar_data; #}
|
||||||
|
autor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -66,7 +67,11 @@
|
||||||
this.set_text(komentar_data['text']);
|
this.set_text(komentar_data['text']);
|
||||||
};
|
};
|
||||||
|
|
||||||
set_autor(autor) {this.#autor.textContent=autor;};
|
set_autor(autor) {
|
||||||
|
this.#autor.textContent=autor;
|
||||||
|
this.autor = autor;
|
||||||
|
};
|
||||||
|
|
||||||
set_text(text) {
|
set_text(text) {
|
||||||
this.#text.innerHTML=text;
|
this.#text.innerHTML=text;
|
||||||
};
|
};
|
||||||
|
|
|
@ -151,7 +151,10 @@
|
||||||
fetch('{% url "korektury_api_oprava_stav" %}', {method: 'POST', body: data})
|
fetch('{% url "korektury_api_oprava_stav" %}', {method: 'POST', body: data})
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!response.ok) {alert('Něco se nepovedlo:' + response.statusText);}
|
if (!response.ok) {alert('Něco se nepovedlo:' + response.statusText);}
|
||||||
else response.json().then(data => this.set_status(data['status']));
|
else response.json().then(data => {
|
||||||
|
this.set_status(data['status']);
|
||||||
|
updatuj_pocty_stavu();
|
||||||
|
});
|
||||||
})
|
})
|
||||||
.catch(error => {alert('Něco se nepovedlo:' + error);});
|
.catch(error => {alert('Něco se nepovedlo:' + error);});
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,8 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updatuj_pocty_stavu();
|
||||||
|
updatuj_pocty_zasluh();
|
||||||
place_comments();
|
place_comments();
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
|
|
|
@ -3,26 +3,33 @@ Zobrazit:
|
||||||
id="k_oprave_checkbox"
|
id="k_oprave_checkbox"
|
||||||
name="k_oprave_checkbox"
|
name="k_oprave_checkbox"
|
||||||
onchange="toggle_corrections('k_oprave')" checked>
|
onchange="toggle_corrections('k_oprave')" checked>
|
||||||
<label for="k_oprave_checkbox">K opravě ({{k_oprave_cnt}})</label>
|
<label for="k_oprave_checkbox">K opravě (<span id="k_oprave_pocet">↺</span>)</label>
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
id="opraveno_checkbox"
|
id="opraveno_checkbox"
|
||||||
name="opraveno_checkbox"
|
name="opraveno_checkbox"
|
||||||
onchange="toggle_corrections('opraveno')" checked>
|
onchange="toggle_corrections('opraveno')" checked>
|
||||||
<label for="opraveno_checkbox">Opraveno ({{opraveno_cnt}})</label>
|
<label for="opraveno_checkbox">Opraveno (<span id="opraveno_pocet">↺</span>)</label>
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
id="neni_chyba_checkbox"
|
id="neni_chyba_checkbox"
|
||||||
name="neni_chyba_checkbox"
|
name="neni_chyba_checkbox"
|
||||||
onchange="toggle_corrections('neni_chyba')" checked>
|
onchange="toggle_corrections('neni_chyba')" checked>
|
||||||
<label for="neni_chyba_checkbox">Není chyba ({{neni_chyba_cnt}})</label>
|
<label for="neni_chyba_checkbox">Není chyba (<span id="neni_chyba_pocet">↺</span>)</label>
|
||||||
<input type="checkbox"
|
<input type="checkbox"
|
||||||
id="k_zaneseni_checkbox"
|
id="k_zaneseni_checkbox"
|
||||||
name="k_zaneseni_checkbox"
|
name="k_zaneseni_checkbox"
|
||||||
onchange="toggle_corrections('k_zaneseni')" checked>
|
onchange="toggle_corrections('k_zaneseni')" checked>
|
||||||
<label for="k_zaneseni_checkbox">K zanesení ({{k_zaneseni_cnt}})</label>
|
<label for="k_zaneseni_checkbox">K zanesení (<span id="k_zaneseni_pocet">↺</span>)</label>
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
const spany_s_pocty_stavu = {
|
||||||
|
'k_oprave': document.getElementById('k_oprave_pocet'),
|
||||||
|
'opraveno': document.getElementById('opraveno_pocet'),
|
||||||
|
'neni_chyba': document.getElementById('neni_chyba_pocet'),
|
||||||
|
'k_zaneseni': document.getElementById('k_zaneseni_pocet'),
|
||||||
|
}
|
||||||
|
|
||||||
function toggle_corrections(aclass)
|
function toggle_corrections(aclass)
|
||||||
{
|
{
|
||||||
const stylesheets = document.styleSheets;
|
const stylesheets = document.styleSheets;
|
||||||
|
@ -48,4 +55,13 @@ Zobrazit:
|
||||||
}
|
}
|
||||||
place_comments();
|
place_comments();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function updatuj_pocty_stavu() {
|
||||||
|
const pocty_stavu = {};
|
||||||
|
for (let oprava of Object.values(opravy)) {
|
||||||
|
if (!(oprava.status in pocty_stavu)) pocty_stavu[oprava.status] = 0;
|
||||||
|
pocty_stavu[oprava.status] += 1;
|
||||||
|
}
|
||||||
|
for (let [stav, pocet] of Object.entries(pocty_stavu)) spany_s_pocty_stavu[stav].innerText = pocet;
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -35,10 +35,27 @@
|
||||||
|
|
||||||
<hr/>
|
<hr/>
|
||||||
<p>
|
<p>
|
||||||
Děkujeme opravovatelům:
|
Děkujeme opravovatelům: <span id="pocty_autoru">↺</span></p>
|
||||||
{% for z in zasluhy %}
|
|
||||||
{{z.autor}} ({{z.pocet}}){% if not forloop.last %},{% endif %}
|
|
||||||
{% endfor %}</p>
|
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
const span_s_pocty_autoru = document.getElementById("pocty_autoru")
|
||||||
|
|
||||||
|
function updatuj_pocty_zasluh() {
|
||||||
|
const pocty_autoru = {};
|
||||||
|
for (let komentar of Object.values(komentare)) {
|
||||||
|
if (!(komentar.autor in pocty_autoru)) pocty_autoru[komentar.autor] = 0;
|
||||||
|
pocty_autoru[komentar.autor] += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
const setrizene = [];
|
||||||
|
for (const keyval of Object.entries(pocty_autoru)) setrizene.push(keyval);
|
||||||
|
setrizene.sort(function(a, b) {return a[1] - b[1];});
|
||||||
|
|
||||||
|
let ans = "";
|
||||||
|
for (let [autor, pocet] of setrizene) ans += `, ${autor} (${pocet})`;
|
||||||
|
span_s_pocty_autoru.innerHTML = ans.substring(2);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -125,31 +125,12 @@ class KorekturyView(generic.TemplateView):
|
||||||
context['img_path'] = settings.KOREKTURY_IMG_DIR
|
context['img_path'] = settings.KOREKTURY_IMG_DIR
|
||||||
context['img_indexes'] = range(self.pdf.stran)
|
context['img_indexes'] = range(self.pdf.stran)
|
||||||
opravy = Oprava.objects.filter(pdf=self.pdf_id)
|
opravy = Oprava.objects.filter(pdf=self.pdf_id)
|
||||||
zasluhy = {}
|
|
||||||
for o in opravy:
|
|
||||||
o.komentare = o.komentar_set.all()
|
|
||||||
for k in o.komentare:
|
|
||||||
if k.autor in zasluhy:
|
|
||||||
zasluhy[k.autor] += 1
|
|
||||||
else:
|
|
||||||
zasluhy[k.autor] = 1
|
|
||||||
zasluhy = [
|
|
||||||
{'autor': jmeno, 'pocet': pocet}
|
|
||||||
for (jmeno, pocet) in zasluhy.items()
|
|
||||||
]
|
|
||||||
zasluhy.sort(key=lambda z: z['pocet'], reverse=True)
|
|
||||||
|
|
||||||
strany = set(o.strana for o in opravy)
|
strany = set(o.strana for o in opravy)
|
||||||
opravy_na_stranu = [{'strana': s, 'op_id': opravy.filter(strana=s)} for s in strany]
|
opravy_na_stranu = [{'strana': s, 'op_id': opravy.filter(strana=s)} for s in strany]
|
||||||
context['opravy_strany'] = opravy_na_stranu
|
context['opravy_strany'] = opravy_na_stranu
|
||||||
|
|
||||||
context['k_oprave_cnt'] = opravy.filter(status='k_oprave').count()
|
|
||||||
context['opraveno_cnt'] = opravy.filter(status='opraveno').count()
|
|
||||||
context['neni_chyba_cnt'] = opravy.filter(status='neni_chyba').count()
|
|
||||||
context['k_zaneseni_cnt'] = opravy.filter(status='k_zaneseni').count()
|
|
||||||
|
|
||||||
context['opravy'] = opravy
|
context['opravy'] = opravy
|
||||||
context['zasluhy'] = zasluhy
|
|
||||||
|
|
||||||
context['tagy'] = KorekturaTag.objects.all()
|
context['tagy'] = KorekturaTag.objects.all()
|
||||||
return context
|
return context
|
||||||
|
|
Loading…
Reference in a new issue