|
|
@ -9,6 +9,7 @@ from django.utils.translation import ugettext as _ |
|
|
|
from django.http import Http404,HttpResponseBadRequest,HttpResponseRedirect |
|
|
|
from django.db.models import Q, Sum, Count |
|
|
|
from django.views.decorators.csrf import ensure_csrf_cookie |
|
|
|
from django.views.generic.edit import FormView |
|
|
|
from django.contrib.auth import authenticate, login, get_user_model, logout |
|
|
|
from django.contrib.auth import views as auth_views |
|
|
|
from django.contrib.auth.models import User |
|
|
@ -22,6 +23,7 @@ from .models import Problem, Cislo, Reseni, Nastaveni, Rocnik, Soustredeni, Orga |
|
|
|
from . import utils |
|
|
|
from .unicodecsv import UnicodeWriter |
|
|
|
from .forms import PrihlaskaForm, LoginForm, EditForm |
|
|
|
import seminar.forms as f |
|
|
|
|
|
|
|
from datetime import timedelta, date, datetime |
|
|
|
from django.utils import timezone |
|
|
@ -1150,6 +1152,11 @@ class ResitelView(LoginRequiredMixin,generic.DetailView): |
|
|
|
return Resitel.objects.get(osoba__user=self.request.user) |
|
|
|
|
|
|
|
## Formulare |
|
|
|
class AddSolutionView(LoginRequiredMixin, FormView): |
|
|
|
template_name = 'seminar/org/vloz_reseni.html' |
|
|
|
form_class = f.VlozReseniForm |
|
|
|
success_url = '/' |
|
|
|
|
|
|
|
def resetPasswordView(request): |
|
|
|
pass |
|
|
|
|
|
|
@ -1324,6 +1331,25 @@ class SkolaAutocomplete(autocomplete.Select2QuerySetView): |
|
|
|
|
|
|
|
return qs |
|
|
|
|
|
|
|
class LoginRequiredAjaxMixin(object): |
|
|
|
def dispatch(self, request, *args, **kwargs): |
|
|
|
#if request.is_ajax() and not request.user.is_authenticated: # Pokud to otevřu jako stránku, tak se omezení neuplatní, takže to asi nechceme |
|
|
|
if not request.user.is_authenticated: |
|
|
|
return JsonResponse(data={'results': [], 'pagination': {}}, status=401) |
|
|
|
return super(LoginRequiredAjaxMixin, self).dispatch(request, *args, **kwargs) |
|
|
|
|
|
|
|
class ResitelAutocomplete(LoginRequiredAjaxMixin,autocomplete.Select2QuerySetView): |
|
|
|
def get_queryset(self): |
|
|
|
qs = Resitel.objects.all() |
|
|
|
if self.q: |
|
|
|
qs = qs.filter( |
|
|
|
Q(osoba__jmeno__startswith=self.q)| |
|
|
|
Q(osoba__prijmeni__startswith=self.q)| |
|
|
|
Q(osoba__prezdivka__startswith=self.q) |
|
|
|
) |
|
|
|
return qs |
|
|
|
|
|
|
|
|
|
|
|
# Ceka na autocomplete v3 |
|
|
|
# class OrganizatorAutocomplete(autocomplete.Select2QuerySetView): |
|
|
|
# def get_queryset(self): |
|
|
|