From 7de6a7e614745c0ac043074ea43a2ca0d8ab424a Mon Sep 17 00:00:00 2001 From: Tomas 'Jethro' Pokorny Date: Tue, 1 Dec 2015 23:24:21 +0100 Subject: [PATCH] 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 zcmV+e2K@PnP)M{oQ?m-0iYJ*`WTD&)(^`uixIBuP#oI>*TtWitDuBeZTv%hU5SU5P-+CgCl|? zy7!^~uec!bR8;OWz-8Wzi}xIQj1WE8>JiU{YYxn|{>0ip?&i55LY8mzUvNuPL1RuuMvx>(4AbI|abN=D?;9z}Ckm)h4yZ+FHxTv+LtshxGMR_$f|5 zEo!?*?vZzx03n1B0&tDo3avXZr^~JEV!DUSw%lx2ad+(y*>0L0@M0H>{y zQ)f@Px>FxO6*A&e+K9UW6#*R3e5EtBGxaS2^grM3+VB}*W9OT@r4nnoamJSBf(Rv- zZcsO>=KFHaMy}~Hb&xC+&KOewsteB4YJlCPc~aB{NcV8j8Nv0e+;P?@xp-$|)PT*~ zn>rdC0>&NdQdR@2L-m>Z%zxMcle+wDatdJb)J9ew0%$c;C|Mrp&B=|$O}uiD*;PNF z?zaCKGK|EVs{uaEM7JCOXqCvJcMBj`bDKKV#xP-^sjMY#OByYC@oRh2Za3j_FF%?W zY+V&|j|j{gAKNW}ZD;l4PJj+!$|PS)P242Yj@JCR3bVn$Hu(E9R1%#bVgORj%`@Hw z7!Q$;{kH%vQ&sdKfY=Goji=7#3*}^lFe9^=bU0MoFBiOJitr;ZnC_E)9YFKf&AJUC zfN;q%aKWe4Y@tzg=zB%fcy6P?(2zV+hI@EKpFj?^fLSha0;oBHhgl9#2bn*_0>Cda zWjE(lK7^P&5R!KKv6+GtjNU=-5K`y_sR~^?+ngbxZ*J*zpz$~+g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P^XJqPBbIW6s}d4{z_f5Om?vMgNQEJG?v2T=KYd^0M3I6IZxbny)%vZR&LD zJpPl@Psh8QyPB@KTx+@RdcC!KX7}kEo;S|j^u2lU7XQ}Oo;f|;z4Ll+_r>@1-xl3| zawq-H%e&ckC+@AhPrP6BKT#_XdT7&;F71j}Joy zkC~6lh7E@6o;W@^IpRNZ{ptLtL(gQ-CY~4mqW;US7Zxvm_|@yz&e53Bp_lTPlfP|z zrTyx_>lv@x#=^!PzR7qqF<$gm`|ZJZ+;<)Cqu&ot2z=0000WV@Og>004R=004l4008;_004mL004C`008P>0026e000+nl3&F} z00089NklSw{qXSe zyo7U(gNWjQ5_Me%r4+H)8WM>Fbf$yp4347?B$7#R!$3R{_bx3icBa$mlMaWY&r@C9 zzkgM>KKxSURbTx?|T58b5KfP=)mHyh5PHNRM#OzL6ygITTzr= zNs`g$afLtzTo}Hb2ZZe6tO6+!o!(rGIo9=d3Vss?fqiNdZ zVo6e4TCRVySmeI|N(F3fWu4PgQ*UDNczsPx4Mb6drmBc)+Ov&~%$-;)=9eTX>ht-U zN{^Ms8DpS?5D-F;&1RkRb91Aco169al9G^N7^^m$4dvzKd}n9JwyLUri^Vd3zTSV) zZa+M3E;2)wWr&${8irwznVIPUlgV`IL`6l=?XGMlgq$58`#KzrMkPuqY>M)+uI@~$ zY_&$i;d#7z*^9t%0OH*I9CF*+rwzk6SLSpsIi0R6I%7MUrpcs2c8g@O$S5mwCYP6&GO{cm&*$@3HBGHt2!|gP6&J(nt$iF>iFDq) z(TcJ0apdxO5CB5qc0`e7G&DA%t-bw$x7ORu7(;q}9m!M*Bf*h-qru>lAE6Ko&Orf? zeZ3(C+eAu>nwy*2E;KY=+sLGIfk5Exr_WzL0I(JoIRI904nP_}iWH)V91xA&!5^?7 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')),