From 4a228f5ba70676b89c9c73ea01cb91c03b8b8e74 Mon Sep 17 00:00:00 2001 From: Tomas 'Jethro' Pokorny Date: Tue, 1 Dec 2015 22:18:28 +0100 Subject: [PATCH 01/23] Vyrobena kostra pro korektury. --- korektury/__init__.py | 0 korektury/admin.py | 3 +++ korektury/migrations/__init__.py | 0 korektury/models.py | 3 +++ korektury/tests.py | 3 +++ korektury/views.py | 3 +++ 6 files changed, 12 insertions(+) create mode 100644 korektury/__init__.py create mode 100644 korektury/admin.py create mode 100644 korektury/migrations/__init__.py create mode 100644 korektury/models.py create mode 100644 korektury/tests.py create mode 100644 korektury/views.py diff --git a/korektury/__init__.py b/korektury/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/korektury/admin.py b/korektury/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/korektury/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/korektury/migrations/__init__.py b/korektury/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/korektury/models.py b/korektury/models.py new file mode 100644 index 00000000..71a83623 --- /dev/null +++ b/korektury/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/korektury/tests.py b/korektury/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/korektury/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/korektury/views.py b/korektury/views.py new file mode 100644 index 00000000..91ea44a2 --- /dev/null +++ b/korektury/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. From 7de6a7e614745c0ac043074ea43a2ca0d8ab424a Mon Sep 17 00:00:00 2001 From: Tomas 'Jethro' Pokorny Date: Tue, 1 Dec 2015 23:24:21 +0100 Subject: [PATCH 02/23] Prototyp korekturovatka v Djangu. --- .gitignore | 3 + korektury/forms.py | 13 ++ korektury/migrations/0001_initial.py | 63 ++++++ korektury/models.py | 122 ++++++++++- korektury/static/korektury/imgs/check.png | Bin 0 -> 697 bytes korektury/static/korektury/imgs/delete.png | Bin 0 -> 717 bytes korektury/static/korektury/imgs/edit.png | Bin 0 -> 1539 bytes korektury/static/korektury/imgs/link.png | Bin 0 -> 3462 bytes korektury/static/korektury/imgs/next-gr.png | Bin 0 -> 881 bytes korektury/static/korektury/imgs/next.png | Bin 0 -> 557 bytes korektury/static/korektury/imgs/undo.png | Bin 0 -> 617 bytes korektury/static/korektury/opraf.css | 105 ++++++++++ korektury/static/korektury/opraf.js | 213 ++++++++++++++++++++ korektury/static/korektury/png/.gitignore | 1 + korektury/static/korektury/tmp/.gitignore | 1 + korektury/templates/korektury/opraf.html | 97 +++++++++ korektury/urls.py | 7 + korektury/views.py | 55 ++++- mamweb/settings_common.py | 1 + mamweb/urls.py | 3 + 20 files changed, 682 insertions(+), 2 deletions(-) create mode 100644 korektury/forms.py create mode 100644 korektury/migrations/0001_initial.py create mode 100644 korektury/static/korektury/imgs/check.png create mode 100644 korektury/static/korektury/imgs/delete.png create mode 100644 korektury/static/korektury/imgs/edit.png create mode 100644 korektury/static/korektury/imgs/link.png create mode 100644 korektury/static/korektury/imgs/next-gr.png create mode 100644 korektury/static/korektury/imgs/next.png create mode 100644 korektury/static/korektury/imgs/undo.png create mode 100644 korektury/static/korektury/opraf.css create mode 100644 korektury/static/korektury/opraf.js create mode 100644 korektury/static/korektury/png/.gitignore create mode 100644 korektury/static/korektury/tmp/.gitignore create mode 100644 korektury/templates/korektury/opraf.html create mode 100644 korektury/urls.py diff --git a/.gitignore b/.gitignore index aefe158b..6b8b5c02 100644 --- a/.gitignore +++ b/.gitignore @@ -20,3 +20,6 @@ # secrets /django.secret + +# vim tmp files +*~ diff --git a/korektury/forms.py b/korektury/forms.py new file mode 100644 index 00000000..676d6b3a --- /dev/null +++ b/korektury/forms.py @@ -0,0 +1,13 @@ +from django import forms + +class OpravaForm(forms.Form): + 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) + diff --git a/korektury/migrations/0001_initial.py b/korektury/migrations/0001_initial.py new file mode 100644 index 00000000..22643689 --- /dev/null +++ b/korektury/migrations/0001_initial.py @@ -0,0 +1,63 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import korektury.models + + +class Migration(migrations.Migration): + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='KorekturovanePDF', + fields=[ + ('id', models.AutoField(serialize=False, primary_key=True)), + ('pdf', models.FileField(upload_to=korektury.models.generate_filename, verbose_name='pdf')), + ], + options={ + 'db_table': 'korekturovane_cislo', + 'verbose_name': 'PDF k oprav\xe1m', + 'verbose_name_plural': 'PDF k oprav\xe1m', + }, + bases=(models.Model,), + ), + migrations.CreateModel( + name='Oprava', + fields=[ + ('id', models.AutoField(serialize=False, primary_key=True)), + ('strana', models.IntegerField(help_text=b'Strana s opravou (od 0)', verbose_name='strana s opravou')), + ('x', models.IntegerField(verbose_name='x-ov\xe1 sou\u0159adnice bugu')), + ('y', models.IntegerField(verbose_name='y-ov\xe1 sou\u0159adnice bugu')), + ('status', models.CharField(default=b'k_oprave', max_length=16, verbose_name='stav opravy', choices=[(b'k_oprave', 'K oprav\u011b'), (b'opraveno', 'Opraveno'), (b'smazano', 'Smaz\xe1no')])), + ('autor', models.TextField(help_text=b'Autor opravy', verbose_name='autor opravy', blank=True)), + ('text', models.TextField(help_text=b'Text opravy', verbose_name='text opravy', blank=True)), + ], + options={ + 'ordering': ['y', 'x'], + 'db_table': 'opravy', + 'verbose_name': 'Oprava', + 'verbose_name_plural': 'Opravy', + }, + bases=(models.Model,), + ), + migrations.CreateModel( + name='OpravaKomentar', + fields=[ + ('id', models.AutoField(serialize=False, primary_key=True)), + ('cas', models.DateTimeField(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': 'opravy_komentare', + 'verbose_name': 'Koment\xe1\u0159 k oprav\u011b', + 'verbose_name_plural': 'Koment\xe1\u0159e k oprav\u011b', + }, + bases=(models.Model,), + ), + ] diff --git a/korektury/models.py b/korektury/models.py index 71a83623..d5ea8203 100644 --- a/korektury/models.py +++ b/korektury/models.py @@ -1,3 +1,123 @@ +# -*- coding: utf-8 -*- +import os +import random from django.db import models +from django.contrib import auth +from django.utils import timezone +from django.conf import settings +from django.utils.encoding import python_2_unicode_compatible +from django.utils.encoding import force_unicode +from django.utils.text import slugify +from django.core.urlresolvers import reverse +from django.core.cache import cache +from imagekit.models import ImageSpecField, ProcessedImageField +from imagekit.processors import ResizeToFit, Transpose + +from PIL import Image +import os +from cStringIO import StringIO +from django.core.files.base import ContentFile + +from django_countries.fields import CountryField +from solo.models import SingletonModel +from taggit.managers import TaggableManager + +import reversion + +# PrilohaReseni method +def generate_filename(self, filename): + clean = filename.replace('/','-').replace('\0', '') + datedir = timezone.now().strftime('%Y-%m') + fname = "%s_%s" % ( + timezone.now().strftime('%Y-%m-%d-%H:%M'), + clean) + return os.path.join(settings.SEMINAR_RESENI_DIR, datedir, fname) + + +#@reversion.register(ignore_duplicate_revision=True) +#@python_2_unicode_compatible +class KorekturovanePDF(models.Model): + class Meta: + db_table = 'korekturovane_cislo' + verbose_name = u'PDF k opravám' + verbose_name_plural = u'PDF k opravám' + + #Interní ID + id = models.AutoField(primary_key = True) + + pdf = models.FileField(u'pdf', upload_to = generate_filename) + + #TODO Nepovinný foreign key k číslu + + + +@reversion.register(ignore_duplicate_revision=True) +@python_2_unicode_compatible +class Oprava(models.Model): + class Meta: + db_table = 'opravy' + verbose_name = u'Oprava' + verbose_name_plural = u'Opravy' + ordering = ['y','x'] + + #Interní ID + id = models.AutoField(primary_key = True) + + #pdf = models.ForeignKey(KorekturovanePDF) + + strana = models.IntegerField(u'strana s opravou', help_text='Strana s opravou (od 0)') + + x = models.IntegerField(u'x-ová souřadnice bugu') + y = models.IntegerField(u'y-ová souřadnice bugu') + + STATUS_K_OPRAVE = 'k_oprave' + STATUS_OPRAVENO = 'opraveno' + STATUS_SMAZANO = 'smazano' + STATUS_CHOICES = ( + (STATUS_K_OPRAVE, u'K opravě'), + (STATUS_OPRAVENO, u'Opraveno'), + (STATUS_SMAZANO, u'Smazáno'), + ) + status = models.CharField(u'stav opravy',max_length=16, choices=STATUS_CHOICES, blank=False, + default = STATUS_K_OPRAVE) + + + # TODO: Změnit na cizí klíč do orgů + autor = models.TextField(u'autor opravy',blank = True, help_text='Autor opravy') + + text = models.TextField(u'text opravy',blank = True, help_text='Text opravy') + +# def __init__(self,dictionary): +# for k,v in dictionary.items(): +# setattr(self,k,v) + + def __str__(self): + return force_unicode(u'%s od %s: %s',self.status,self.autor,self.text) + + + +@reversion.register(ignore_duplicate_revision=True) +@python_2_unicode_compatible +class OpravaKomentar(models.Model): + class Meta: + db_table = 'opravy_komentare' + verbose_name = u'Komentář k opravě' + verbose_name_plural = u'Komentáře k opravě' + ordering = ['cas'] + + #Interní ID + id = models.AutoField(primary_key = True) + + cas = models.DateTimeField(u'čas komentáře',help_text = 'Čas zadání komentáře') + + oprava = models.ForeignKey(Oprava) + # TODO: Změnit na cizí klíč do orgů + autor = models.TextField(u'autor komentáře',blank = True, help_text='Autor komentáře') + + text = models.TextField(u'text komentáře',blank = True, help_text='Text komentáře') + + def __str__(self): + return force_unicode(u'%s od %s: %s',self.cas,self.autor,self.text) + + -# Create your models here. diff --git a/korektury/static/korektury/imgs/check.png b/korektury/static/korektury/imgs/check.png new file mode 100644 index 0000000000000000000000000000000000000000..c4d5504e9e56d95b9bcad7fc93d595472d6f7db3 GIT binary patch literal 697 zcmV;q0!ICbP)1+?ESE&+-+wv6Jz4h>*+>XY&x1pTJYZ8WBo56 zyplC-jY;A!8qDbT_CU+(Fzxf8?$gs@(G$Z8padz9h(W*svlzb>$ww?3H*`Jyiky%x zLGTMuQY!F0HSjLZ@9#M35KSyWae`czpBS?R?c<%86sD~>kAh`@yegW{Nysu8bqDZO z7(`Np9t}f{=p3_K+jH!JHw5m$e>1%hEXBZ25O^@~2)&d2RWgdL-Vm;Ax{*-`*N+jX z7&Tnp3DkV34YdC5NXN_ypcMYw`)*-OaDtLj;3DJkaG(xd4Sbk~f>ffk z>mFu>S;O1Iw$*PExQpW5aXa(RCZB|RaSXJS#-<1k{Zk*28kd5JB^R_|I@EuDj@D7z zwb$8gmOo7nm?$Zi@EMvtrgQpJnEL6)0`VRCsO^}82MQ(@uDJb(pk;V@dCfD;u}Z0w&sM7@=wMr^ zl$y$93clx^y)G6%&^1Uu-&a-&$(fm@%E1AsmCM*M3_W{&ZFYc>Ix(T$mP+8kvNqn7 z%Xvt5?w_4qt?cguuT}$r?}Nt84R$O`e|vSsL^g+p)YRM@>Pe?HgLv@t1Z=~=cD=3x2myn~$2H^dko^y>-e_#Y&jSOh+}DTV$)py-EQpK^ z%fj80lc4uG90cs%_l|=bj-#_2Y!42qvZ|tZPmdPDkO~p+ou3Eh@iBvGFeCydgmIWeY zJraokj^jX`=P?n`7cVZ_75ZO*WP4z03dKZGt04rq7Ra2;Eh1n+sK4tZKzHw-o<@qQ zYPWlPfFoDn*X#TO)*u(YtS6;su0b!Ugc;gKIC3EP68 z2jnzKjzhyFFM=Qdp(O-KgZ-%2w;{@8)*OsiLzucN%lLu7VW~cijHrWxfYOShNutO^ zXk~s{);i0Q!3%AWHdUrayGqV{MH00000NkvXXu0mjfba+y( literal 0 HcmV?d00001 diff --git a/korektury/static/korektury/imgs/edit.png b/korektury/static/korektury/imgs/edit.png new file mode 100644 index 0000000000000000000000000000000000000000..95cabe7d627b2b752769a0382a0bf0b5d83661ce GIT binary patch literal 1539 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 o0G53vv;Rr~m)} literal 0 HcmV?d00001 diff --git a/korektury/static/korektury/imgs/next-gr.png b/korektury/static/korektury/imgs/next-gr.png new file mode 100644 index 0000000000000000000000000000000000000000..885c2cd7c12009f9a6e39f7ca9d67216856906a3 GIT binary patch literal 881 zcmeAS@N?(olHy`uVBq!ia0vp^0w65F1|2LOJURt&@ zN5-c^#4?AkN3-mxt7p)Wqj9n_k$l^9cWR1vHy`#YoHRpex~-3y!ONAYxZ*{sPCM7$8*-%EDzq5 ziql{3XU>=#wfx%6D@)F1ZN8Obuw!YCX0(^Whvk2lo#$To_d;EUyy4C{F@Ac+$NGN= z+MmkbQlTT)-L6qR!}g5av?)u@Uw;0wn4$Q9i~+lwn_0Cv5HkMS{u>DIzH?%jA${oU zOCZeLefNpcPM>v;lP5SZt=zFAAz6D{lJ>-RSLW`TY}lLWlN_e~^Q3AiygSRo4r9WIk}QSyBY+yZoPBZ_Kq-LeW{sUvw`$x zL+J(q(M3)nlkQB4F7n=Z<2KKdLn{lkcn+lh;F!yZ{7CSZzoS)GRaGe z;adX#Hyay{-G|m~Sgm3AEZOc`-W+r0|53vCIN!Hie|RD!P0M(yy7~(TcB@B)z`)s{ zmU8p@)7PI$T^F-XKF#<*_TIy}XVY}1Pm|K>TJN}5Ei@!$g+c?D){2`sQ}>^Wf4cp4 zv{@7o?zz`}#PyMqp?&?eG7zldD(rB+lVteIyS!bnY`AIYE`u9}(N7mmT_dke#+@E`TMXFFaFr6z_ zg+!DD=ckpFCl;kLFjU+s_BrYA69h<((T>vU(@O1TaS?83{ F1ORj&k7xh@ literal 0 HcmV?d00001 diff --git a/korektury/static/korektury/imgs/next.png b/korektury/static/korektury/imgs/next.png new file mode 100644 index 0000000000000000000000000000000000000000..e8b15f66fc33855425d70bed77423b3e70efde31 GIT binary patch literal 557 zcmV+|0@D47P)LlRaxxQ4ofox##TNt3p0h7A(vU&_YBpF{X(i2(hsh zBvv*mwpMnQ670l66x7n6U@!<8loe7dDk75gE4%CN-MjakGZvSs{{`@9<512CggCa42s2%v~WKox+#?^3muHCDfuMTBG=3+8u z$(*I{tF(F@nrZ9ujkWpxrGids2^vQES!hy2O7?a~tY1q&wl=lnG-+-XF{oOpP?{;q_NTIHqNbBBGN)+6C_vO78c z_}u!3ZR%7ND>4a8Q`l_*14Igb?}4e>%$a@HH(z{P`MB12Z6E{1=2@Z`xU0lG6GJiqhUFOLc7l$WLW(N~vVzMpqq8I!V^kn9R z@)wN6I5hrP51N@wXH|4ee)LsJOABqSHF!Whz&Ck^_s#o$zVG|;u)|lliOq+JCJaPu zZhgVy#?L#Q4n{Xj=yr9`G_`1&@PIF-QU4rf0WVdteQujQX(#tzC})G??tC~zO<@EM z?T!Ij&jj6YfU5LB5=EqTl-xF(X8VBYF;xz=x*3;?SlYLjT4ct(u+vnbX8^dIPP^E! zTAQW;4hIgcrU;^d=J;ZUwShA;V^DrwN3kf)U@j+oYjhw$dqI*^5CoaGM&L0F7>}1s z_-M+$dhKf!iJ}yH9vH_L4RqXdbt=2*Ul2_h8PTlX%d+_4ZH0dS_!SE!b zNNs5B?&fSDG~ogVj)ANi;2$HQQIkOYAt$$1Q{3R=#xJdBX}`ZfF*H;^fB8K^DByy& zsslj~Kzm8}$baW$MN3xL(+K_%@ypLQ!qG^g`l(W~fk?;;O4k4bFzew6=xHXPW`i?8 z&+x0WeWge}GEhKup@hK*F>~!znqinV z)D+l}fMeIWMau2Vqn4N(2{?Y^O&$k)K~dz`NWko^%?(pGisgIL%R>WaSGK0~uD)ii zWclti8X7ot`(55DDn7Y$sPt<;G?2RaHeq%C^Fx0EdJPAFT}%l500000NkvXXu0mjf DLMR=< literal 0 HcmV?d00001 diff --git a/korektury/static/korektury/opraf.css b/korektury/static/korektury/opraf.css new file mode 100644 index 00000000..d385932c --- /dev/null +++ b/korektury/static/korektury/opraf.css @@ -0,0 +1,105 @@ +.pointer-hi, +.pointer, +.pointer-done, +.pointer-done-hi { + position:absolute; + /*border-bottom-left-radius: 10px; */ + border-left: 2px solid yellow; + border-bottom: 2px solid yellow; +} + +.pointer-done-hi, +.pointer-hi { + border-width: 3px; +} + +.pointer { + border-color: #F00; /*IE*/ + border-color: rgba(255, 0, 0, 0.35); +} +.pointer-hi { + border-color: #F00; /*IE*/ + border-color: rgba(255, 0, 0, 1); +} +.pointer-done { + border-color: #00F; /*IE*/ + border-color: rgba(0, 0, 255, 0.2); +} +.pointer-done-hi { + border-color: #00F; /*IE*/ + border-color: rgba(0, 0, 255, 1); +} + + +.box:hover, .box-done:hover { + border-width:3px; + margin: 0px; +} +.box, .box-done { + margin: 1px; + background-color: white; + width:300px; + /*position:absolute;*/ + padding: 3px; + border: 2px solid black; + border-radius: 10px; +} +.box { + border-color: red; +} +.box-done { + border-color: blue; +} +form { + display:inline; +} + +.float-right{ + float:right; +} + +.imgdiv { + position:relative; + left:0px; + top:0px; +} +#commform-div { + display: none; + position: absolute; + background-color: white; + border: 1px solid; + padding: 3px; + /* + width: 310; + height: 220; + */ + z-index: 10; + border: 4px solid red; + border-radius: 10px; + background-color: white; +} +.close-button{ + background-color: yellow; +} + +body { + background-color: #b0b0ff; +} + + + +.box button, +.box img, +.box-done button, +.box-done img { + border: 1px solid white; + background-color:transparent; + margin:0; + padding: 1px; +} +.box button:hover, +.box img:hover, +.box-done img:hover, +.box-done button:hover { + border: 1px solid black; +} diff --git a/korektury/static/korektury/opraf.js b/korektury/static/korektury/opraf.js new file mode 100644 index 00000000..60764ca1 --- /dev/null +++ b/korektury/static/korektury/opraf.js @@ -0,0 +1,213 @@ +function place_comments_one_div(img_id, comments) +{ + var img = document.getElementById(img_id); + if( img == null ) { + return; + } + var par = img.parentNode; + var w = img.clientWidth; + var h = img.clientHeight; + var w_skip = 10; + var h_skip = 5; + var pointer_min_h = 30; + + var bott_max = 0; + var comments_sorted = comments.sort(function (a,b) { + return a[2] - b[2]; + //pokus o hezci kladeni poiteru, ale nic moc + if( a[3] < b[3] ) { + return (a[2] + pointer_min_h)- b[2]; + } else { + return (a[2] - pointer_min_h)- b[2]; + } + + }); + //console.log("w:" + w); + for (c in comments_sorted) { + var id = comments_sorted[c][0]; + var x = comments_sorted[c][1]; + var y = comments_sorted[c][2]; + + var el = document.getElementById(id); + var elp = document.getElementById(id + "-pointer"); + + if( el == null || elp == null ) { + continue; + } + + par.appendChild(elp); + par.appendChild(el); + + var delta_y = (y > bott_max) ? 0: bott_max - y + h_skip; + + elp.style.left = x; + elp.style.top = y ; + elp.style.width = w - x + w_skip; + elp.style.height = pointer_min_h + delta_y; + elp.img_id = img_id; + el.img_id = img_id; + + el.style.position = 'absolute'; + el.style.left = w + w_skip; + el.style.top = y + delta_y; + + var bott = el.offsetTop + el.offsetHeight; + bott_max = ( bott_max > bott ) ? bott_max : bott; + + //console.log( "par.w:" + par.style.width); + + } + if( par.offsetHeight < bott_max ) { + //par.style.height = bott_max; + //alert("preteklo to:"+ par.offsetHeight +",mx:" + bott_max ); + par.style.height = bott_max; + + } +} + +// ctrl-enter submits form +function textarea_onkey(ev) +{ + //console.log("ev:" + ev.keyCode + "," + ev.ctrlKey); + if( (ev.keyCode == 13 || ev.keyCode == 10 ) && ev.ctrlKey ) { + var form = document.getElementById('commform'); + if( form ) { + save_scroll(form); + //form.action =''; + form.submit(); + } + return true; + } + return false; +} + +//hide comment form +function close_commform() { + + var formdiv = document.getElementById('commform-div'); + if( formdiv == null ) { + alert("form null"); + return true; + } + formdiv.style.display = 'none'; + return false; +} + +// show comment form, when clicked to image +function img_click(element, ev) { + + var dx, dy; + var par = element.parentNode; + if( ev.pageX != null ) { + dx = ev.pageX - par.offsetLeft; + dy = ev.pageY - par.offsetTop; + } else { //IE + dx = ev.offsetX; + dy = ev.offsetY; + } + var img_id = element.id; + if( element.img_id != null ) { + // click was to '-pointer' + img_id = element.img_id; + } + return show_form(img_id, dx, dy, '', '', '', ''); +} + +// show comment form, when 'edit' button pressed +function box_edit(button) +{ + var divbox = button.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 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'); + +} + +//fill up comment form and show him +function show_form(img_id, dx, dy, id, text, action) { + var form = document.getElementById('commform'); + var formdiv = document.getElementById('commform-div'); + var textarea = document.getElementById('commform-text'); + var inputX = document.getElementById('commform-x'); + var inputY = document.getElementById('commform-y'); + var inputImgId = document.getElementById('commform-img-id'); + var inputId = document.getElementById('commform-id'); + var inputAction = document.getElementById('commform-action'); + var img = document.getElementById(img_id); + + if( formdiv == null || textarea == null ) { + alert("form null"); + return 1; + } + + //form.action = "#" + img_id; + + // set hidden values + inputX.value = dx; + inputY.value = dy; + inputImgId.value = img_id; + inputId.value = id; + inputAction.value = action; + textarea.value = text; + + //textarea.value = "dxy:"+ dx + "x" + dy + "\n" + 'id:' + img_id; + + // show form + formdiv.style.display = 'block'; + formdiv.style.left = dx; + formdiv.style.top = dy; + + img.parentNode.appendChild(formdiv); + + textarea.focus(); + + return true; + +} + +function box_onmouseover(box, done) +{ + var id = box.id; + var pointer = document.getElementById(box.id + '-pointer'); + pointer.className = done ? 'pointer-done-hi' : 'pointer-hi'; + //console.log('mouseout'); + +} + +function box_onmouseout(box, done) +{ + var id = box.id; + var pointer = document.getElementById(box.id + '-pointer'); + pointer.className = done ? 'pointer-done' : 'pointer'; + + //console.log('mousein'); +} + +function save_scroll(form) +{ + //alert('save_scroll:' + document.body.scrollTop); + form.scroll.value = document.body.scrollTop; + //alert('save_scroll:' + form.scroll.value); + + + return true; +} + + +String.prototype.unescapeHTML = function () { + return( + this.replace(/&/g,'&'). + replace(/>/g,'>'). + replace(/</g,'<'). + replace(/"/g,'"') + ); +}; + diff --git a/korektury/static/korektury/png/.gitignore b/korektury/static/korektury/png/.gitignore new file mode 100644 index 00000000..72e8ffc0 --- /dev/null +++ b/korektury/static/korektury/png/.gitignore @@ -0,0 +1 @@ +* diff --git a/korektury/static/korektury/tmp/.gitignore b/korektury/static/korektury/tmp/.gitignore new file mode 100644 index 00000000..72e8ffc0 --- /dev/null +++ b/korektury/static/korektury/tmp/.gitignore @@ -0,0 +1 @@ +* diff --git a/korektury/templates/korektury/opraf.html b/korektury/templates/korektury/opraf.html new file mode 100644 index 00000000..75d80b7f --- /dev/null +++ b/korektury/templates/korektury/opraf.html @@ -0,0 +1,97 @@ + + + + + + Korektury 22_3_verze5.pdf + + + +

Korektury 22_3_verze5.pdf

+ Klikni na chybu, napi¹ komentáø | + ls | + help |          | + hlavní stránka | + wiki | +
+ +
+
+ {% csrf_token %} + + + +
+ +
+ + + + + + + +
+
+ + {% for i in img_indexes %} +

+ {% endfor %} + +
+ + + + Souhlasím se smazáním v¹ech kometáøù +
+
+ + Dìkujeme opravovatelùm: Marble(4), zuzka(4), Matìj(2), O(N)dra(2), Va¹ek(1), Kristý(1), Tonda(1), Jethro(1), Pe»a(1), ML(1), Lucka(1)
+ + + + + +{% for o in opravy %} + +
+
+ + + {{o.autor}} +
+
+ + + + + + + + + + + + +
+
{{o.text}}
+ +
+ + +{% endfor %} + + + + +
+ {% csrf_token %} + {{ form_oprava.as_p }} + +
+ diff --git a/korektury/urls.py b/korektury/urls.py new file mode 100644 index 00000000..72035e2c --- /dev/null +++ b/korektury/urls.py @@ -0,0 +1,7 @@ +from django.conf.urls import * # NOQA +from django.conf.urls import patterns, url +from . import views + +urlpatterns = patterns('', + url(r'^korektury$',views.KorekturyView.as_view(),name='korektury'), +) diff --git a/korektury/views.py b/korektury/views.py index 91ea44a2..673d94d8 100644 --- a/korektury/views.py +++ b/korektury/views.py @@ -1,3 +1,56 @@ +# -*- coding: utf-8 -*- from django.shortcuts import render +from django.shortcuts import get_object_or_404, render +from django.http import HttpResponseRedirect +from django.http import HttpResponse +from django.core.urlresolvers import reverse +from django.views import generic +from django.utils.translation import ugettext as _ +from django.http import Http404 +from django.http import HttpResponseRedirect + +from .models import Oprava +from .forms import OpravaForm + +from datetime import timedelta, date, datetime +from itertools import groupby +import tempfile +import subprocess +import shutil +import os +from django.conf import settings +import unicodedata + +### Korektury +class KorekturyView(generic.TemplateView): + model = Oprava + template_name = 'korektury/opraf.html' + form_class = OpravaForm + + def post(self, request, *args, **kwargs): + form = self.form_class(request.POST) + q = request.POST + x = int(q.get('x')) + y = int(q.get('y')) + autor = q.get('au') + text = q.get('txt') + strana = int(q.get('img-id')[4:]) + scroll = q.get('scroll') + + oprava = Oprava(x=x,y=y, autor=autor, text=text, strana=strana) + oprava.save() + + return HttpResponseRedirect(reverse('korektury')+"?scroll=%s"%(scroll)) +# return render(request, 'seminar/opraf.html',self.get_context_data()) +# return HttpResponse(u'Oprav: %d,x: %d y: %d, autor: %s, text: %s, strana: %d'%( +# len(Oprava.objects.all()),x,y,autor,text,strana)) + def get_context_data(self, **kwargs): + context = super(KorekturyView,self).get_context_data(**kwargs) + context['img_name'] = "22_3_verze5" + context['img_indexes'] = range(27) + context['form_oprava'] = OpravaForm() + context['opravy'] = Oprava.objects.all() + return context + def form_valid(self,form): + return super(KorekturyView,self).form_valid(form) -# Create your views here. diff --git a/mamweb/settings_common.py b/mamweb/settings_common.py index d48a0938..2fbdf849 100644 --- a/mamweb/settings_common.py +++ b/mamweb/settings_common.py @@ -117,6 +117,7 @@ INSTALLED_APPS = ( 'mamweb', 'seminar', 'galerie', + 'korektury', # Admin upravy: diff --git a/mamweb/urls.py b/mamweb/urls.py index 999ffc90..223bdae8 100644 --- a/mamweb/urls.py +++ b/mamweb/urls.py @@ -14,6 +14,9 @@ urlpatterns = patterns('', # Seminarova aplikace (ma vlastni podadresare) url(r'^', include('seminar.urls')), + + # Korekturovaci aplikace (ma vlastni podadresare) + url(r'^', include('korektury.urls')), # Comments (interni i verejne) url(r'^comments_dj/', include('django_comments.urls')), From 4f1e04af998a341a60876cd73b43b3d334fb27da Mon Sep 17 00:00:00 2001 From: Tomas 'Jethro' Pokorny Date: Wed, 2 Dec 2015 01:01:24 +0100 Subject: [PATCH 03/23] Funguje mazani, upravy a done/undone. Lehce rozbite je zvyraznovani car, chce to prozkoumat JS. --- korektury/templates/korektury/opraf.html | 17 +++++--- korektury/views.py | 49 +++++++++++++++++++----- 2 files changed, 51 insertions(+), 15 deletions(-) diff --git a/korektury/templates/korektury/opraf.html b/korektury/templates/korektury/opraf.html index 75d80b7f..9013ce53 100644 --- a/korektury/templates/korektury/opraf.html +++ b/korektury/templates/korektury/opraf.html @@ -54,23 +54,28 @@ {% for o in opravy %} -
-
+
+
+
{{o.autor}}
+ {% csrf_token %} - + - + {% if o.status = 'opraveno' %} + {% else %} + + {% endif %} - +
@@ -94,4 +99,6 @@ {{ form_oprava.as_p }} + + diff --git a/korektury/views.py b/korektury/views.py index 673d94d8..14f95b57 100644 --- a/korektury/views.py +++ b/korektury/views.py @@ -30,17 +30,46 @@ class KorekturyView(generic.TemplateView): def post(self, request, *args, **kwargs): form = self.form_class(request.POST) q = request.POST - x = int(q.get('x')) - y = int(q.get('y')) - autor = q.get('au') - text = q.get('txt') - strana = int(q.get('img-id')[4:]) - scroll = q.get('scroll') - - oprava = Oprava(x=x,y=y, autor=autor, text=text, strana=strana) - oprava.save() + + + action = q.get('action') + if (action == u''): # Přidej + x = int(q.get('x')) + y = int(q.get('y')) + autor = q.get('au') + text = q.get('txt') + strana = int(q.get('img-id')[4:]) + scroll = q.get('scroll') + + op = Oprava(x=x,y=y, autor=autor, text=text, strana=strana) + op.save() + elif (action == u'del'): + id = int(q.get('id')) + op = Oprava.objects.filter(id=id).first() + op.delete() + elif (action == u'update'): + id = int(q.get('id')) + op = Oprava.objects.filter(id=id).first() + autor = q.get('au') + text = q.get('txt') + op.autor = autor + op.text = text + op.save() + elif (action == u'undone'): + id = int(q.get('id')) + op = Oprava.objects.filter(id=id).first() + op.status = op.STATUS_K_OPRAVE + op.save() + elif (action == u'done'): + id = int(q.get('id')) + op = Oprava.objects.filter(id=id).first() + op.status = op.STATUS_OPRAVENO + op.save() + + return HttpResponse(u'Oprav: %d, akce: %s'%( + len(Oprava.objects.all()),action)) - return HttpResponseRedirect(reverse('korektury')+"?scroll=%s"%(scroll)) +# return HttpResponseRedirect(reverse('korektury')+"?scroll=%s"%(scroll)) # return render(request, 'seminar/opraf.html',self.get_context_data()) # return HttpResponse(u'Oprav: %d,x: %d y: %d, autor: %s, text: %s, strana: %d'%( # len(Oprava.objects.all()),x,y,autor,text,strana)) From 09b20903716fafa82d0f02ab63c8c085f4d43341 Mon Sep 17 00:00:00 2001 From: Tomas 'Jethro' Pokorny Date: Wed, 2 Dec 2015 01:07:50 +0100 Subject: [PATCH 04/23] Zvyraznovani odladeno. --- korektury/templates/korektury/opraf.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/korektury/templates/korektury/opraf.html b/korektury/templates/korektury/opraf.html index 9013ce53..c8b198fb 100644 --- a/korektury/templates/korektury/opraf.html +++ b/korektury/templates/korektury/opraf.html @@ -56,7 +56,10 @@
-
+
{{o.autor}} From 2a163fe6a455b3200b0d8deb663abb81135ba65a Mon Sep 17 00:00:00 2001 From: Tomas 'Jethro' Pokorny Date: Thu, 3 Dec 2015 00:07:23 +0100 Subject: [PATCH 05/23] 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) From b0f97143295c68a583b17a7814518e751a69a33f Mon Sep 17 00:00:00 2001 From: "Tomas \"Jethro\" Pokorny" Date: Sat, 5 Dec 2015 01:19:49 +0100 Subject: [PATCH 06/23] Pridano administracni rozhrani. Korekturovana PDF se uz daji pridavat pres admina. Pridan jednoduchy vypis korekturovanych veci. --- korektury/admin.py | 13 ++++++ .../migrations/0003_auto_20151204_1855.py | 27 +++++++++++ .../migrations/0004_auto_20151204_2240.py | 26 +++++++++++ .../migrations/0005_auto_20151204_2244.py | 32 +++++++++++++ korektury/migrations/0006_oprava_pdf.py | 20 +++++++++ korektury/models.py | 45 +++++++++++++++---- korektury/templates/korektury/opraf.html | 27 ++++++----- korektury/templates/korektury/seznam.html | 13 ++++++ korektury/urls.py | 3 +- korektury/views.py | 17 +++++-- mamweb/settings_common.py | 2 + mamweb/settings_local.py | 7 +++ 12 files changed, 205 insertions(+), 27 deletions(-) create mode 100644 korektury/migrations/0003_auto_20151204_1855.py create mode 100644 korektury/migrations/0004_auto_20151204_2240.py create mode 100644 korektury/migrations/0005_auto_20151204_2244.py create mode 100644 korektury/migrations/0006_oprava_pdf.py create mode 100644 korektury/templates/korektury/seznam.html diff --git a/korektury/admin.py b/korektury/admin.py index 8c38f3f3..564e2cd0 100644 --- a/korektury/admin.py +++ b/korektury/admin.py @@ -1,3 +1,16 @@ from django.contrib import admin +from reversion.admin import VersionAdmin +from korektury.models import KorekturovanePDF # Register your models here. +class KorekturovanePDFAdmin(VersionAdmin): + readonly_fields = ['cas', 'stran'] + fieldsets = [ + (None, {'fields': ['pdf', 'cas', 'stran', 'nazev', 'komentar']}), +# (u'PDF', {'fields': ['pdf']}), + ] + list_display = ['pdf', 'cas', 'stran'] + list_filter = [] + search_fields = [] + +admin.site.register(KorekturovanePDF, KorekturovanePDFAdmin) diff --git a/korektury/migrations/0003_auto_20151204_1855.py b/korektury/migrations/0003_auto_20151204_1855.py new file mode 100644 index 00000000..8f8cb70b --- /dev/null +++ b/korektury/migrations/0003_auto_20151204_1855.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations +import django.utils.timezone + + +class Migration(migrations.Migration): + + dependencies = [ + ('korektury', '0002_auto_20151202_2351'), + ] + + operations = [ + migrations.AddField( + model_name='korekturovanepdf', + name='cas', + field=models.DateTimeField(default=django.utils.timezone.now, help_text=b'\xc4\x8cas vlo\xc5\xbeen\xc3\xad PDF', verbose_name='\u010das vlo\u017een\xed PDF'), + preserve_default=True, + ), + migrations.AddField( + model_name='korekturovanepdf', + name='stran', + field=models.IntegerField(default=0, help_text=b'Po\xc4\x8det stran PDF', verbose_name='po\u010det stran'), + preserve_default=True, + ), + ] diff --git a/korektury/migrations/0004_auto_20151204_2240.py b/korektury/migrations/0004_auto_20151204_2240.py new file mode 100644 index 00000000..ed47ccaf --- /dev/null +++ b/korektury/migrations/0004_auto_20151204_2240.py @@ -0,0 +1,26 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('korektury', '0003_auto_20151204_1855'), + ] + + operations = [ + migrations.AddField( + model_name='korekturovanepdf', + name='komentar', + field=models.TextField(help_text=b'Koment\xc3\xa1\xc5\x99 ke korekturovan\xc3\xa9mu PDF (nap\xc5\x99. na co se zam\xc4\x9b\xc5\x99it)', verbose_name='koment\xe1\u0159 k PDF', blank=True), + preserve_default=True, + ), + migrations.AddField( + model_name='korekturovanepdf', + name='nazev', + field=models.TextField(help_text=b'N\xc3\xa1zev (nap\xc5\x99. 22.1 verze 4) korekturovan\xc3\xa9ho PDF', verbose_name='n\xe1zev PDF', blank=True), + preserve_default=True, + ), + ] diff --git a/korektury/migrations/0005_auto_20151204_2244.py b/korektury/migrations/0005_auto_20151204_2244.py new file mode 100644 index 00000000..52ebdfb6 --- /dev/null +++ b/korektury/migrations/0005_auto_20151204_2244.py @@ -0,0 +1,32 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('korektury', '0004_auto_20151204_2240'), + ] + + operations = [ + migrations.AlterField( + model_name='komentar', + name='autor', + field=models.CharField(help_text=b'Autor koment\xc3\xa1\xc5\x99e', max_length=20, verbose_name='autor koment\xe1\u0159e', blank=True), + preserve_default=True, + ), + migrations.AlterField( + model_name='korekturovanepdf', + name='nazev', + field=models.CharField(help_text=b'N\xc3\xa1zev (nap\xc5\x99. 22.1 verze 4) korekturovan\xc3\xa9ho PDF', max_length=50, verbose_name='n\xe1zev PDF', blank=True), + preserve_default=True, + ), + migrations.AlterField( + model_name='oprava', + name='autor', + field=models.CharField(help_text=b'Autor opravy', max_length=20, verbose_name='autor opravy', blank=True), + preserve_default=True, + ), + ] diff --git a/korektury/migrations/0006_oprava_pdf.py b/korektury/migrations/0006_oprava_pdf.py new file mode 100644 index 00000000..2adf04e7 --- /dev/null +++ b/korektury/migrations/0006_oprava_pdf.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('korektury', '0005_auto_20151204_2244'), + ] + + operations = [ + migrations.AddField( + model_name='oprava', + name='pdf', + field=models.ForeignKey(default=-1, to='korektury.KorekturovanePDF'), + preserve_default=True, + ), + ] diff --git a/korektury/models.py b/korektury/models.py index 80655739..75593af3 100644 --- a/korektury/models.py +++ b/korektury/models.py @@ -13,8 +13,8 @@ from django.core.cache import cache from imagekit.models import ImageSpecField, ProcessedImageField from imagekit.processors import ResizeToFit, Transpose -from PIL import Image import os +import subprocess from cStringIO import StringIO from django.core.files.base import ContentFile @@ -26,12 +26,11 @@ import reversion # PrilohaReseni method def generate_filename(self, filename): - clean = filename.replace('/','-').replace('\0', '') - datedir = timezone.now().strftime('%Y-%m') + clean = filename.replace('/','-').replace('\0', '').replace(":","_") fname = "%s_%s" % ( - timezone.now().strftime('%Y-%m-%d-%H:%M'), + timezone.now().strftime('%Y-%m-%d-%H_%M'), clean) - return os.path.join(settings.SEMINAR_RESENI_DIR, datedir, fname) + return os.path.join(settings.KOREKTURY_PDF_DIR, fname) #@reversion.register(ignore_duplicate_revision=True) @@ -45,10 +44,40 @@ class KorekturovanePDF(models.Model): #Interní ID id = models.AutoField(primary_key = True) + cas = models.DateTimeField(u'čas vložení PDF',default=timezone.now,help_text = 'Čas vložení PDF') + + nazev = models.CharField(u'název PDF',blank = True,max_length=50, help_text='Název (např. 22.1 verze 4) korekturovaného PDF') + + komentar = models.TextField(u'komentář k PDF',blank = True, help_text='Komentář ke korekturovanému PDF (např. na co se zaměřit)') + pdf = models.FileField(u'pdf', upload_to = generate_filename) + stran = models.IntegerField(u'počet stran', help_text = 'Počet stran PDF', default = 0) + #TODO Nepovinný foreign key k číslu + def save(self): + super(KorekturovanePDF, self).save() + print("\nSaving") + print(self.pdf.path) + print(self.pdf.url) + filename = os.path.split(self.pdf.file.name)[1].split(".")[0] + try: + os.listdir(settings.KOREKTURY_IMG_DIR) + except OSError: + os.mkdir(settings.KOREKTURY_IMG_DIR) + while True: + res = subprocess.call([ + "convert", + "-density","180x180", + "-geometry"," 1024x1448", + self.pdf.path+"[%d]"%self.stran, + os.path.join(settings.KOREKTURY_IMG_DIR, "%s-%d.png"%(filename,self.stran))]) + if res==1: + break + self.stran +=1 + super(KorekturovanePDF, self).save() + @reversion.register(ignore_duplicate_revision=True) @@ -63,7 +92,7 @@ class Oprava(models.Model): #Interní ID id = models.AutoField(primary_key = True) - #pdf = models.ForeignKey(KorekturovanePDF) + pdf = models.ForeignKey(KorekturovanePDF, default=-1) strana = models.IntegerField(u'strana s opravou', help_text='Strana s opravou (od 0)') @@ -83,7 +112,7 @@ class Oprava(models.Model): # TODO: Změnit na cizí klíč do orgů - autor = models.TextField(u'autor opravy',blank = True, help_text='Autor opravy') + autor = models.CharField(u'autor opravy',blank = True,max_length=20, help_text='Autor opravy') text = models.TextField(u'text opravy',blank = True, help_text='Text opravy') @@ -112,7 +141,7 @@ class Komentar(models.Model): oprava = models.ForeignKey(Oprava) # TODO: Změnit na cizí klíč do orgů - autor = models.TextField(u'autor komentáře',blank = True, help_text='Autor komentáře') + autor = models.CharField(u'autor komentáře',blank = True,max_length=20, help_text='Autor komentáře') text = models.TextField(u'text komentáře',blank = True, help_text='Text komentáře') diff --git a/korektury/templates/korektury/opraf.html b/korektury/templates/korektury/opraf.html index 63069f63..7beb1435 100644 --- a/korektury/templates/korektury/opraf.html +++ b/korektury/templates/korektury/opraf.html @@ -1,15 +1,14 @@ - - + + - Korektury 22_3_verze5.pdf - - - -

Korektury 22_3_verze5.pdf

- Klikni na chybu, napi¹ komentáø | - ls | + Korektury {{pdf.nazev}} + + +

Korektury {{pdf.nazev}}

+ Klikni na chybu, napiš komentář | + ls | help |          | hlavní stránka | wiki | @@ -24,7 +23,7 @@

- + @@ -35,13 +34,13 @@
{% for i in img_indexes %} -

+

{% endfor %}
- + Souhlasím se smazáním v¹ech kometáøù

@@ -66,7 +65,7 @@
{% csrf_token %} - + {% if o.komentare %} @@ -122,7 +121,7 @@
{% csrf_token %} - + +

@@ -38,16 +38,15 @@ {% endfor %} + {% csrf_token %} - + - Souhlasím se smazáním v¹ech kometáøù + Souhlasím se smazáním všech kometářů
- Dìkujeme opravovatelùm: Marble(4), zuzka(4), Matìj(2), O(N)dra(2), Va¹ek(1), Kristý(1), Tonda(1), Jethro(1), Pe»a(1), ML(1), Lucka(1)
- - + Děkujeme opravovatelům: {% for autor,pocet in zasluhy.items %} {{autor}}({{pocet}}) {% endfor %}
@@ -64,7 +63,8 @@
{{o.autor}}
- {% csrf_token %} + {% csrf_token %} + @@ -106,7 +106,7 @@
@@ -133,7 +133,7 @@
-
{{k.text}}
+
{{k.text}}
{% endfor %} @@ -155,6 +155,12 @@ {{ form_oprava.as_p }} + {% if scroll %} + + {% endif %} - + + diff --git a/korektury/views.py b/korektury/views.py index 24352585..562c03da 100644 --- a/korektury/views.py +++ b/korektury/views.py @@ -35,16 +35,20 @@ class KorekturyView(generic.TemplateView): def post(self, request, *args, **kwargs): form = self.form_class(request.POST) q = request.POST + scroll = q.get('scroll') + autor = q.get('au') + if not autor: + autor = 'anonym' + if not scroll: + scroll = 0 action = q.get('action') if (action == u''): # Přidej x = int(q.get('x')) y = int(q.get('y')) - autor = q.get('au') text = q.get('txt') strana = int(q.get('img-id')[4:]) - scroll = q.get('scroll') pdf = KorekturovanePDF.objects.filter(id=q.get('pdf')).first() op = Oprava(x=x,y=y, autor=autor, text=text, strana=strana,pdf = pdf) @@ -82,14 +86,26 @@ class KorekturyView(generic.TemplateView): id = int(q.get('id')) kom = Komentar.objects.filter(id=id).first() kom.delete() + elif (action == u'delall'): + pdf = KorekturovanePDF.objects.filter(id=q.get('pdf')) + checked = q.get('yes') + if checked: + opravy = Oprava.objects.filter(pdf=pdf) + komentare = Komentar.objects.filter(oprava=opravy) + opravy.delete() + komentare.delete() + # return HttpResponse(u'Keys: %s '%(q.iteitems())) - return HttpResponse(u'Oprav: %d, akce: %s'%( - len(Oprava.objects.all()),action)) +# return HttpResponse(u'Oprav: %d, akce: %s'%( +# len(Oprava.objects.all()),action)) # return HttpResponseRedirect(reverse('korektury')+"?scroll=%s"%(scroll)) -# return render(request, 'seminar/opraf.html',self.get_context_data()) + context = self.get_context_data() + context['scroll'] = scroll + context['autor'] = autor + return render(request, 'korektury/opraf.html',context) # return HttpResponse(u'Oprav: %d,x: %d y: %d, autor: %s, text: %s, strana: %d'%( # len(Oprava.objects.all()),x,y,autor,text,strana)) def get_context_data(self, **kwargs): @@ -98,12 +114,24 @@ class KorekturyView(generic.TemplateView): context['pdf'] = pdf context['img_name'] = os.path.split(pdf.pdf.path)[1].split('.')[0] context['img_path'] = settings.KOREKTURY_IMG_DIR - context['img_indexes'] = range(27) + context['img_indexes'] = range(pdf.stran) context['form_oprava'] = OpravaForm() opravy = Oprava.objects.filter(pdf=self.kwargs['pdf']) + zasluhy = {} for o in opravy: + if o.autor in zasluhy: + zasluhy[o.autor]+=1 + else: + zasluhy[o.autor]=1 o.komentare = o.komentar_set.all() + for k in o.komentare: + if o.autor in zasluhy: + zasluhy[k.autor]+=1 + else: + zasluhy[k.autor]=1 + context['opravy'] = opravy + context['zasluhy'] = zasluhy return context def form_valid(self,form): return super(KorekturyView,self).form_valid(form) From 2a6dafd3819e28fb0f3dd2cb4c97b0e3d2b8d4d5 Mon Sep 17 00:00:00 2001 From: "Tomas \"Jethro\" Pokorny" Date: Sat, 5 Dec 2015 11:17:24 +0100 Subject: [PATCH 08/23] Opraven editacni box. Korektury se jiz daji spravne opravovat. --- korektury/static/korektury/opraf.js | 1 + korektury/templates/korektury/opraf.html | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/korektury/static/korektury/opraf.js b/korektury/static/korektury/opraf.js index 284a6864..1d56da31 100644 --- a/korektury/static/korektury/opraf.js +++ b/korektury/static/korektury/opraf.js @@ -125,6 +125,7 @@ function box_edit(button, action) if (action == 'update') { var text_el = document.getElementById(divbox.id + '-text'); text = text_el.innerHTML.unescapeHTML(); + } else { text = ''; } diff --git a/korektury/templates/korektury/opraf.html b/korektury/templates/korektury/opraf.html index 7267c2b4..9bb1525e 100644 --- a/korektury/templates/korektury/opraf.html +++ b/korektury/templates/korektury/opraf.html @@ -60,7 +60,7 @@ onmouseout='box_onmouseout(this,{% if o.status = 'opraveno' %}1{% else %}0{% endif %})' >
-
{{o.autor}}
+
{{o.autor}}
{% csrf_token %} @@ -89,12 +89,12 @@ {% endif %} - {% if o.komentare %} - + {% if o.komentare %} + {% else %} - {% endif %} @@ -105,7 +105,7 @@ - From 49ae8af9f3a8df0fa7f41ed458b04d0696e19f02 Mon Sep 17 00:00:00 2001 From: "Tomas \"Jethro\" Pokorny" Date: Sat, 5 Dec 2015 13:31:17 +0100 Subject: [PATCH 09/23] Uprava formatovani. --- korektury/templates/korektury/opraf.html | 261 ++++++++++++----------- 1 file changed, 132 insertions(+), 129 deletions(-) diff --git a/korektury/templates/korektury/opraf.html b/korektury/templates/korektury/opraf.html index 9bb1525e..251f722f 100644 --- a/korektury/templates/korektury/opraf.html +++ b/korektury/templates/korektury/opraf.html @@ -15,152 +15,155 @@
- - {% csrf_token %} - - - -
- -
- - - - - - - - + +
+ {% csrf_token %} + + + +
+ +
+ + + + + + + +
+
{% for i in img_indexes %} -

+
+ +
+
{% endfor %} +
- {% csrf_token %} - - - - Souhlasím se smazáním všech kometářů + {% csrf_token %} + + + + Souhlasím se smazáním všech kometářů
+
- - Děkujeme opravovatelům: {% for autor,pocet in zasluhy.items %} {{autor}}({{pocet}}) {% endfor %}
- - - -{% for o in opravy %} - -
-
-
+ Děkujeme opravovatelům: {% for autor,pocet in zasluhy.items %} {{autor}}({{pocet}}) {% endfor %}

+
+ + {% for o in opravy %} +
+
+
- -
-
{{o.autor}}
-
-
- {% csrf_token %} - - - - - {% if o.komentare %} - - {% else %} - - {% endif %} - - {% if o.status = 'opraveno' %} - - {% else %} - - {% endif %} - - {% if o.komentare %} - - {% else %} - - {% endif %} - - - - -
-
-
-
{{o.text}}
- {% for k in o.komentare %} -
-
-
-
{{k.autor}}
+
+
{{o.autor}}
+
+ +
+ {% csrf_token %} + + + + + + {% if o.komentare %} + + {% else %} + + {% endif %} + + {% if o.status = 'opraveno' %} + + {% else %} + + {% endif %} + + {% if o.komentare %} + + {% else %} + + {% endif %} + +
+ + + +
+
+
{{o.text}}
+ + {% for k in o.komentare %} +
+
+
+
{{k.autor}}
+
- {% csrf_token %} - - - - + {% csrf_token %} + + + +
- -
-
-
{{k.text}}
-
- {% endfor %} - + + +
+
+
{{k.text}}
+
+ {% endfor %}
+ {% endfor %} - -{% endfor %} - - - - -
- {% csrf_token %} - {{ form_oprava.as_p }} - -
- {% if scroll %} - - {% endif %} - - + {% endfor %} + {% if scroll %} + window.scrollTo(0,{{scroll}}); + {% endif %} + From 2de2aa40a466bbafd9b06495861af83d555593db Mon Sep 17 00:00:00 2001 From: "Tomas \"Jethro\" Pokorny" Date: Sat, 5 Dec 2015 14:13:07 +0100 Subject: [PATCH 10/23] Docisteni HTML a JS, opravy komentaru. Komentare uz se daji i upravovat. --- korektury/static/korektury/opraf.js | 22 ++++++-------------- korektury/templates/korektury/opraf.html | 26 ++++++++++++------------ korektury/views.py | 10 +++++++-- 3 files changed, 27 insertions(+), 31 deletions(-) diff --git a/korektury/static/korektury/opraf.js b/korektury/static/korektury/opraf.js index 1d56da31..6c955a72 100644 --- a/korektury/static/korektury/opraf.js +++ b/korektury/static/korektury/opraf.js @@ -83,7 +83,6 @@ function textarea_onkey(ev) //hide comment form function close_commform() { - var formdiv = document.getElementById('commform-div'); if( formdiv == null ) { alert("form null"); @@ -116,9 +115,8 @@ function img_click(element, ev) { // show comment form, when 'edit' or 'comment' button pressed function box_edit(button, action) { - var divbox = button.parentNode.parentNode.parentNode.parentNode; + var divbox = button.parentNode.parentNode.parentNode; var id = divbox.id; - //alert("id: " + id); var divpointer = document.getElementById(divbox.id + '-pointer'); var text; @@ -135,24 +133,22 @@ function box_edit(button, action) //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, action); - } // show comment form when 'update-comment' button pressed function update_comment(button) { - var divbox = button.parentNode.parentNode.parentNode; + var divbox = button.parentNode.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(); + var commentdiv = button.parentNode.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'); + return show_form(divbox.img_id, dx, dy, id, text, 'update-comment'); } //fill up comment form and show him @@ -202,8 +198,6 @@ function box_onmouseover(box, done) var id = box.id; var pointer = document.getElementById(box.id + '-pointer'); pointer.className = done ? 'pointer-done-hi' : 'pointer-hi'; - //console.log('mouseout'); - } function box_onmouseout(box, done) @@ -211,8 +205,6 @@ function box_onmouseout(box, done) var id = box.id; var pointer = document.getElementById(box.id + '-pointer'); pointer.className = done ? 'pointer-done' : 'pointer'; - - //console.log('mousein'); } function save_scroll(form) @@ -220,8 +212,6 @@ function save_scroll(form) //alert('save_scroll:' + document.body.scrollTop); form.scroll.value = document.body.scrollTop; //alert('save_scroll:' + form.scroll.value); - - return true; } diff --git a/korektury/templates/korektury/opraf.html b/korektury/templates/korektury/opraf.html index 251f722f..1f3d6e9b 100644 --- a/korektury/templates/korektury/opraf.html +++ b/korektury/templates/korektury/opraf.html @@ -99,21 +99,21 @@ {% endif %} - - {% if o.komentare %} - - {% else %} - - {% endif %} - + + {% if o.komentare %} + + {% else %} + + {% endif %} +