From 2a163fe6a455b3200b0d8deb663abb81135ba65a Mon Sep 17 00:00:00 2001 From: Tomas 'Jethro' Pokorny Date: Thu, 3 Dec 2015 00:07:23 +0100 Subject: [PATCH] Skoro hotova nova verze korekturovatka. Dodelany nektere vychytavky z nove verze oprafu. Nefunguje editace komentaru. Zamky a podobna havet neimplementovany. --- .../migrations/0002_auto_20151202_2351.py | 39 +++++++++ korektury/models.py | 6 +- korektury/static/korektury/imgs/comment.png | Bin 0 -> 726 bytes korektury/static/korektury/imgs/delete-gr.png | Bin 0 -> 593 bytes korektury/static/korektury/imgs/edit-gr.png | Bin 0 -> 973 bytes korektury/static/korektury/opraf.css | 27 +++++-- korektury/static/korektury/opraf.js | 35 ++++++-- korektury/templates/korektury/opraf.html | 76 +++++++++++++++--- korektury/views.py | 20 ++++- 9 files changed, 176 insertions(+), 27 deletions(-) create mode 100644 korektury/migrations/0002_auto_20151202_2351.py create mode 100644 korektury/static/korektury/imgs/comment.png create mode 100644 korektury/static/korektury/imgs/delete-gr.png create mode 100644 korektury/static/korektury/imgs/edit-gr.png diff --git a/korektury/migrations/0002_auto_20151202_2351.py b/korektury/migrations/0002_auto_20151202_2351.py new file mode 100644 index 00000000..ba88f7c7 --- /dev/null +++ b/korektury/migrations/0002_auto_20151202_2351.py @@ -0,0 +1,39 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('korektury', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='Komentar', + fields=[ + ('id', models.AutoField(serialize=False, primary_key=True)), + ('cas', models.DateTimeField(default=django.utils.timezone.now, help_text=b'\xc4\x8cas zad\xc3\xa1n\xc3\xad koment\xc3\xa1\xc5\x99e', verbose_name='\u010das koment\xe1\u0159e')), + ('autor', models.TextField(help_text=b'Autor koment\xc3\xa1\xc5\x99e', verbose_name='autor koment\xe1\u0159e', blank=True)), + ('text', models.TextField(help_text=b'Text koment\xc3\xa1\xc5\x99e', verbose_name='text koment\xe1\u0159e', blank=True)), + ('oprava', models.ForeignKey(to='korektury.Oprava')), + ], + options={ + 'ordering': ['cas'], + 'db_table': 'komentare', + 'verbose_name': 'Koment\xe1\u0159 k oprav\u011b', + 'verbose_name_plural': 'Koment\xe1\u0159e k oprav\u011b', + }, + bases=(models.Model,), + ), + migrations.RemoveField( + model_name='opravakomentar', + name='oprava', + ), + migrations.DeleteModel( + name='OpravaKomentar', + ), + ] diff --git a/korektury/models.py b/korektury/models.py index d5ea8203..80655739 100644 --- a/korektury/models.py +++ b/korektury/models.py @@ -98,9 +98,9 @@ class Oprava(models.Model): @reversion.register(ignore_duplicate_revision=True) @python_2_unicode_compatible -class OpravaKomentar(models.Model): +class Komentar(models.Model): class Meta: - db_table = 'opravy_komentare' + db_table = 'komentare' verbose_name = u'Komentář k opravě' verbose_name_plural = u'Komentáře k opravě' ordering = ['cas'] @@ -108,7 +108,7 @@ class OpravaKomentar(models.Model): #Interní ID id = models.AutoField(primary_key = True) - cas = models.DateTimeField(u'čas komentáře',help_text = 'Čas zadání komentáře') + cas = models.DateTimeField(u'čas komentáře',default=timezone.now,help_text = 'Čas zadání komentáře') oprava = models.ForeignKey(Oprava) # TODO: Změnit na cizí klíč do orgů diff --git a/korektury/static/korektury/imgs/comment.png b/korektury/static/korektury/imgs/comment.png new file mode 100644 index 0000000000000000000000000000000000000000..4a64842599e60dc4a1b5bab57d7b95fa5657ca2d GIT binary patch literal 726 zcmV;{0xA88P)JYBCkU**+i6q@ZY=e;ALaZ(%o}i7f5JXUmU?(DqLAhLVr^kKl-RtPiH@Y*dzLTJP8~^u8 zJipkSJRh8^>*(3*|p-I&WRNhmmqZ2)KBeL1sy8rO`qm$hkRxQAjLAdzb*yCxaWKoeyfw5YBi>koHAF1IT0*e+V2QyJvFvMi zrlzJ}->_>ErVUttEQ+X-L@8rTs$?BaR%C=JkLvce>l3!1^^TFkxVb1vg<%r%IG0t) zj4-JnDtI6E*p}*(x7Sic$(kslsO6t#5wZwHg)*LWW4rg*)>3YER2Oy#vMTE$BuOM4 zNy#E)9Z5)iMXfR%rnOhSm8-Tp%kXeaXM;0&hoJP8USGzV#~T%qX?|i0je&O(zgsFh6Sjw%7vuyvz6aIhk2KOsaFO1WvfB*mh07*qo IM6N<$f+{yuQUCw| literal 0 HcmV?d00001 diff --git a/korektury/static/korektury/imgs/delete-gr.png b/korektury/static/korektury/imgs/delete-gr.png new file mode 100644 index 0000000000000000000000000000000000000000..c9816e47054926daa2b7ed514aa7c3b9ed32c5d1 GIT binary patch literal 593 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!60wlNoGJgf6SkfJR9T^xl_H+M9WCik>lDyqr z82-2SpV<%Ov6p!Iy0YKrmgH5@3z!|0!oa}T>gnPbqH*4~e{Y_!qe$!in=`k{Hoak7 zsKM%Y$05e$)Y8wVcrPz?dc?cHc>RPf^ApN5_;gm4EJ+mMl-6{)cp*6Akn5?l{ldpj zy$iVUY})gA#b0E33kr5z_wG|S{uiHizvkZSIr7bI{eSP?TT;9Gf6j(YDc`2vud{t; z5?$Z-<>14-_w1Hi&lc4u8_aY}JDPu5l7Gpj)U%=49)6yUQ!l0S9mzkbsmkE$UHV4& ze+ZWn>%`L^nwI@pq_Sv6+sfbz8+r4WDg+4$)&(<7%-m7DI7WAY-0xjeT$GBRxrnq_ zo1b!AyW{#_<(-eDT$|ijpSD>xMC#@TB|9~_Og}9X zUK8urak|R6D>3$3&Gn{JZ~F32a4s->v0$ZF*TDrlInB@Qd2{_Jvs5eBDN&JqYMPpw z*^7RkEcr86sMV?c2=C`WyYlaj!3&+HmaK93#sA*qYQi0j_zC5?ck?}ZPy5H;%idv8 zm3Owa^0#rk??3C?GDp7s-M(J_fqW%@_c6}v^LT)9q*~${QIe8al4_M)lnSI6j0_A- zbqx)5jf_GJ4XunVtc;Dd4GgUe3}ojWT7jY=H$NpatrE9}oWoTjKn)C@u6{1-oD!M< DiO=*k literal 0 HcmV?d00001 diff --git a/korektury/static/korektury/imgs/edit-gr.png b/korektury/static/korektury/imgs/edit-gr.png new file mode 100644 index 0000000000000000000000000000000000000000..e7ca04b8f358f7c7ade5f1588a668c5515c6b50e GIT binary patch literal 973 zcmeAS@N?(olHy`uVBq!ia0vp^0w65F0wkYiylDyqr z{{I(QZFm;Q<1FxqEC$jZVC;4>+YZQJFY)wsWxvlY$*W>*>$a^QsOgQTi(`nz>Doz^ z9#<+Q+UMVYXtDTe&+!#A%z9+6y z%v^l!ZAY-Qye|J5P3bcGmmfc5rWUCDc-!|!^+&&(MH07%?*-Acox7j=R*8o0I2af3 z&m^y`&Cz>u^>bf|C!d;=eq3fQ4}1Qvwo$ImOI*pDW8#kJj*`>Pcc;9F@pd#@qRCvN z!1AS+>GigY6aQY?r4pJiWSkT5MMlW1Ib2HcX-`ky-@jr%RyqC+xlq7#t^kx`JaT`%mEqlRkRAl#Jf0Y$|IdRUHdmo|+cMCoTCcW9Zvi|9nSb;||O9V{!a|TMQ z9eEk~ZoS{UsQX14VgL4PeYX9s$9z2M1Ghot-bm?HvBAgxYy4+Yk}fHm@X66SK3LtS zy{hN*7Dev$d&O5Um^UAg(R*6@RrhSs*}3wXZy)X`lH789LB@lbH}9ydo8EUh|IM+z zpB|qHVMrCev3>TWQbz8&4||P{XbC>hW&dCFVVA7m#_eZ5Tm9LV)N_3L?Ef1b*gj;l zAI-@zEpeS=y1sE?)dzjXhfd3PuHx(78+yO(2v_{KZRf3(nRi@1kjZf>p{H=qe-VSX z?H#8RG*-oHJvycL>az^*Uu`zMxjY-ba!#p{mD>B)f7?@5cfB^b zsMv1;%gt$ytFrGh8rF5M<2(O8BxkZ#)-9vu?iG`GF1=>4$Vw@C%6Vq$ROZc>HkO%2 zyp)WLi=TM?M)`$Zsc$B?1umO*kLRcK;qz<0+xImw-Mjcev+ZB#0~_9NTtCd&yPd~<*1%KK1h84^{7|2qW_~8)Or4#1X z$3+&N+!7NF%nGU{t`Q|Ei6yC4$wjF^iowXh&{WsZP}j&P#L&>n*uu)#SlhtR%D_N& h-k}vJ8glbfGSez?YsfiVB?8pI;OXk;vd$@?2>`5=td9Ty literal 0 HcmV?d00001 diff --git a/korektury/static/korektury/opraf.css b/korektury/static/korektury/opraf.css index d385932c..dce8716d 100644 --- a/korektury/static/korektury/opraf.css +++ b/korektury/static/korektury/opraf.css @@ -1,3 +1,10 @@ +body{background: #f3f3f3; color: black;} +body.locked { + background: rgb(144, 189, 255); +} + +img{background:white;} + .pointer-hi, .pointer, .pointer-done, @@ -82,11 +89,6 @@ form { background-color: yellow; } -body { - background-color: #b0b0ff; -} - - .box button, .box img, @@ -103,3 +105,18 @@ body { .box-done button:hover { border: 1px solid black; } + +.comment hr { + height: 0px; +} + +.corr-header { + overflow: auto; +} + +.author { + font-weight: bold; + float: left; + margin-top: 3px; +} + diff --git a/korektury/static/korektury/opraf.js b/korektury/static/korektury/opraf.js index 60764ca1..284a6864 100644 --- a/korektury/static/korektury/opraf.js +++ b/korektury/static/korektury/opraf.js @@ -113,22 +113,45 @@ function img_click(element, ev) { return show_form(img_id, dx, dy, '', '', '', ''); } -// show comment form, when 'edit' button pressed -function box_edit(button) +// show comment form, when 'edit' or 'comment' button pressed +function box_edit(button, action) { - var divbox = button.parentNode.parentNode.parentNode; + var divbox = button.parentNode.parentNode.parentNode.parentNode; var id = divbox.id; //alert("id: " + id); var divpointer = document.getElementById(divbox.id + '-pointer'); - var text_el = document.getElementById(divbox.id + '-text'); - var text = text_el.innerHTML.unescapeHTML(); + + var text; + if (action == 'update') { + var text_el = document.getElementById(divbox.id + '-text'); + text = text_el.innerHTML.unescapeHTML(); + } else { + text = ''; + } var dx = parseInt(divpointer.style.left); var dy = parseInt(divpointer.style.top); //alert('not yet 2:' + text + text_el); // + divpointer.style.top "x" + divpo ); id = id.substring(2); - return show_form(divbox.img_id, dx, dy, id, text, 'update'); + return show_form(divbox.img_id, dx, dy, id, text, action); + +} + +// show comment form when 'update-comment' button pressed +function update_comment(button) +{ + var divbox = button.parentNode.parentNode.parentNode; + var id = divbox.id; + var divpointer = document.getElementById(divbox.id + '-pointer'); + var dx = parseInt(divpointer.style.left); + var dy = parseInt(divpointer.style.top); + + var commentdiv = button.parentNode.parentNode; + var id = commentdiv.id.substring(1); + + var text = document.getElementById('kt' + id).innerHTML.unescapeHTML(); + return show_form(divbox.img_id, dx, dy, id, text, 'update-comment'); } //fill up comment form and show him diff --git a/korektury/templates/korektury/opraf.html b/korektury/templates/korektury/opraf.html index c8b198fb..63069f63 100644 --- a/korektury/templates/korektury/opraf.html +++ b/korektury/templates/korektury/opraf.html @@ -61,30 +61,84 @@ onmouseover='box_onmouseover(this,{% if o.status = 'opraveno' %}1{% else %}0{% endif %})' onmouseout='box_onmouseout(this,{% if o.status = 'opraveno' %}1{% else %}0{% endif %})' > - - {{o.autor}} +
+
{{o.autor}}
{% csrf_token %} - + {% if o.komentare %} + + {% else %} + + {% endif %} + {% if o.status = 'opraveno' %} - + {% else %} - + {% endif %} - - - - + {% if o.komentare %} + + {% else %} + + {% endif %} + + + +
-
{{o.text}}
+
+ +
{{o.text}}
+ {% for k in o.komentare %} +
+
+
+
{{k.autor}}
+
+
+ {% csrf_token %} + + + + +
+ +
+
+
{{k.text}}
+
+ {% endfor %} -
+ {% endfor %} diff --git a/korektury/views.py b/korektury/views.py index 14f95b57..4c13f849 100644 --- a/korektury/views.py +++ b/korektury/views.py @@ -9,7 +9,7 @@ from django.utils.translation import ugettext as _ from django.http import Http404 from django.http import HttpResponseRedirect -from .models import Oprava +from .models import Oprava,Komentar from .forms import OpravaForm from datetime import timedelta, date, datetime @@ -65,7 +65,20 @@ class KorekturyView(generic.TemplateView): op = Oprava.objects.filter(id=id).first() op.status = op.STATUS_OPRAVENO op.save() + elif (action == u'comment'): + id = int(q.get('id')) + op = Oprava.objects.filter(id=id).first() + autor = q.get('au') + text = q.get('txt') + kom = Komentar(oprava=op,autor=autor,text=text) + kom.save() + elif (action == u'del-comment'): + id = int(q.get('id')) + kom = Komentar.objects.filter(id=id).first() + kom.delete() + +# return HttpResponse(u'Keys: %s '%(q.iteitems())) return HttpResponse(u'Oprav: %d, akce: %s'%( len(Oprava.objects.all()),action)) @@ -78,7 +91,10 @@ class KorekturyView(generic.TemplateView): context['img_name'] = "22_3_verze5" context['img_indexes'] = range(27) context['form_oprava'] = OpravaForm() - context['opravy'] = Oprava.objects.all() + opravy = Oprava.objects.all() + for o in opravy: + o.komentare = o.komentar_set.all() + context['opravy'] = opravy return context def form_valid(self,form): return super(KorekturyView,self).form_valid(form)