korektury | prirazeni autora podle prihlaseni
kdyz prihlaseny neni organizator vrati 403
This commit is contained in:
parent
7aa5f72e7d
commit
ff9a207bfb
1 changed files with 9 additions and 4 deletions
|
@ -3,8 +3,9 @@ from django.shortcuts import get_object_or_404, render
|
|||
from django.views import generic
|
||||
from django.utils.translation import ugettext as _
|
||||
from django.conf import settings
|
||||
from django.http import HttpResponseForbidden
|
||||
|
||||
from .models import Oprava,Komentar,KorekturovanePDF
|
||||
from .models import Oprava,Komentar,KorekturovanePDF, Organizator
|
||||
from .forms import OpravaForm
|
||||
|
||||
import subprocess
|
||||
|
@ -29,14 +30,17 @@ class KorekturyView(generic.TemplateView):
|
|||
form = self.form_class(request.POST)
|
||||
q = request.POST
|
||||
scroll = q.get('scroll')
|
||||
autor = q.get('au')
|
||||
|
||||
# prirazeni autora podle prihlaseni
|
||||
autor_user = request.user
|
||||
# pokud existuje ucet (user), ale neni to organizator = 403
|
||||
autor = Organizator.objects.filter(user=autor_user).first()
|
||||
if not autor:
|
||||
autor = 'anonym'
|
||||
return HttpResponseForbidden()
|
||||
|
||||
if not scroll:
|
||||
scroll = 0
|
||||
|
||||
|
||||
action = q.get('action')
|
||||
if (action == u''): # Přidej
|
||||
x = int(q.get('x'))
|
||||
|
@ -141,6 +145,7 @@ class KorekturyView(generic.TemplateView):
|
|||
context['opravy'] = opravy
|
||||
context['zasluhy'] = zasluhy
|
||||
return context
|
||||
|
||||
def form_valid(self,form):
|
||||
return super(KorekturyView,self).form_valid(form)
|
||||
|
||||
|
|
Loading…
Reference in a new issue