Merge branch 'opraf_nasad' into stable
This commit is contained in:
commit
db661a4693
9 changed files with 71 additions and 59 deletions
|
@ -4,11 +4,8 @@
|
|||
- vyžádat pozornost autora obsahu
|
||||
- zvednout upload limit na 5MB
|
||||
- sbalit a rozbalit korekturu
|
||||
- nápověda
|
||||
- nahrávání jiných věcí než PDF - kontrolovat?
|
||||
- stylování
|
||||
- vylepšení hlavičky
|
||||
- seznam PDF, homepage M&M, admin, wiki
|
||||
- seznam PDF - co zobrazovat?
|
||||
|
||||
|
||||
|
|
20
korektury/migrations/0008_auto_20151229_1556.py
Normal file
20
korektury/migrations/0008_auto_20151229_1556.py
Normal file
|
@ -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,
|
||||
),
|
||||
]
|
|
@ -1,28 +1,13 @@
|
|||
# -*- 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 django.core.exceptions import ObjectDoesNotExist
|
||||
from imagekit.models import ImageSpecField, ProcessedImageField
|
||||
from imagekit.processors import ResizeToFit, Transpose
|
||||
|
||||
import os
|
||||
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
|
||||
|
||||
# PrilohaReseni method
|
||||
|
@ -123,13 +108,11 @@ class Oprava(models.Model):
|
|||
STATUS_OPRAVENO = 'opraveno'
|
||||
STATUS_NENI_CHYBA = 'neni_chyba'
|
||||
STATUS_K_REAKCI = 'k_reakci'
|
||||
STATUS_SMAZANO = 'smazano'
|
||||
STATUS_CHOICES = (
|
||||
(STATUS_K_OPRAVE, u'K opravě'),
|
||||
(STATUS_OPRAVENO, u'Opraveno'),
|
||||
(STATUS_NENI_CHYBA, u'Není chyba'),
|
||||
(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,
|
||||
default = STATUS_K_OPRAVE)
|
||||
|
|
BIN
korektury/static/korektury/imgs/hide.png
Normal file
BIN
korektury/static/korektury/imgs/hide.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 270 B |
|
@ -1,8 +1,13 @@
|
|||
body{background: #f3f3f3; color: black;}
|
||||
body.comitting {
|
||||
body,
|
||||
.adding{
|
||||
background: #f3f3f3;
|
||||
color: black;
|
||||
}
|
||||
.comitting
|
||||
{
|
||||
background: yellow;
|
||||
}
|
||||
body.deprecated {
|
||||
.deprecated {
|
||||
background: red;
|
||||
}
|
||||
|
||||
|
|
|
@ -122,6 +122,20 @@ function img_click(element, ev) {
|
|||
}
|
||||
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
|
||||
function box_edit(button, action)
|
||||
|
|
|
@ -15,7 +15,9 @@
|
|||
<br>
|
||||
<i>Klikni na chybu, napiš komentář</i> |
|
||||
<a href="../">seznam souborů</a> |
|
||||
<a href="../help">nápověda</a> | |
|
||||
<a href="/admin/korektury/korekturovanepdf/">Spravovat PDF</a> |
|
||||
<a href="../help">nápověda</a> |
|
||||
|
|
||||
<a href="/">hlavní stránka</a> |
|
||||
<a href="https://mam.mff.cuni.cz/wiki">wiki</a> |
|
||||
<hr/>
|
||||
|
@ -24,7 +26,7 @@
|
|||
<!-- Pridat korekturu / komentar !-->
|
||||
<form action='' onsubmit='save_scroll(this)' id="commform" method="POST">
|
||||
{% 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!"/>
|
||||
<button type="button" onclick="close_commform()">Zavřít</button>
|
||||
<br/>
|
||||
|
@ -142,6 +144,10 @@
|
|||
<button type='button' onclick='box_edit(this, "comment");' title='Komentovat'>
|
||||
<img src="{% static "korektury/imgs/comment.png" %}"/>
|
||||
</button>
|
||||
<button type='button' onclick='toggle_visibility(this);' title='Skrýt/Zobrazit'>
|
||||
<img src="{% static "korektury/imgs/hide.png" %}"/>
|
||||
</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div id='op{{o.id}}-text'>{{o.text}}</div>
|
||||
|
@ -176,9 +182,14 @@
|
|||
{% endfor %}
|
||||
|
||||
<script>
|
||||
var comments = [
|
||||
{% 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 %}
|
||||
[]]
|
||||
for (var i=0;i<comments.length-1;i++){
|
||||
place_comments_one_div(comments[i][0], comments[i][1])
|
||||
}
|
||||
{% if scroll %}
|
||||
window.scrollTo(0,{{scroll}});
|
||||
{% endif %}
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
|
||||
<ul>
|
||||
{% 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 %}
|
||||
<li> Nejsou žádné dokumenty ke korekturování.
|
||||
{% endfor %}
|
||||
|
|
|
@ -1,24 +1,15 @@
|
|||
# -*- 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 django.conf import settings
|
||||
|
||||
from .models import Oprava,Komentar,KorekturovanePDF
|
||||
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
|
||||
|
||||
class KorekturyHelpView(generic.TemplateView):
|
||||
|
@ -39,7 +30,8 @@ class KorekturyView(generic.TemplateView):
|
|||
q = request.POST
|
||||
scroll = q.get('scroll')
|
||||
autor = q.get('au')
|
||||
print "autor:" + str(autor)
|
||||
|
||||
print "autor:" + unicode(autor)
|
||||
if not autor:
|
||||
autor = 'anonym'
|
||||
if not scroll:
|
||||
|
@ -52,52 +44,52 @@ class KorekturyView(generic.TemplateView):
|
|||
y = int(q.get('y'))
|
||||
text = q.get('txt')
|
||||
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.save()
|
||||
elif (action == u'del'):
|
||||
id = int(q.get('id'))
|
||||
op = Oprava.objects.filter(id=id).first()
|
||||
op = Oprava.objects.get(id=id)
|
||||
op.delete()
|
||||
elif (action == u'update'):
|
||||
id = int(q.get('id'))
|
||||
op = Oprava.objects.filter(id=id).first()
|
||||
op = Oprava.objects.get(id=id)
|
||||
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 = Oprava.objects.get(id=id)
|
||||
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 = Oprava.objects.get(id=id)
|
||||
op.status = op.STATUS_OPRAVENO
|
||||
op.save()
|
||||
elif (action == u'wontfix'):
|
||||
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.save()
|
||||
elif (action == u'comment'):
|
||||
id = int(q.get('id'))
|
||||
op = Oprava.objects.filter(id=id).first()
|
||||
op = Oprava.objects.get(id=id)
|
||||
text = q.get('txt')
|
||||
kom = Komentar(oprava=op,autor=autor,text=text)
|
||||
kom.save()
|
||||
elif (action == u'update-comment'):
|
||||
id = int(q.get('id'))
|
||||
kom = Komentar.objects.filter(id=id).first()
|
||||
kom = Komentar.objects.get(id=id)
|
||||
text = q.get('txt')
|
||||
kom.text = text
|
||||
kom.autor = autor
|
||||
kom.save()
|
||||
elif (action == u'del-comment'):
|
||||
id = int(q.get('id'))
|
||||
kom = Komentar.objects.filter(id=id).first()
|
||||
kom = Komentar.objects.get(id=id)
|
||||
kom.delete()
|
||||
elif (action == u'delall'):
|
||||
pdf = KorekturovanePDF.objects.filter(id=q.get('pdf'))
|
||||
|
@ -116,24 +108,14 @@ class KorekturyView(generic.TemplateView):
|
|||
elif (q.get('state') == u'deprecated'):
|
||||
pdf.status = pdf.STATUS_ZASTARALE
|
||||
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['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):
|
||||
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['img_name'] = os.path.split(pdf.pdf.path)[1].split('.')[0]
|
||||
context['img_path'] = settings.KOREKTURY_IMG_DIR
|
||||
|
|
Loading…
Reference in a new issue