Compare commits
No commits in common. "de0f0d304087968114e6deb441c2ce473c5835d2" and "0f1cd2e32aa6643843016a3e3b4e902039713306" have entirely different histories.
de0f0d3040
...
0f1cd2e32a
5 changed files with 90 additions and 19 deletions
|
@ -3,7 +3,7 @@
|
||||||
<img
|
<img
|
||||||
id='img-{{i}}'
|
id='img-{{i}}'
|
||||||
width='1021' height='1448'
|
width='1021' height='1448'
|
||||||
src='/media/korektury/img/{{korekturovanepdf.get_prefix}}-{{i}}.png'
|
src='/media/korektury/img/{{img_prefix}}-{{i}}.png'
|
||||||
alt='Strana {{ i|add:1 }}'
|
alt='Strana {{ i|add:1 }}'
|
||||||
class="strana"
|
class="strana"
|
||||||
/>
|
/>
|
||||||
|
@ -14,9 +14,6 @@
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// Mapování stránka -> korektury
|
// Mapování stránka -> korektury
|
||||||
/**
|
|
||||||
* @type {Object.<number, Array<Oprava>>}
|
|
||||||
*/
|
|
||||||
const comments = {
|
const comments = {
|
||||||
{% for s in img_indexes %}
|
{% for s in img_indexes %}
|
||||||
{{s}}: []{% if not forloop.last %},{% endif %}
|
{{s}}: []{% if not forloop.last %},{% endif %}
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
* @param pri_uspechu Akce, která se má provést při úspěchu (speciálně zavřít formulář)
|
* @param pri_uspechu Akce, která se má provést při úspěchu (speciálně zavřít formulář)
|
||||||
*/
|
*/
|
||||||
function update_all(data={}, catchError=true, pri_uspechu=null) { // FIXME není mi jasné, zda v {} nemá být `cache: "no-store"`, aby prohlížeč necachoval GET.
|
function update_all(data={}, catchError=true, pri_uspechu=null) { // FIXME není mi jasné, zda v {} nemá být `cache: "no-store"`, aby prohlížeč necachoval GET.
|
||||||
fetch('{% url "korektury_api_opravy_a_komentare" korekturovanepdf.id %}', data)
|
fetch('{% url "korektury_api_opravy_a_komentare" pdf.id %}', data)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!response.ok && catchError) {alert('Něco se nepovedlo:' + response.statusText);}
|
if (!response.ok && catchError) {alert('Něco se nepovedlo:' + response.statusText);}
|
||||||
else response.json().then(data => {
|
else response.json().then(data => {
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
<h4>Změnit stav PDF:</h4>
|
<h4>Změnit stav PDF:</h4>
|
||||||
<i>Aktuální: {{korekturovanepdf.status}}</i>
|
<i>Aktuální: {{pdf.status}}</i>
|
||||||
<br>
|
<br>
|
||||||
<form method="post" id="PDFSTAV_FORM">
|
<form method="post" id="PDFSTAV_FORM">
|
||||||
{% csrf_token %}
|
{% csrf_token %}
|
||||||
<input type="radio" name="state" value="{{ korekturovanepdf.STATUS.PRIDAVANI }}" {% if korekturovanepdf.status == korekturovanepdf.STATUS.PRIDAVANI %} checked {% endif %}>Přidávání korektur
|
<input type="radio" name="state" value="{{ pdf.STATUS.PRIDAVANI }}" {% if pdf.status == pdf.STATUS.PRIDAVANI %} checked {% endif %}>Přidávání korektur
|
||||||
<br>
|
<br>
|
||||||
<input type="radio" name="state" value="{{ korekturovanepdf.STATUS.ZANASENI }}" {% if korekturovanepdf.status == korekturovanepdf.STATUS.ZANASENI %} checked {% endif %}>Zanášení korektur
|
<input type="radio" name="state" value="{{ pdf.STATUS.ZANASENI }}" {% if pdf.status == pdf.STATUS.ZANASENI %} checked {% endif %}>Zanášení korektur
|
||||||
<br>
|
<br>
|
||||||
<input type="radio" name="state" value="{{ korekturovanepdf.STATUS.ZASTARALE }}" {% if korekturovanepdf.status == korekturovanepdf.STATUS.ZASTARALE %} checked {% endif %}>Zastaralé, nekorigovat
|
<input type="radio" name="state" value="{{ pdf.STATUS.ZASTARALE }}" {% if pdf.status == pdf.STATUS.ZASTARALE %} checked {% endif %}>Zastaralé, nekorigovat
|
||||||
<br>
|
<br>
|
||||||
<input type='submit' value='Změnit stav PDF'/>
|
<input type='submit' value='Změnit stav PDF'/>
|
||||||
</form>
|
</form>
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
* @param {Boolean} catchError
|
* @param {Boolean} catchError
|
||||||
*/
|
*/
|
||||||
function fetchStav(data, catchError=true) {
|
function fetchStav(data, catchError=true) {
|
||||||
fetch("{% url 'korektury_api_pdf_stav' korekturovanepdf.id %}", data
|
fetch("{% url 'korektury_api_pdf_stav' pdf.id %}", data
|
||||||
)
|
)
|
||||||
.then(response => {
|
.then(response => {
|
||||||
if (!response.ok) { if (catchError) alert("Něco se nepovedlo:" + response.statusText);}
|
if (!response.ok) { if (catchError) alert("Něco se nepovedlo:" + response.statusText);}
|
||||||
|
|
|
@ -6,19 +6,19 @@
|
||||||
<link rel="stylesheet" title="opraf-css" type="text/css" media="screen, projection" href="{% static "korektury/opraf.css"%}?version=1" />
|
<link rel="stylesheet" title="opraf-css" type="text/css" media="screen, projection" href="{% static "korektury/opraf.css"%}?version=1" />
|
||||||
<link href="{% static 'css/rozliseni.css' %}?version=1" rel="stylesheet">
|
<link href="{% static 'css/rozliseni.css' %}?version=1" rel="stylesheet">
|
||||||
<script src="{% static "korektury/opraf.js"%}?version=1"></script>
|
<script src="{% static "korektury/opraf.js"%}?version=1"></script>
|
||||||
<title>Korektury {{korekturovanepdf.nazev}}</title>
|
<title>Korektury {{pdf.nazev}}</title>
|
||||||
</head>
|
</head>
|
||||||
<body class="{{ LOCAL_TEST_PROD }}web" data-status="{{ korekturovanepdf.status }}">
|
<body class="{{ LOCAL_TEST_PROD }}web" data-status="{{ pdf.status }}" onload='place_comments()'>
|
||||||
|
|
||||||
<h1>Korektury {{korekturovanepdf.nazev}}</h1>
|
<h1>Korektury {{pdf.nazev}}</h1>
|
||||||
|
|
||||||
<h2 class="textzanaseni"> Probíhá zanášení korektur, zvažte, zda chcete přidávat nové </h2>
|
<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>
|
<h2 class="textzastarale"> Toto PDF je již zastaralé, nepřidávejte nové korektury </h2>
|
||||||
|
|
||||||
<i>{{korekturovanepdf.komentar}}</i>
|
<i>{{pdf.komentar}}</i>
|
||||||
<br>
|
<br>
|
||||||
<i>Klikni na chybu, napiš komentář</i> |
|
<i>Klikni na chybu, napiš komentář</i> |
|
||||||
<a href="{{korekturovanepdf.pdf.url}}">stáhnout PDF (bez korektur)</a> |
|
<a href="{{pdf.pdf.url}}">stáhnout PDF (bez korektur)</a> |
|
||||||
<a href="../">seznam souborů</a> |
|
<a href="../">seznam souborů</a> |
|
||||||
<a href="/admin/korektury/korekturovanepdf/">Spravovat PDF</a> |
|
<a href="/admin/korektury/korekturovanepdf/">Spravovat PDF</a> |
|
||||||
<a href="../help">nápověda</a> |
|
<a href="../help">nápověda</a> |
|
||||||
|
|
|
@ -50,14 +50,88 @@ class KorekturySeskupeneListView(KorekturyAktualniListView):
|
||||||
return reversed(sorted(qs, key=lambda it: it.cislo_a_tema))
|
return reversed(sorted(qs, key=lambda it: it.cislo_a_tema))
|
||||||
|
|
||||||
### Korektury
|
### Korektury
|
||||||
class KorekturyView(generic.DetailView):
|
class KorekturyView(generic.TemplateView):
|
||||||
model = KorekturovanePDF
|
model = Oprava
|
||||||
pk_url_kwarg = "pdf"
|
|
||||||
template_name = 'korektury/korekturovatko/htmlstrana.html'
|
template_name = 'korektury/korekturovatko/htmlstrana.html'
|
||||||
|
|
||||||
|
def setup(self, request, *args, **kwargs):
|
||||||
|
super().setup(request, *args, **kwargs)
|
||||||
|
self.pdf_id = self.kwargs["pdf"]
|
||||||
|
self.pdf = get_object_or_404(KorekturovanePDF, id=self.pdf_id)
|
||||||
|
|
||||||
|
def post(self, request, *args, **kwargs):
|
||||||
|
q = request.POST
|
||||||
|
|
||||||
|
# prirazeni autora podle prihlaseni
|
||||||
|
autor_user = request.user
|
||||||
|
# pokud existuje ucet (user), ale neni to organizator = 403
|
||||||
|
autor = Organizator.objects.filter(osoba__user=autor_user).first()
|
||||||
|
if not autor:
|
||||||
|
return HttpResponseForbidden()
|
||||||
|
|
||||||
|
action = q.get('action')
|
||||||
|
if (action == ''): # Přidej
|
||||||
|
x = int(q.get('x'))
|
||||||
|
y = int(q.get('y'))
|
||||||
|
text = q.get('txt')
|
||||||
|
strana = int(q.get('img-id')[4:])
|
||||||
|
op = Oprava(x=x,y=y, strana=strana, pdf=self.pdf)
|
||||||
|
op.save()
|
||||||
|
kom = Komentar(oprava=op,autor=autor,text=text)
|
||||||
|
kom.save()
|
||||||
|
send_email_notification_komentar(op, autor, request)
|
||||||
|
elif (action == 'del'):
|
||||||
|
id = int(q.get('id'))
|
||||||
|
op = Oprava.objects.get(id=id)
|
||||||
|
for k in Komentar.objects.filter(oprava=op):
|
||||||
|
k.delete()
|
||||||
|
op.delete()
|
||||||
|
elif action in Oprava.STATUS.values:
|
||||||
|
id = int(q.get('id'))
|
||||||
|
op = Oprava.objects.get(id=id)
|
||||||
|
op.status = action
|
||||||
|
op.save()
|
||||||
|
elif (action == 'comment'):
|
||||||
|
id = int(q.get('id'))
|
||||||
|
op = Oprava.objects.get(id=id)
|
||||||
|
text = q.get('txt')
|
||||||
|
kom = Komentar(oprava=op,autor=autor,text=text)
|
||||||
|
kom.save()
|
||||||
|
send_email_notification_komentar(op, autor, request)
|
||||||
|
elif (action == 'update-comment'):
|
||||||
|
id = int(q.get('id'))
|
||||||
|
kom = Komentar.objects.get(id=id)
|
||||||
|
text = q.get('txt')
|
||||||
|
kom.text = text
|
||||||
|
kom.autor = autor
|
||||||
|
kom.save()
|
||||||
|
elif (action == 'del-comment'):
|
||||||
|
id = int(q.get('id'))
|
||||||
|
kom = Komentar.objects.get(id=id)
|
||||||
|
kom.delete()
|
||||||
|
elif (action == 'set-state'):
|
||||||
|
status = q.get('state')
|
||||||
|
assert status in KorekturovanePDF.STATUS.values
|
||||||
|
self.pdf.status = status
|
||||||
|
self.pdf.save()
|
||||||
|
context = self.get_context_data()
|
||||||
|
context['autor'] = autor
|
||||||
|
return render(request, 'korektury/korekturovatko/htmlstrana.html', context)
|
||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
context = super().get_context_data(**kwargs)
|
context = super().get_context_data(**kwargs)
|
||||||
context['img_indexes'] = range(self.object.stran)
|
context['pdf'] = self.pdf
|
||||||
|
context['img_prefix'] = self.pdf.get_prefix()
|
||||||
|
context['img_path'] = settings.KOREKTURY_IMG_DIR
|
||||||
|
context['img_indexes'] = range(self.pdf.stran)
|
||||||
|
opravy = Oprava.objects.filter(pdf=self.pdf_id)
|
||||||
|
|
||||||
|
strany = set(o.strana for o in opravy)
|
||||||
|
opravy_na_stranu = [{'strana': s, 'op_id': opravy.filter(strana=s)} for s in strany]
|
||||||
|
context['opravy_strany'] = opravy_na_stranu
|
||||||
|
|
||||||
|
context['opravy'] = opravy
|
||||||
|
|
||||||
context['tagy'] = KorekturaTag.objects.all()
|
context['tagy'] = KorekturaTag.objects.all()
|
||||||
return context
|
return context
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue