Browse Source

Merge remote-tracking branch 'origin/opraf'

Conflicts:
	korektury/models.py
	seminar/urls.py
remotes/origin/opraf^2
Bc. Petr Pecha 9 years ago
parent
commit
448426a6fb
  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. 45
      korektury/views.py
  10. 20
      seminar/urls.py
  11. 4
      seminar/utils.py

3
korektury/TODO

@ -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

@ -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 -*-
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
from reversion import revisions as 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

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.comitting {
body,
.adding{
background: #f3f3f3;
color: black;
}
.comitting
{
background: yellow;
}
body.deprecated {
.deprecated {
background: red;
}

14
korektury/static/korektury/opraf.js

@ -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)

17
korektury/templates/korektury/opraf.html

@ -15,7 +15,9 @@
<br>
<i>Klikni na chybu, napiš komentář</i> |
<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="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 %}

2
korektury/templates/korektury/seznam.html

@ -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 %}

45
korektury/views.py

@ -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,7 @@ class KorekturyView(generic.TemplateView):
q = request.POST
scroll = q.get('scroll')
autor = q.get('au')
print "autor:" + str(autor)
if not autor:
autor = 'anonym'
if not scroll:
@ -52,52 +43,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 +107,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

20
seminar/urls.py

@ -2,6 +2,7 @@ from django.conf.urls import * # NOQA
from django.conf.urls import patterns, url
from django.contrib.auth.decorators import user_passes_test
from . import views, export
from utils import staff_member_required
staff_member_required = user_passes_test(lambda u: u.is_staff)
@ -20,7 +21,6 @@ urlpatterns = [
name = 'seminar_seznam_soustredeni'),
url(r'^soustredeni/probehlo/(?P<soustredeni>\d+)/$', views.SoustredeniView.as_view(), name='seminar_soustredeni'),
url(r'^soustredeni/(?P<soustredeni>\d+)/fotogalerie/', include('galerie.urls')),
url(r'^soustredeni/(?P<soustredeni>\d+)/obalky.pdf', views.soustredeniObalkyView,name='seminar_soustredeni_obalky'),
url(r'^zadani/aktualni/$', views.AktualniZadaniView, name='seminar_aktualni_zadani'),
url(r'^zadani/temata/$', views.ZadaniTemataView, name='seminar_temata'),
@ -31,16 +31,22 @@ urlpatterns = [
url(r'^clanky/resitel/$', views.ClankyResitelView.as_view(), name='clanky_resitel'),
url(r'^clanky/org/$', views.ClankyOrganizatorView.as_view(), name='clanky_organizator'),
url(r'^stav$', views.StavDatabazeView, name='stav_databaze'),
url(r'^aesop-export/mam-rocnik-(?P<prvni_rok>\d+)\.csv$', export.ExportRocnikView.as_view(), name='seminar_export_rocnik'),
url(r'^aesop-export/mam-sous-(?P<datum_zacatku>[\d-]+)\.csv$', export.ExportSousView.as_view(), name='seminar_export_sous'),
url(r'^aesop-export/index.csv$', export.ExportIndexView.as_view(), name='seminar_export_index'),
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>\d+)/vysledkovka.tex$', views.CisloVysledkovkaView.as_view(), name='seminar_cislo_vysledkovka'),
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>\d+)/obalky.pdf$',views.cisloObalkyView, name='seminar_cislo_obalky'),
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>\d+)/tituly.tex', views.TitulyView,name='seminar_cislo_titul'),
#### Stranky viditelne pouze pro orgy:
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>\d+)/vysledkovka.tex$',
staff_member_required(views.CisloVysledkovkaView.as_view()), name='seminar_cislo_vysledkovka'),
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>\d+)/obalky.pdf$',
staff_member_required(views.cisloObalkyView), name='seminar_cislo_obalky'),
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>\d+)/tituly.tex$',
staff_member_required(views.TitulyView), name='seminar_cislo_titul'),
url(r'^stav$',
staff_member_required(views.StavDatabazeView), name='stav_databaze'),
url(r'^cislo/(?P<rocnik>\d+).(?P<cislo>\d+)/resitel_uloha.html$',
staff_member_required(views.resitelUlohaView),name='seminar_cislo_resitel_uloha'),
url(r'^soustredeni/(?P<soustredeni>\d+)/obalky.pdf',
staff_member_required(views.soustredeniObalkyView),name='seminar_soustredeni_obalky'),
]

4
seminar/utils.py

@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
import datetime
from django.contrib.auth.decorators import user_passes_test
staff_member_required = user_passes_test(lambda u: u.is_staff)
def histogram(seznam):
d = {}
@ -76,3 +78,5 @@ def seznam_problemu():
return problemy

Loading…
Cancel
Save