Compare commits
16 Commits
master
...
korekturov
Author | SHA1 | Date |
---|---|---|
Jonas Havelka | dd86fc1fcb | 2 weeks ago |
Jonas Havelka | 341ae7ce45 | 2 weeks ago |
Jonas Havelka | 7906c87733 | 2 weeks ago |
Jonas Havelka | daf24ff981 | 2 weeks ago |
Jonas Havelka | 0dde05f102 | 2 weeks ago |
Jonas Havelka | 3528a44d3c | 2 weeks ago |
Jonas Havelka | 524593b7ef | 2 weeks ago |
Jonas Havelka | 22e88daf02 | 3 weeks ago |
Jonas Havelka | 04508206bb | 3 weeks ago |
Jonas Havelka | 8d09fd5389 | 3 weeks ago |
Jonas Havelka | 9df34c22e0 | 3 weeks ago |
Jonas Havelka | d3d5484d0e | 3 weeks ago |
Jonas Havelka | 62160e8440 | 3 weeks ago |
Jonas Havelka | 1e6e6118a7 | 3 weeks ago |
Jonas Havelka | c1440687aa | 3 weeks ago |
Jonas Havelka | 69e870f958 | 3 weeks ago |
23 changed files with 465 additions and 415 deletions
@ -0,0 +1,7 @@ |
|||
from django.apps import AppConfig |
|||
|
|||
|
|||
class ApiConfig(AppConfig): |
|||
default_auto_field = 'django.db.models.BigAutoField' |
|||
name = 'korektury.api' |
|||
label = 'korektury_api' # Protože jedno api už máme. |
@ -0,0 +1,7 @@ |
|||
from django.urls import path |
|||
from personalni.utils import org_required |
|||
from . import views |
|||
|
|||
urlpatterns = [ |
|||
path('korektury/api/<int:pdf_id>/stav', org_required(views.korektury_stav_view), name='korektury_api_pdf_stav'), |
|||
] |
@ -0,0 +1,20 @@ |
|||
from django.http import HttpResponseForbidden, JsonResponse |
|||
from django.shortcuts import get_object_or_404 |
|||
from django.views.decorators.csrf import csrf_exempt |
|||
|
|||
from rest_framework import serializers |
|||
|
|||
from korektury.utils import send_email_notification_komentar |
|||
from korektury.models import Oprava, KorekturovanePDF, Komentar |
|||
from personalni.models import Organizator, Osoba |
|||
|
|||
|
|||
def korektury_stav_view(request, pdf_id: int, **kwargs): |
|||
q = request.POST |
|||
pdf = get_object_or_404(KorekturovanePDF, id=pdf_id) |
|||
status = q.get('state') |
|||
if status is not None: |
|||
assert status in KorekturovanePDF.STATUS.values |
|||
pdf.status = status |
|||
pdf.save() |
|||
return JsonResponse({'status': pdf.status}) |
@ -1,14 +0,0 @@ |
|||
from django import forms |
|||
|
|||
class OpravaForm(forms.Form): |
|||
""" formulář k přidání opravy (:class:`korektury.models.Oprava`) """ |
|||
text = forms.CharField(max_length=256) |
|||
autor = forms.CharField(max_length=20) |
|||
x = forms.IntegerField() |
|||
y = forms.IntegerField() |
|||
scroll = forms.CharField(max_length=256) |
|||
pdf = forms.CharField(max_length=256) |
|||
img_id = forms.CharField(max_length=256) |
|||
id = forms.CharField(max_length=256) |
|||
action = forms.CharField(max_length=256) |
|||
|
@ -0,0 +1,45 @@ |
|||
# Generated by Django 4.2.16 on 2024-12-12 10:25 |
|||
|
|||
from django.db import migrations |
|||
|
|||
import datetime |
|||
from django.utils import timezone |
|||
|
|||
|
|||
def oprava2komentar(apps, schema_editor): |
|||
Oprava = apps.get_model('korektury', 'Oprava') |
|||
Komentar = apps.get_model('korektury', 'Komentar') |
|||
|
|||
for o in Oprava.objects.all(): |
|||
Komentar.objects.create(oprava=o, text=o.text, autor=o.autor, cas=timezone.make_aware(datetime.datetime.fromtimestamp(0))) |
|||
|
|||
def komentar2oprava(apps, schema_editor): |
|||
Oprava = apps.get_model('korektury', 'Oprava') |
|||
Komentar = apps.get_model('korektury', 'Komentar') |
|||
|
|||
for o in Oprava.objects.all(): |
|||
k = Komentar.objects.filter(oprava=o).first() |
|||
o.text = k.text |
|||
o.autor = k.autor |
|||
o.save() |
|||
k.delete() |
|||
|
|||
|
|||
|
|||
class Migration(migrations.Migration): |
|||
|
|||
dependencies = [ |
|||
('korektury', '0024_vic_orgu_k_pdf'), |
|||
] |
|||
|
|||
operations = [ |
|||
migrations.RunPython(oprava2komentar, komentar2oprava), |
|||
migrations.RemoveField( |
|||
model_name='oprava', |
|||
name='autor', |
|||
), |
|||
migrations.RemoveField( |
|||
model_name='oprava', |
|||
name='text', |
|||
), |
|||
] |
Before Width: | Height: | Size: 270 B After Width: | Height: | Size: 307 B |
@ -0,0 +1,17 @@ |
|||
<div id="commform-div"> |
|||
<form action='' onsubmit='save_scroll(this)' id="commform" method="POST"> |
|||
{% csrf_token %} |
|||
<input size="24" name="au" value="{{user.first_name}} {{user.last_name}}" readonly/> |
|||
<input type=submit value="Oprav!"/> |
|||
<button type="button" onclick="close_commform()">Zavřít</button> |
|||
<br/> |
|||
<textarea onkeypress="textarea_onkey(event);" id="commform-text" cols=40 rows=10 name="txt"></textarea> |
|||
<br/> |
|||
<input type="hidden" size="3" id="commform-x" name="x"/> |
|||
<input type="hidden" size="3" id="commform-y" name="y"/> |
|||
<input type="hidden" size="3" id="commform-img-id" name="img-id"/> |
|||
<input type="hidden" size="3" id="commform-id" name="id"/> |
|||
<input type="hidden" size="3" id="commform-action" name="action"/> |
|||
<input type="hidden" size="3" id="commform-action" name="scroll"/> |
|||
</form> |
|||
</div> |
@ -0,0 +1,24 @@ |
|||
{% load static %} |
|||
|
|||
<div class='comment' id='k{{k.id}}'> |
|||
<div class='corr-header'> |
|||
<div class='author'>{{k.autor}}</div> |
|||
<div class="float-right"> |
|||
<!-- Komentar !--> |
|||
<form action='' onsubmit='save_scroll(this)' method='POST'> |
|||
{% csrf_token %} |
|||
<input type='hidden' name='id' value='{{k.id}}'> |
|||
<input type='hidden' name='scroll'> |
|||
<button style="display: none" type='submit' name='action' value='del-comment' title='Smaž komentář' |
|||
onclick='return confirm("Opravdu smazat komentář?")'> |
|||
<img src="{% static "korektury/imgs/delete.png" %}"/> |
|||
</button> |
|||
</form> |
|||
<!-- /Komentar !--> |
|||
<button type='button' onclick="update_comment('op{{o.id}}','kt{{k.id}}');" title='Uprav komentář'> |
|||
<img src="{% static "korektury/imgs/edit.png"%}"/> |
|||
</button> |
|||
</div> |
|||
</div> |
|||
<div id='kt{{k.id}}'>{{k.text|linebreaks}}</div> |
|||
</div> |
@ -0,0 +1,69 @@ |
|||
{% load static %} |
|||
|
|||
<div onclick='img_click(this,event)' |
|||
id='op{{o.id}}-pointer' |
|||
class='pointer {{o.status}}'> |
|||
</div> |
|||
<div name='op{{o.id}}' id='op{{o.id}}' |
|||
class='box {{o.status}}' |
|||
onmouseover='box_onmouseover(this)' |
|||
onmouseout='box_onmouseout(this)'> |
|||
|
|||
<div class='corr-body' id='op{{o.id}}-body'> |
|||
|
|||
{% for k in o.komentare %} |
|||
{% include "korektury/korekturovatko/__komentar.html" %} |
|||
<hr> |
|||
{% endfor %} |
|||
</div> |
|||
<div class='corr-header'> |
|||
<span class='float-right'> |
|||
<span id='op{{o.id}}-buttons'> |
|||
<form action='' onsubmit='save_scroll(this)' method='POST'> |
|||
{% csrf_token %} |
|||
<input type='hidden' name='id' value='{{o.id}}'> |
|||
<input type='hidden' name='scroll'> |
|||
|
|||
<button style="display: none" type='submit' name='action' value='del' title='Smaž opravu'> |
|||
<img src="{% static "korektury/imgs/delete.png"%}"/> |
|||
</button> |
|||
{% 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 != 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 != 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 != 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 %} |
|||
</form> |
|||
|
|||
{% if o.status == 'opraveno' or o.status == 'neni_chyba' %} |
|||
<button type='button' title='Korekturu nelze komentovat, protože už je uzavřená'> |
|||
<img src="{% static "korektury/imgs/comment-gr.png" %}"/> |
|||
</button> |
|||
{% else %} |
|||
<button type='button' onclick='box_edit("op{{o.id}}", "comment");' title='Komentovat'> |
|||
<img src="{% static "korektury/imgs/comment.png" %}"/> |
|||
</button> |
|||
{% endif %} |
|||
|
|||
</span> |
|||
<button type='button' onclick='toggle_visibility("op{{o.id}}");' title='Skrýt/Zobrazit'> |
|||
<img id='op{{o.id}}-toggleimg' src="{% static "korektury/imgs/hide.png" %}"/> |
|||
</button> |
|||
|
|||
</span> |
|||
</div> |
|||
</div> |
@ -0,0 +1,30 @@ |
|||
{% include "korektury/korekturovatko/__edit_komentar.html" %} |
|||
|
|||
{% for i in img_indexes %} |
|||
<div class='imgdiv'> |
|||
<img |
|||
width='1021' height='1448' |
|||
onclick='img_click(this,event)' id='img-{{i}}' |
|||
src='/media/korektury/img/{{img_prefix}}-{{i}}.png' |
|||
alt='Strana {{ i|add:1 }}' |
|||
/> |
|||
</div> |
|||
|
|||
<hr/> |
|||
{% endfor %} |
|||
|
|||
|
|||
{% for o in opravy %} |
|||
{% include "korektury/korekturovatko/__oprava.html" %} |
|||
{% endfor %} |
|||
|
|||
<script> |
|||
var comments = [ |
|||
{% for s in opravy_strany %} |
|||
["img-{{s.strana}}", [{% for o in s.op_id %}["op{{o.id}}",{{o.x}},{{o.y}}],{% endfor %}[]]], |
|||
{% endfor %} |
|||
[]] |
|||
{% if scroll %} |
|||
window.scrollTo(0,{{scroll}}); |
|||
{% endif %} |
|||
</script> |
@ -0,0 +1,23 @@ |
|||
Zobrazit: |
|||
<input type="checkbox" |
|||
id="k_oprave_checkbox" |
|||
name="k_oprave_checkbox" |
|||
onchange="toggle_corrections('k_oprave')" checked> |
|||
<label for="k_oprave_checkbox">K opravě ({{k_oprave_cnt}})</label> |
|||
<input type="checkbox" |
|||
id="opraveno_checkbox" |
|||
name="opraveno_checkbox" |
|||
onchange="toggle_corrections('opraveno')" checked> |
|||
<label for="opraveno_checkbox">Opraveno ({{opraveno_cnt}})</label> |
|||
<input type="checkbox" |
|||
id="neni_chyba_checkbox" |
|||
name="neni_chyba_checkbox" |
|||
onchange="toggle_corrections('neni_chyba')" checked> |
|||
<label for="neni_chyba_checkbox">Není chyba ({{neni_chyba_cnt}})</label> |
|||
<input type="checkbox" |
|||
id="k_zaneseni_checkbox" |
|||
name="k_zaneseni_checkbox" |
|||
onchange="toggle_corrections('k_zaneseni')" checked> |
|||
<label for="k_zaneseni_checkbox">K zanesení ({{k_zaneseni_cnt}})</label> |
|||
|
|||
<hr/> |
@ -0,0 +1,45 @@ |
|||
<h4>Změnit stav PDF:</h4> |
|||
<i>Aktuální: {{pdf.status}}</i> |
|||
<br> |
|||
<form method="post" id="PDFSTAV_FORM"> |
|||
{% csrf_token %} |
|||
<input type="radio" name="state" value="{{ pdf.STATUS.PRIDAVANI }}" {% if pdf.status == pdf.STATUS.PRIDAVANI %} checked {% endif %}>Přidávání korektur |
|||
<br> |
|||
<input type="radio" name="state" value="{{ pdf.STATUS.ZANASENI }}" {% if pdf.status == pdf.STATUS.ZANASENI %} checked {% endif %}>Zanášení korektur |
|||
<br> |
|||
<input type="radio" name="state" value="{{ pdf.STATUS.ZASTARALE }}" {% if pdf.status == pdf.STATUS.ZASTARALE %} checked {% endif %}>Zastaralé, nekorigovat |
|||
<br> |
|||
<input type='submit' value='Změnit stav PDF'/> |
|||
</form> |
|||
|
|||
<script> |
|||
const pdfstav_form = document.getElementById('PDFSTAV_FORM'); |
|||
const csrf_form = document.getElementById('CSRF_FORM'); |
|||
|
|||
/** |
|||
* |
|||
* @param {RequestInit} data |
|||
* @param {Boolean} catchError |
|||
*/ |
|||
function fetchStav(data, catchError=true) { |
|||
fetch("{% url 'korektury_api_pdf_stav' pdf.id %}", data |
|||
) |
|||
.then(response => { |
|||
if (!response.ok) { if (catchError) alert("Něco se nepovedlo:" + response.statusText);} |
|||
else response.json().then(data => document.body.dataset.status = data["status"]); |
|||
}) |
|||
.catch(error => {if (catchError) alert("Něco se nepovedlo:" + error);}); |
|||
} |
|||
|
|||
pdfstav_form.addEventListener('submit', async event => { |
|||
event.preventDefault(); |
|||
|
|||
const data = new FormData(pdfstav_form); |
|||
fetchStav({method: "POST", body: data}); |
|||
}); |
|||
|
|||
|
|||
// FIXME není mi jasné, zda v {} nemá být `cache: "no-store"`, aby prohlížeč necachoval get. |
|||
setInterval(() => fetchStav({}, false), 30000); // Každou půl minutu fetchni stav |
|||
</script> |
|||
|
@ -0,0 +1,44 @@ |
|||
{% load static %} |
|||
|
|||
<html> |
|||
<head> |
|||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
|||
<link rel="stylesheet" title="opraf-css" type="text/css" media="screen, projection" href="{% static "korektury/opraf.css"%}" /> |
|||
<link href="{% static 'css/rozliseni.css' %}?version=1" rel="stylesheet"> |
|||
<script src="{% static "korektury/opraf.js"%}"></script> |
|||
<title>Korektury {{pdf.nazev}}</title> |
|||
</head> |
|||
<body class="{{ LOCAL_TEST_PROD }}web" data-status="{{ pdf.status }}" onload='place_comments()'> |
|||
|
|||
<h1>Korektury {{pdf.nazev}}</h1> |
|||
|
|||
<h2 class="textzanaseni"> Probíhá zanášení korektur, zvažte, zda chcete přidávat nové </h2> |
|||
<h2 class="textzastarale"> Toto PDF je již zastaralé, nepřidávejte nové korektury </h2> |
|||
|
|||
<i>{{pdf.komentar}}</i> |
|||
<br> |
|||
<i>Klikni na chybu, napiš komentář</i> | |
|||
<a href="{{pdf.pdf.url}}">stáhnout PDF (bez korektur)</a> | |
|||
<a href="../">seznam souborů</a> | |
|||
<a href="/admin/korektury/korekturovanepdf/">Spravovat PDF</a> | |
|||
<a href="../help">nápověda</a> | |
|||
| |
|||
<a href="/">hlavní stránka</a> | |
|||
<a href="https://mam.mff.cuni.cz/wiki">wiki</a> | |
|||
<hr /> |
|||
|
|||
{% include "korektury/korekturovatko/_schovani_korektur.html" %} |
|||
|
|||
{% include "korektury/korekturovatko/_main.html" %} |
|||
|
|||
{% include "korektury/korekturovatko/_zmena_stavu.html" %} |
|||
|
|||
<hr/> |
|||
<p> |
|||
Děkujeme opravovatelům: |
|||
{% for z in zasluhy %} |
|||
{{z.autor}} ({{z.pocet}}){% if not forloop.last %},{% endif %} |
|||
{% endfor %}</p> |
|||
<hr> |
|||
</body> |
|||
</html> |
@ -1,244 +0,0 @@ |
|||
{% load static %} |
|||
|
|||
<html> |
|||
<head> |
|||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
|||
<link rel="stylesheet" title="opraf-css" type="text/css" media="screen, projection" href="{% static "korektury/opraf.css"%}" /> |
|||
<link href="{% static 'css/rozliseni.css' %}?version=1" rel="stylesheet"> |
|||
<script src="{% static "korektury/opraf.js"%}"></script> |
|||
<title>Korektury {{pdf.nazev}}</title> |
|||
</head> |
|||
<body class="{{ LOCAL_TEST_PROD }}web{% if pdf.status == 'zanaseni'%} comitting{% elif pdf.status == 'zastarale' %} deprecated{% endif %}" onload='place_comments()'> |
|||
<h1>Korektury {{pdf.nazev}}</h1> |
|||
{% if pdf.status == 'zanaseni' %} <h2> Probíhá zanášení korektur, zvažte, zda chcete přidávat nové </h2> {% endif %} |
|||
{% if pdf.status == 'zastarale' %} <h2> Toto PDF je již zastaralé, nepřidávejte nové korektury </h2> {% endif %} |
|||
<i>{{pdf.komentar}}</i> |
|||
<br> |
|||
<i>Klikni na chybu, napiš komentář</i> | |
|||
<a href="{{pdf.pdf.url}}">stáhnout PDF (bez korektur)</a> | |
|||
<a href="../">seznam souborů</a> | |
|||
<a href="/admin/korektury/korekturovanepdf/">Spravovat PDF</a> | |
|||
<a href="../help">nápověda</a> | |
|||
| |
|||
<a href="/">hlavní stránka</a> | |
|||
<a href="https://mam.mff.cuni.cz/wiki">wiki</a> | |
|||
<hr /> |
|||
Zobrazit: |
|||
<input type="checkbox" |
|||
id="k_oprave_checkbox" |
|||
name="k_oprave_checkbox" |
|||
onchange="toggle_corrections('k_oprave')" checked> |
|||
<label for="k_oprave_checkbox">K opravě ({{k_oprave_cnt}})</label> |
|||
<input type="checkbox" |
|||
id="opraveno_checkbox" |
|||
name="opraveno_checkbox" |
|||
onchange="toggle_corrections('opraveno')" checked> |
|||
<label for="opraveno_checkbox">Opraveno ({{opraveno_cnt}})</label> |
|||
<input type="checkbox" |
|||
id="neni_chyba_checkbox" |
|||
name="neni_chyba_checkbox" |
|||
onchange="toggle_corrections('neni_chyba')" checked> |
|||
<label for="neni_chyba_checkbox">Není chyba ({{neni_chyba_cnt}})</label> |
|||
<input type="checkbox" |
|||
id="k_zaneseni_checkbox" |
|||
name="k_zaneseni_checkbox" |
|||
onchange="toggle_corrections('k_zaneseni')" checked> |
|||
<label for="k_zaneseni_checkbox">K zanesení ({{k_zaneseni_cnt}})</label> |
|||
|
|||
<hr/> |
|||
|
|||
<div id="commform-div"> |
|||
<!-- Pridat korekturu / komentar !--> |
|||
<form action='' onsubmit='save_scroll(this)' id="commform" method="POST"> |
|||
{% csrf_token %} |
|||
<input size="24" name="au" value="{{user.first_name}} {{user.last_name}}" readonly/> |
|||
<input type=submit value="Oprav!"/> |
|||
<button type="button" onclick="close_commform()">Zavřít</button> |
|||
<br/> |
|||
<textarea onkeypress="textarea_onkey(event);" id="commform-text" cols=40 rows=10 name="txt"></textarea> |
|||
<br/> |
|||
<input type="hidden" size="3" name="pdf" value='{{pdf.id}}'/> |
|||
<input type="hidden" size="3" id="commform-x" name="x"/> |
|||
<input type="hidden" size="3" id="commform-y" name="y"/> |
|||
<input type="hidden" size="3" id="commform-img-id" name="img-id"/> |
|||
<input type="hidden" size="3" id="commform-id" name="id"/> |
|||
<input type="hidden" size="3" id="commform-action" name="action"/> |
|||
<input type="hidden" size="3" id="commform-action" name="scroll"/> |
|||
</form> |
|||
<!-- /Pridat korekturu / komentar !--> |
|||
</div> |
|||
|
|||
{% for i in img_indexes %} |
|||
<div class='imgdiv'> |
|||
<img width='1021' height='1448' |
|||
onclick='img_click(this,event)' id='img-{{i}}' |
|||
src='/media/korektury/img/{{img_prefix}}-{{i}}.png'/> |
|||
</div> |
|||
<hr/> |
|||
{% endfor %} |
|||
|
|||
<h4>Změnit stav PDF:</h4> |
|||
<i>Aktuální: {{pdf.status}}</i> |
|||
<br> |
|||
<!-- Zmenit stav PDF !--> |
|||
<form method="post"> |
|||
{% csrf_token %} |
|||
<input type='hidden' name='action' value='set-state'/> |
|||
<input type='hidden' name='pdf' value='{{pdf.id}}'/> |
|||
<input type="radio" name="state" value="adding" {% if pdf.status == 'pridavani' %} checked {% endif %}>Přidávání korektur |
|||
<br> |
|||
<input type="radio" name="state" value="comitting" {% if pdf.status == 'zanaseni' %} checked {% endif %}>Zanášení korektur |
|||
<br> |
|||
<input type="radio" name="state" value="deprecated" {% if pdf.status == 'zastarale' %} checked {% endif %}>Zastaralé, nekorigovat |
|||
<br> |
|||
<input type='submit' value='Změnit stav PDF'/> |
|||
</form> |
|||
|
|||
<!-- /Zmenit stav PDF !--> |
|||
<hr/> |
|||
<p> |
|||
Děkujeme opravovatelům: |
|||
{% for z in zasluhy %} |
|||
{{z.autor}} ({{z.pocet}}){% if not forloop.last %},{% endif %} |
|||
{% endfor %}</p> |
|||
<hr> |
|||
|
|||
{% for o in opravy %} |
|||
<div onclick='img_click(this,event)' |
|||
id='op{{o.id}}-pointer' |
|||
class='pointer {{o.status}}'> |
|||
</div> |
|||
<div name='op{{o.id}}' id='op{{o.id}}' |
|||
class='box {{o.status}}' |
|||
onmouseover='box_onmouseover(this)' |
|||
onmouseout='box_onmouseout(this)'> |
|||
|
|||
<div class='corr-header'> |
|||
<span class='author' id='op{{o.id}}-autor'>{{o.autor}}</span> |
|||
<span class='float-right'> |
|||
<span id='op{{o.id}}-buttons'> |
|||
<!-- Existujici korektura !--> |
|||
<form action='' onsubmit='save_scroll(this)' method='POST'> |
|||
{% csrf_token %} |
|||
<input type='hidden' name="au" value="{{o.autor}}"/> |
|||
<input type='hidden' name='pdf' value='{{pdf.id}}'> |
|||
<input type='hidden' name='id' value='{{o.id}}'> |
|||
<input type='hidden' name='scroll'> |
|||
|
|||
{% if o.komentare %} |
|||
<button name='action' value='del' type='button' |
|||
title="Opravu nelze smazat – už ji někdo okomentoval"> |
|||
<img src="{% static "korektury/imgs/delete-gr.png"%}"/> |
|||
</button> |
|||
{% else %} |
|||
<button type='submit' name='action' value='del' title='Smaž opravu'> |
|||
<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é'> |
|||
<img src="{% static "korektury/imgs/undo.png"%}"/> |
|||
</button> |
|||
{% endif %} |
|||
{% if o.status != 'opraveno' %} |
|||
<button type='submit' name='action' value='done' 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'> |
|||
<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í'> |
|||
<img src="{% static "korektury/imgs/tex.png" %}"/> |
|||
</button> |
|||
{% endif %} |
|||
</form> |
|||
<!-- /Existujici korektura !--> |
|||
|
|||
{% if o.komentare %} |
|||
<button type='button' title="Korekturu nelze upravit – už ji někdo okomentoval"> |
|||
<img src="{% static "korektury/imgs/edit-gr.png" %}"/> |
|||
</button> |
|||
{% else %} |
|||
<button type='button' onclick='box_edit("op{{o.id}}","update");' title='Oprav opravu'> |
|||
<img src="{% static "korektury/imgs/edit.png" %}"/> |
|||
</button> |
|||
{% endif %} |
|||
{% if o.status == 'opraveno' or o.status == 'neni_chyba' %} |
|||
<button type='button' title='Korekturu nelze komentovat, protože už je uzavřená'> |
|||
<img src="{% static "korektury/imgs/comment-gr.png" %}"/> |
|||
</button> |
|||
{% else %} |
|||
<button type='button' onclick='box_edit("op{{o.id}}", "comment");' title='Komentovat'> |
|||
<img src="{% static "korektury/imgs/comment.png" %}"/> |
|||
</button> |
|||
{% endif %} |
|||
|
|||
</span> |
|||
<button type='button' onclick='toggle_visibility("op{{o.id}}");' title='Skrýt/Zobrazit'> |
|||
<img src="{% static "korektury/imgs/hide.png" %}"/> |
|||
</button> |
|||
|
|||
</span> |
|||
</div> |
|||
<div class='corr-body' id='op{{o.id}}-body'> |
|||
<div id='op{{o.id}}-text'>{{o.text|linebreaks}}</div> |
|||
|
|||
{% for k in o.komentare %} |
|||
<hr> |
|||
<div class='comment' id='k{{k.id}}'> |
|||
<div class='corr-header'> |
|||
<div class='author'>{{k.autor}}</div> |
|||
<div class="float-right"> |
|||
<!-- Komentar !--> |
|||
<form action='' onsubmit='save_scroll(this)' method='POST'> |
|||
{% csrf_token %} |
|||
<input type='hidden' name='pdf' value='{{pdf.id}}'> |
|||
<input type='hidden' name='id' value='{{k.id}}'> |
|||
<input type='hidden' name='scroll'> |
|||
{% if forloop.last %} |
|||
<button type='submit' name='action' value='del-comment' title='Smaž komentář' |
|||
onclick='return confirm("Opravdu smazat komentář?")'> |
|||
<img src="{% static "korektury/imgs/delete.png" %}"/> |
|||
</button> |
|||
{% else %} |
|||
<button name='action' value='del-comment' type='button' |
|||
title="Komentář nelze smazat – existuje novější"> |
|||
<img src="{% static "korektury/imgs/delete-gr.png"%}"/> |
|||
</button> |
|||
{% endif %} |
|||
</form> |
|||
<!-- /Komentar !--> |
|||
{% if forloop.last %} |
|||
<button type='button' onclick="update_comment('op{{o.id}}','kt{{k.id}}');" title='Uprav komentář'> |
|||
<img src="{% static "korektury/imgs/edit.png"%}"/> |
|||
</button> |
|||
{% else %} |
|||
<button type='button' title="Komentář nelze upravit – existuje novější"> |
|||
<img src="{% static "korektury/imgs/edit-gr.png" %}"/> |
|||
</button> |
|||
{% endif %} |
|||
</div> |
|||
</div> |
|||
<div id='kt{{k.id}}'>{{k.text|linebreaks}}</div> |
|||
</div> |
|||
{% endfor %} |
|||
</div> |
|||
</div> |
|||
{% endfor %} |
|||
|
|||
<script> |
|||
var comments = [ |
|||
{% for s in opravy_strany %} |
|||
["img-{{s.strana}}", [{% for o in s.op_id %}["op{{o.id}}",{{o.x}},{{o.y}}],{% endfor %}[]]], |
|||
{% endfor %} |
|||
[]] |
|||
{% if scroll %} |
|||
window.scrollTo(0,{{scroll}}); |
|||
{% endif %} |
|||
</script> |
|||
</body> |
|||
</html> |
@ -0,0 +1,53 @@ |
|||
from django.core.mail import EmailMessage |
|||
from django.http import HttpRequest |
|||
from django.urls import reverse |
|||
|
|||
from korektury.models import Komentar, Oprava |
|||
from personalni.models import Organizator |
|||
|
|||
|
|||
def send_email_notification_komentar(oprava: Oprava, autor: Organizator, request: HttpRequest): |
|||
''' Rozesle e-mail pri pridani komentare / opravy, |
|||
ktery obsahuje text vlakna opravy. |
|||
''' |
|||
|
|||
# parametry e-mailu |
|||
#odkaz = "https://mam.mff.cuni.cz/korektury/{}/".format(oprava.pdf.pk) |
|||
odkaz = request.build_absolute_uri(reverse('korektury', kwargs={'pdf': oprava.pdf.pk})) |
|||
odkaz = f"{odkaz}#op{oprava.id}-pointer" |
|||
from_email = 'korekturovatko@mam.mff.cuni.cz' |
|||
subject = 'Nová korektura od {} v {}'.format(autor, oprava.pdf.nazev) |
|||
texty = [] |
|||
for kom in Komentar.objects.filter(oprava=oprava): |
|||
texty.append((kom.autor.osoba.plne_jmeno(),kom.text)) |
|||
optext = "\n\n\n".join([": ".join(t) for t in texty]) |
|||
text = u"Text komentáře:\n\n{}\n\n=== Konec textu komentáře ===\n\ |
|||
\nodkaz do korekturovátka: {}\n\ |
|||
\nVaše korekturovátko\n".format(optext, odkaz) |
|||
|
|||
# Prijemci e-mailu |
|||
emails = set() |
|||
|
|||
# nalezeni e-mailu na autory komentaru |
|||
for komentar in oprava.komentar_set.all(): |
|||
email_komentujiciho = komentar.autor.osoba.email |
|||
if email_komentujiciho: |
|||
emails.add(email_komentujiciho) |
|||
|
|||
# zodpovedni orgove |
|||
for org in oprava.pdf.orgove.all(): |
|||
email_zobpovedny = org.osoba.email |
|||
if email_zobpovedny: |
|||
emails.add(email_zobpovedny) |
|||
|
|||
# odstran e-mail autora opravy |
|||
email = autor.osoba.email |
|||
if email: |
|||
emails.discard(email) |
|||
|
|||
EmailMessage( |
|||
subject=subject, |
|||
body=text, |
|||
from_email=from_email, |
|||
to=list(emails), |
|||
).send() |
Loading…
Reference in new issue