Skoro hotova nova verze korekturovatka.
Dodelany nektere vychytavky z nove verze oprafu. Nefunguje editace komentaru. Zamky a podobna havet neimplementovany.
This commit is contained in:
		
							parent
							
								
									09b2090371
								
							
						
					
					
						commit
						2a163fe6a4
					
				
					 9 changed files with 177 additions and 28 deletions
				
			
		
							
								
								
									
										39
									
								
								korektury/migrations/0002_auto_20151202_2351.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										39
									
								
								korektury/migrations/0002_auto_20151202_2351.py
									
									
									
									
									
										Normal file
									
								
							|  | @ -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', | ||||||
|  |         ), | ||||||
|  |     ] | ||||||
|  | @ -98,9 +98,9 @@ class Oprava(models.Model): | ||||||
| 
 | 
 | ||||||
| @reversion.register(ignore_duplicate_revision=True) | @reversion.register(ignore_duplicate_revision=True) | ||||||
| @python_2_unicode_compatible | @python_2_unicode_compatible | ||||||
| class OpravaKomentar(models.Model): | class Komentar(models.Model): | ||||||
|     class Meta: |     class Meta: | ||||||
|         db_table = 'opravy_komentare' |         db_table = 'komentare' | ||||||
|         verbose_name = u'Komentář k opravě' |         verbose_name = u'Komentář k opravě' | ||||||
|         verbose_name_plural = u'Komentáře k opravě' |         verbose_name_plural = u'Komentáře k opravě' | ||||||
|         ordering = ['cas'] |         ordering = ['cas'] | ||||||
|  | @ -108,7 +108,7 @@ class OpravaKomentar(models.Model): | ||||||
|     #Interní ID |     #Interní ID | ||||||
|     id  = models.AutoField(primary_key = True) |     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) |     oprava = models.ForeignKey(Oprava) | ||||||
|     # TODO: Změnit na cizí klíč do orgů |     # TODO: Změnit na cizí klíč do orgů | ||||||
|  |  | ||||||
							
								
								
									
										
											BIN
										
									
								
								korektury/static/korektury/imgs/comment.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								korektury/static/korektury/imgs/comment.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 726 B | 
							
								
								
									
										
											BIN
										
									
								
								korektury/static/korektury/imgs/delete-gr.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								korektury/static/korektury/imgs/delete-gr.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 593 B | 
							
								
								
									
										
											BIN
										
									
								
								korektury/static/korektury/imgs/edit-gr.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								korektury/static/korektury/imgs/edit-gr.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 973 B | 
|  | @ -1,3 +1,10 @@ | ||||||
|  | body{background: #f3f3f3; color: black;} | ||||||
|  | body.locked { | ||||||
|  |     background: rgb(144, 189, 255); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | img{background:white;} | ||||||
|  | 
 | ||||||
| .pointer-hi,  | .pointer-hi,  | ||||||
| .pointer,  | .pointer,  | ||||||
| .pointer-done,  | .pointer-done,  | ||||||
|  | @ -82,11 +89,6 @@ form { | ||||||
| 	background-color: yellow;	 | 	background-color: yellow;	 | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| body { |  | ||||||
| 	background-color: #b0b0ff; |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| .box button, | .box button, | ||||||
| .box img, | .box img, | ||||||
|  | @ -103,3 +105,18 @@ body { | ||||||
| .box-done button:hover { | .box-done button:hover { | ||||||
| 	border: 1px solid black; | 	border: 1px solid black; | ||||||
| } | } | ||||||
|  | 
 | ||||||
|  | .comment hr { | ||||||
|  | 	height: 0px; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .corr-header { | ||||||
|  |     overflow: auto; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | .author { | ||||||
|  |     font-weight: bold; | ||||||
|  |     float: left; | ||||||
|  |     margin-top: 3px; | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  |  | ||||||
|  | @ -113,24 +113,47 @@ function img_click(element, ev) { | ||||||
| 	return show_form(img_id, dx, dy, '', '', '', ''); | 	return show_form(img_id, dx, dy, '', '', '', ''); | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // show comment form, when 'edit' button pressed
 | // show comment form, when 'edit' or 'comment' button pressed
 | ||||||
| function box_edit(button)  | function box_edit(button, action) | ||||||
| { | { | ||||||
| 	var divbox = button.parentNode.parentNode.parentNode; | 	var divbox = button.parentNode.parentNode.parentNode.parentNode; | ||||||
| 	var id = divbox.id; | 	var id = divbox.id; | ||||||
| 	//alert("id: " +  id);
 | 	//alert("id: " +  id);
 | ||||||
| 	var divpointer = document.getElementById(divbox.id + '-pointer'); | 	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 dx = parseInt(divpointer.style.left); | ||||||
| 	var dy = parseInt(divpointer.style.top); | 	var dy = parseInt(divpointer.style.top); | ||||||
| 	//alert('not yet 2:' + text + text_el); // + divpointer.style.top "x" + divpo );
 | 	//alert('not yet 2:' + text + text_el); // + divpointer.style.top "x" + divpo );
 | ||||||
| 	id = id.substring(2); | 	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
 | //fill up comment form and show him
 | ||||||
| function show_form(img_id, dx, dy, id, text, action) { | function show_form(img_id, dx, dy, id, text, action) { | ||||||
| 	var form = document.getElementById('commform'); | 	var form = document.getElementById('commform'); | ||||||
|  |  | ||||||
|  | @ -61,30 +61,84 @@ | ||||||
| 	    onmouseover='box_onmouseover(this,{% if o.status = 'opraveno' %}1{% else %}0{% endif %})'  | 	    onmouseover='box_onmouseover(this,{% if o.status = 'opraveno' %}1{% else %}0{% endif %})'  | ||||||
| 		onmouseout='box_onmouseout(this,{% if o.status = 'opraveno' %}1{% else %}0{% endif %})' > | 		onmouseout='box_onmouseout(this,{% if o.status = 'opraveno' %}1{% else %}0{% endif %})' > | ||||||
| 	   | 	   | ||||||
|           |     <div class='corr-header'>  | ||||||
| 	<b>{{o.autor}}</b> | 	<div class='author'>{{o.autor}}</div> | ||||||
| 	 <div class='float-right'> | 	 <div class='float-right'> | ||||||
| 	  <form  action='' onsubmit='save_scroll(this)' method='POST'> | 	  <form  action='' onsubmit='save_scroll(this)' method='POST'> | ||||||
| 		{% csrf_token %} | 		{% csrf_token %} | ||||||
| 	   <input type='hidden' name='pdf' value='22_3_verze5.pdf'> | 	   <input type='hidden' name='pdf' value='22_3_verze5.pdf'> | ||||||
| 	   <input type='hidden' name='id' value='{{o.id}}'> | 	   <input type='hidden' name='id' value='{{o.id}}'> | ||||||
| 	   <input type='hidden' name='scroll'> | 	   <input type='hidden' name='scroll'> | ||||||
| 	   <button type='submit' name='action' value='del' title='Sma¾ opravu'><img src="/static/korektury/imgs/delete.png"/></button> | 	   {% if o.komentare %} | ||||||
| 	   {% if o.status = 'opraveno' %} | 	   <button name='action' value='del' type='button' | ||||||
| 	   	   <button type='submit' name='action' value='undone' title='Oznaè jako neopravené'><img src="/static/korektury/imgs/undo.png"/></button> |             title="Korekturu nelze smazat – už ji někdo okomentoval"> | ||||||
|  | 		   <img src="/static/korektury/imgs/delete-gr.png"/> | ||||||
|  | 	   </button> | ||||||
| 	   {% else %} | 	   {% else %} | ||||||
| 	   	   <button type='submit' name='action' value='done' title='Oznaè jako opravené'><img src="/static/korektury/imgs/check.png"/></button> | 	   <button type='submit' name='action' value='del' title='Smaž opravu'> | ||||||
|  | 		   <img src="/static/korektury/imgs/delete.png"/> | ||||||
|  | 	   </button> | ||||||
| 	   {% endif %} | 	   {% endif %} | ||||||
| 	    | 	    | ||||||
|  | 	   {% if o.status = 'opraveno' %} | ||||||
|  | 	   <button type='submit' name='action' value='undone' title='Označ jako neopravené'> | ||||||
|  | 		   <img src="/static/korektury/imgs/undo.png"/> | ||||||
|  | 	   </button> | ||||||
|  | 	   {% else %} | ||||||
|  | 	   <button type='submit' name='action' value='done' title='Označ jako opravené'> | ||||||
|  | 		   <img src="/static/korektury/imgs/check.png"/> | ||||||
|  | 	   </button> | ||||||
|  | 	   {% endif %} | ||||||
| 	     | 	     | ||||||
| 	   <button type='button' onclick='box_edit(this);' title='Oprav opravu'><img src="/static/korektury/imgs/edit.png"/></button> |        {% if o.komentare %} | ||||||
| 	   <a href='#op{{o.id}}'><button type='button' title='Link na opravu'><img src="/static/korektury/imgs/link.png"/></button></a> | 		<button type='button' title="Korekturu nelze upravit – už ji někdo okomentoval"> | ||||||
| 	   	    <a href='#op579'><img title='Dal¹í oprava' src="/static/korektury/imgs/next.png"/></button></a> | 			<img src="/static/korektury/imgs/edit-gr.png"/> | ||||||
|  | 		</button> | ||||||
|  | 	   {% else %} | ||||||
|  | 	   <button type='button' onclick='box_edit(this);' title='Oprav opravu'> | ||||||
|  | 		   <img src="/static/korektury/imgs/edit.png"/> | ||||||
|  | 	   </button> | ||||||
|  | 	   {% endif %} | ||||||
|  | 	   <button type='button' onclick='box_edit(this, "comment");' title='Komentovat'> | ||||||
|  | 		   <img src="/static/korektury/imgs/comment.png"/> | ||||||
|  | 	   </button> | ||||||
|  | 
 | ||||||
|  | 	   <a href='#op{{o.id}}'><button type='button' title='Link na opravu'> | ||||||
|  | 			   <img src="/static/korektury/imgs/link.png"/> | ||||||
|  | 	   </button></a> | ||||||
|  | 	   <button><a href='#op579'> | ||||||
|  | 			   <img title='Dal¹í oprava' src="/static/korektury/imgs/next.png"/> | ||||||
|  | 	   </a></button> | ||||||
| 	     | 	     | ||||||
| 	  </form> | 	  </form> | ||||||
| 	 </div> 	 <div id='op{{o.id}}-text'>{{o.text}}</div> | 	 </div> | ||||||
|  | 	</div> | ||||||
|  | 	<div id='op{{o.id}}-text'>{{o.text}}</div> | ||||||
|  | 	{% for k in o.komentare %} | ||||||
|  |     <hr> | ||||||
|  | 	<div class='comment' id='k{{k.id}}'> | ||||||
|  |     	<div class='corr-header'> | ||||||
|  |         	<div class='author'>{{k.autor}}</div> | ||||||
|  |             	<div class="float-right"> | ||||||
|  |                     <form  action='' onsubmit='save_scroll(this)' method='POST'> | ||||||
|  | 					  {% csrf_token %} | ||||||
|  |                       <input type='hidden' name='pdf' value='22_3_verze1.pdf'> | ||||||
|  | 					  <input type='hidden' name='id' value='{{k.id}}'> | ||||||
|  |                       <input type='hidden' name='scroll'> | ||||||
|  |                       <button type='submit' name='action' value='del-comment' title='Smaž komentář' | ||||||
|  |                       	onclick='return confirm("Opravdu smazat komentář?")'> | ||||||
|  | 						  <img src="/static/korektury/imgs/delete.png"/> | ||||||
|  | 					  </button> | ||||||
|  |                     </form> | ||||||
|  |                     <button type='button' onclick='update_comment(this);' title='Uprav komentář'> | ||||||
|  | 						<img src="/static/korektury/imgs/edit.png"/></button> | ||||||
|  |                   </div> | ||||||
|  |               </div> | ||||||
|  | 			  <div id='kt{{k.id}}'>{{k.text}}</div> | ||||||
|  |             </div> | ||||||
|  | 	{% endfor %} | ||||||
|           |           | ||||||
| 	</div>		<div onclick='img_click(this,event)' id='op579-pointer' class='pointer'></div> | 	</div>	 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| {% endfor %} | {% endfor %} | ||||||
|  |  | ||||||
|  | @ -9,7 +9,7 @@ from django.utils.translation import ugettext as _ | ||||||
| from django.http import Http404 | from django.http import Http404 | ||||||
| from django.http import HttpResponseRedirect | from django.http import HttpResponseRedirect | ||||||
| 
 | 
 | ||||||
| from .models import Oprava | from .models import Oprava,Komentar | ||||||
| from .forms import OpravaForm | from .forms import OpravaForm | ||||||
| 
 | 
 | ||||||
| from datetime import timedelta, date, datetime | from datetime import timedelta, date, datetime | ||||||
|  | @ -65,7 +65,20 @@ class KorekturyView(generic.TemplateView): | ||||||
|             op = Oprava.objects.filter(id=id).first() |             op = Oprava.objects.filter(id=id).first() | ||||||
|             op.status = op.STATUS_OPRAVENO |             op.status = op.STATUS_OPRAVENO | ||||||
|             op.save() |             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'%( |         return HttpResponse(u'Oprav: %d, akce: %s'%( | ||||||
|             len(Oprava.objects.all()),action)) |             len(Oprava.objects.all()),action)) | ||||||
|   |   | ||||||
|  | @ -78,7 +91,10 @@ class KorekturyView(generic.TemplateView): | ||||||
|         context['img_name'] = "22_3_verze5" |         context['img_name'] = "22_3_verze5" | ||||||
|         context['img_indexes'] = range(27)  |         context['img_indexes'] = range(27)  | ||||||
|         context['form_oprava'] = OpravaForm() |         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 |         return context | ||||||
|     def form_valid(self,form): |     def form_valid(self,form): | ||||||
|         return super(KorekturyView,self).form_valid(form) |         return super(KorekturyView,self).form_valid(form) | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue