|
@ -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,7 @@ 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) |
|
|
|
|
|
if not autor: |
|
|
if not autor: |
|
|
autor = 'anonym' |
|
|
autor = 'anonym' |
|
|
if not scroll: |
|
|
if not scroll: |
|
@ -52,52 +43,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 +107,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 |
|
|