Browse Source

Merge branch 'opraf_nasad' into stable

remotes/origin/temata
Bc. Petr Pecha 9 years ago
parent
commit
db661a4693
  1. 3
      korektury/TODO
  2. 20
      korektury/migrations/0008_auto_20151229_1556.py
  3. 17
      korektury/models.py
  4. BIN
      korektury/static/korektury/imgs/hide.png
  5. 11
      korektury/static/korektury/opraf.css
  6. 14
      korektury/static/korektury/opraf.js
  7. 17
      korektury/templates/korektury/opraf.html
  8. 2
      korektury/templates/korektury/seznam.html
  9. 46
      korektury/views.py

3
korektury/TODO

@ -4,11 +4,8 @@
- vyžádat pozornost autora obsahu - vyžádat pozornost autora obsahu
- zvednout upload limit na 5MB - zvednout upload limit na 5MB
- sbalit a rozbalit korekturu - sbalit a rozbalit korekturu
- nápověda
- nahrávání jiných věcí než PDF - kontrolovat? - nahrávání jiných věcí než PDF - kontrolovat?
- stylování - stylování
- vylepšení hlavičky
- seznam PDF, homepage M&M, admin, wiki
- seznam PDF - co zobrazovat? - seznam PDF - co zobrazovat?

20
korektury/migrations/0008_auto_20151229_1556.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', '0007_auto_20151225_1237'),
]
operations = [
migrations.AlterField(
model_name='oprava',
name='status',
field=models.CharField(default=b'k_oprave', max_length=16, verbose_name='stav opravy', choices=[(b'k_oprave', 'K oprav\u011b'), (b'opraveno', 'Opraveno'), (b'neni_chyba', 'Nen\xed chyba'), (b'k_reakci', 'K reakci autora textu')]),
preserve_default=True,
),
]

17
korektury/models.py

@ -1,28 +1,13 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
import random
from django.db import models from django.db import models
from django.contrib import auth
from django.utils import timezone from django.utils import timezone
from django.conf import settings from django.conf import settings
from django.utils.encoding import python_2_unicode_compatible from django.utils.encoding import python_2_unicode_compatible
from django.utils.encoding import force_unicode 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 django.core.exceptions import ObjectDoesNotExist from django.core.exceptions import ObjectDoesNotExist
from imagekit.models import ImageSpecField, ProcessedImageField
from imagekit.processors import ResizeToFit, Transpose
import os
import subprocess import subprocess
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 import reversion
# PrilohaReseni method # PrilohaReseni method
@ -123,13 +108,11 @@ class Oprava(models.Model):
STATUS_OPRAVENO = 'opraveno' STATUS_OPRAVENO = 'opraveno'
STATUS_NENI_CHYBA = 'neni_chyba' STATUS_NENI_CHYBA = 'neni_chyba'
STATUS_K_REAKCI = 'k_reakci' STATUS_K_REAKCI = 'k_reakci'
STATUS_SMAZANO = 'smazano'
STATUS_CHOICES = ( STATUS_CHOICES = (
(STATUS_K_OPRAVE, u'K opravě'), (STATUS_K_OPRAVE, u'K opravě'),
(STATUS_OPRAVENO, u'Opraveno'), (STATUS_OPRAVENO, u'Opraveno'),
(STATUS_NENI_CHYBA, u'Není chyba'), (STATUS_NENI_CHYBA, u'Není chyba'),
(STATUS_K_REAKCI, u'K reakci autora textu'), (STATUS_K_REAKCI, u'K reakci autora textu'),
(STATUS_SMAZANO, u'Smazáno'),
) )
status = models.CharField(u'stav opravy',max_length=16, choices=STATUS_CHOICES, blank=False, status = models.CharField(u'stav opravy',max_length=16, choices=STATUS_CHOICES, blank=False,
default = STATUS_K_OPRAVE) default = STATUS_K_OPRAVE)

BIN
korektury/static/korektury/imgs/hide.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 270 B

11
korektury/static/korektury/opraf.css

@ -1,8 +1,13 @@
body{background: #f3f3f3; color: black;} body,
body.comitting { .adding{
background: #f3f3f3;
color: black;
}
.comitting
{
background: yellow; background: yellow;
} }
body.deprecated { .deprecated {
background: red; background: red;
} }

14
korektury/static/korektury/opraf.js

@ -122,6 +122,20 @@ function img_click(element, ev) {
} }
return show_form(img_id, dx, dy, '', '', '', ''); return show_form(img_id, dx, dy, '', '', '', '');
} }
// hide or show text of correction
function toggle_visibility(button){
var divbox = button.parentNode.parentNode.parentNode;
var id = divbox.id;
var text = document.getElementById(id+'-text');
if (text.style.display == 'none'){
text.style.display = 'block';
}else {
text.style.display = 'none';
}
for (var i=0;i<comments.length-1;i++){
place_comments_one_div(comments[i][0], comments[i][1])
}
}
// show comment form, when 'edit' or 'comment' button pressed // show comment form, when 'edit' or 'comment' button pressed
function box_edit(button, action) function box_edit(button, action)

17
korektury/templates/korektury/opraf.html

@ -15,7 +15,9 @@
<br> <br>
<i>Klikni na chybu, napiš komentář</i> | <i>Klikni na chybu, napiš komentář</i> |
<a href="../">seznam souborů</a> | <a href="../">seznam souborů</a> |
<a href="../help">nápověda</a> |&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;| <a href="/admin/korektury/korekturovanepdf/">Spravovat PDF</a> |
<a href="../help">nápověda</a> |
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;|
<a href="/">hlavní stránka</a> | <a href="/">hlavní stránka</a> |
<a href="https://mam.mff.cuni.cz/wiki">wiki</a> | <a href="https://mam.mff.cuni.cz/wiki">wiki</a> |
<hr/> <hr/>
@ -24,7 +26,7 @@
<!-- Pridat korekturu / komentar !--> <!-- Pridat korekturu / komentar !-->
<form action='' onsubmit='save_scroll(this)' id="commform" method="POST"> <form action='' onsubmit='save_scroll(this)' id="commform" method="POST">
{% csrf_token %} {% csrf_token %}
<input size="8" name="au" value="{{user.username}}"/> <input size="24" name="au" value="{{user.first_name}} {{user.last_name}}" readonly/>
<input type=submit value="Oprav!"/> <input type=submit value="Oprav!"/>
<button type="button" onclick="close_commform()">Zavřít</button> <button type="button" onclick="close_commform()">Zavřít</button>
<br/> <br/>
@ -142,6 +144,10 @@
<button type='button' onclick='box_edit(this, "comment");' title='Komentovat'> <button type='button' onclick='box_edit(this, "comment");' title='Komentovat'>
<img src="{% static "korektury/imgs/comment.png" %}"/> <img src="{% static "korektury/imgs/comment.png" %}"/>
</button> </button>
<button type='button' onclick='toggle_visibility(this);' title='Skrýt/Zobrazit'>
<img src="{% static "korektury/imgs/hide.png" %}"/>
</button>
</div> </div>
</div> </div>
<div id='op{{o.id}}-text'>{{o.text}}</div> <div id='op{{o.id}}-text'>{{o.text}}</div>
@ -176,9 +182,14 @@
{% endfor %} {% endfor %}
<script> <script>
var comments = [
{% for s in opravy_strany %} {% for s in opravy_strany %}
place_comments_one_div("img-{{s.strana}}", [{% for o in s.op_id %}["op{{o.id}}",{{o.x}},{{o.y}}],{% endfor %}[]]); ["img-{{s.strana}}", [{% for o in s.op_id %}["op{{o.id}}",{{o.x}},{{o.y}}],{% endfor %}[]]],
{% endfor %} {% endfor %}
[]]
for (var i=0;i<comments.length-1;i++){
place_comments_one_div(comments[i][0], comments[i][1])
}
{% if scroll %} {% if scroll %}
window.scrollTo(0,{{scroll}}); window.scrollTo(0,{{scroll}});
{% endif %} {% endif %}

2
korektury/templates/korektury/seznam.html

@ -12,7 +12,7 @@
<ul> <ul>
{% for pdf in object_list %} {% for pdf in object_list %}
<li> <b>{{ pdf.nazev }}</b> <i>{{pdf.komentar}}</i> <a href="/korektury/{{pdf.id}}">{{pdf.pdf.url}}</a> </li> <li> <b>{{ pdf.nazev }}</b> <i>{{pdf.komentar}}</i> <a href="/korektury/{{pdf.id}}">{{pdf.pdf.name}}</a> </li>
{% empty %} {% empty %}
<li> Nejsou žádné dokumenty ke korekturování. <li> Nejsou žádné dokumenty ke korekturování.
{% endfor %} {% endfor %}

46
korektury/views.py

@ -1,24 +1,15 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
from django.shortcuts import render 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.views import generic
from django.utils.translation import ugettext as _ from django.utils.translation import ugettext as _
from django.http import Http404 from django.conf import settings
from django.http import HttpResponseRedirect
from .models import Oprava,Komentar,KorekturovanePDF from .models import Oprava,Komentar,KorekturovanePDF
from .forms import OpravaForm from .forms import OpravaForm
from datetime import timedelta, date, datetime
from itertools import groupby
import tempfile
import subprocess import subprocess
import shutil import shutil
import os import os
from django.conf import settings
import unicodedata import unicodedata
class KorekturyHelpView(generic.TemplateView): class KorekturyHelpView(generic.TemplateView):
@ -39,7 +30,8 @@ class KorekturyView(generic.TemplateView):
q = request.POST q = request.POST
scroll = q.get('scroll') scroll = q.get('scroll')
autor = q.get('au') autor = q.get('au')
print "autor:" + str(autor)
print "autor:" + unicode(autor)
if not autor: if not autor:
autor = 'anonym' autor = 'anonym'
if not scroll: if not scroll:
@ -52,52 +44,52 @@ class KorekturyView(generic.TemplateView):
y = int(q.get('y')) y = int(q.get('y'))
text = q.get('txt') text = q.get('txt')
strana = int(q.get('img-id')[4:]) strana = int(q.get('img-id')[4:])
pdf = KorekturovanePDF.objects.filter(id=q.get('pdf')).first() pdf = KorekturovanePDF.objects.get(id=q.get('pdf'))
op = Oprava(x=x,y=y, autor=autor, text=text, strana=strana,pdf = pdf) op = Oprava(x=x,y=y, autor=autor, text=text, strana=strana,pdf = pdf)
op.save() op.save()
elif (action == u'del'): elif (action == u'del'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.filter(id=id).first() op = Oprava.objects.get(id=id)
op.delete() op.delete()
elif (action == u'update'): elif (action == u'update'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.filter(id=id).first() op = Oprava.objects.get(id=id)
text = q.get('txt') text = q.get('txt')
op.autor = autor op.autor = autor
op.text = text op.text = text
op.save() op.save()
elif (action == u'undone'): elif (action == u'undone'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.filter(id=id).first() op = Oprava.objects.get(id=id)
op.status = op.STATUS_K_OPRAVE op.status = op.STATUS_K_OPRAVE
op.save() op.save()
elif (action == u'done'): elif (action == u'done'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.filter(id=id).first() op = Oprava.objects.get(id=id)
op.status = op.STATUS_OPRAVENO op.status = op.STATUS_OPRAVENO
op.save() op.save()
elif (action == u'wontfix'): elif (action == u'wontfix'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.filter(id=id).first() op = Oprava.objects.get(id=id)
op.status = op.STATUS_NENI_CHYBA op.status = op.STATUS_NENI_CHYBA
op.save() op.save()
elif (action == u'comment'): elif (action == u'comment'):
id = int(q.get('id')) id = int(q.get('id'))
op = Oprava.objects.filter(id=id).first() op = Oprava.objects.get(id=id)
text = q.get('txt') text = q.get('txt')
kom = Komentar(oprava=op,autor=autor,text=text) kom = Komentar(oprava=op,autor=autor,text=text)
kom.save() kom.save()
elif (action == u'update-comment'): elif (action == u'update-comment'):
id = int(q.get('id')) id = int(q.get('id'))
kom = Komentar.objects.filter(id=id).first() kom = Komentar.objects.get(id=id)
text = q.get('txt') text = q.get('txt')
kom.text = text kom.text = text
kom.autor = autor kom.autor = autor
kom.save() kom.save()
elif (action == u'del-comment'): elif (action == u'del-comment'):
id = int(q.get('id')) id = int(q.get('id'))
kom = Komentar.objects.filter(id=id).first() kom = Komentar.objects.get(id=id)
kom.delete() kom.delete()
elif (action == u'delall'): elif (action == u'delall'):
pdf = KorekturovanePDF.objects.filter(id=q.get('pdf')) pdf = KorekturovanePDF.objects.filter(id=q.get('pdf'))
@ -116,24 +108,14 @@ class KorekturyView(generic.TemplateView):
elif (q.get('state') == u'deprecated'): elif (q.get('state') == u'deprecated'):
pdf.status = pdf.STATUS_ZASTARALE pdf.status = pdf.STATUS_ZASTARALE
pdf.save() pdf.save()
# return HttpResponse(u'Keys: %s '%(q.iteitems()))
# return HttpResponse(u'Oprav: %d, akce: %s'%(
# len(Oprava.objects.all()),action))
# return HttpResponseRedirect(reverse('korektury')+"?scroll=%s"%(scroll))
context = self.get_context_data() context = self.get_context_data()
context['scroll'] = scroll context['scroll'] = scroll
context['autor'] = autor context['autor'] = autor
return render(request, 'korektury/opraf.html',context) 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): def get_context_data(self, **kwargs):
context = super(KorekturyView,self).get_context_data(**kwargs) context = super(KorekturyView,self).get_context_data(**kwargs)
pdf = KorekturovanePDF.objects.filter(id=self.kwargs['pdf']).first() pdf = KorekturovanePDF.objects.get(id=self.kwargs['pdf'])
context['pdf'] = pdf context['pdf'] = pdf
context['img_name'] = os.path.split(pdf.pdf.path)[1].split('.')[0] context['img_name'] = os.path.split(pdf.pdf.path)[1].split('.')[0]
context['img_path'] = settings.KOREKTURY_IMG_DIR context['img_path'] = settings.KOREKTURY_IMG_DIR

Loading…
Cancel
Save