Compare commits
No commits in common. "ba2ea74a049f0167770a5d385261bb6e257c287c" and "5f7ec853fa6a8998822adbddd851c4c588c97ced" have entirely different histories.
ba2ea74a04
...
5f7ec853fa
7 changed files with 64 additions and 77 deletions
|
@ -21,16 +21,4 @@ urlpatterns = [
|
|||
# Obecný view na profil -- orgům dá rozcestník, řešitelům jejich stránku
|
||||
path('profil/', views.profilView, name='profil'),
|
||||
|
||||
# Seznam organizátorů
|
||||
path(
|
||||
'o-nas/organizatori/',
|
||||
views.CojemamOrganizatoriView.as_view(),
|
||||
name='organizatori'
|
||||
),
|
||||
path(
|
||||
'o-nas/organizatori/organizovali/',
|
||||
views.CojemamOrganizatoriStariView.as_view(),
|
||||
name='stari_organizatori'
|
||||
),
|
||||
|
||||
]
|
||||
|
|
|
@ -1,8 +1,3 @@
|
|||
import tempfile
|
||||
import subprocess
|
||||
import shutil
|
||||
import http
|
||||
|
||||
from django.shortcuts import render
|
||||
from django.urls import reverse
|
||||
from django.views import generic
|
||||
|
@ -11,10 +6,8 @@ from django.views.decorators.debug import sensitive_post_parameters
|
|||
from django.views.generic.base import TemplateView
|
||||
from django.contrib.auth.models import User, Permission, Group, AnonymousUser
|
||||
from django.contrib.auth.mixins import LoginRequiredMixin
|
||||
from django.contrib.staticfiles.finders import find
|
||||
from django.db import transaction
|
||||
from django.http import HttpResponse
|
||||
from django.utils import timezone
|
||||
|
||||
import seminar.models as s
|
||||
import seminar.models as m
|
||||
|
@ -30,59 +23,6 @@ from various.autentizace.utils import posli_reset_hesla
|
|||
|
||||
from django.forms.models import model_to_dict
|
||||
|
||||
from .models import Organizator
|
||||
|
||||
|
||||
def aktivniOrganizatori(datum=timezone.now()):
|
||||
return Organizator.objects.exclude(
|
||||
organizuje_do__isnull=False,
|
||||
organizuje_do__lt=datum
|
||||
).order_by('osoba__jmeno')
|
||||
|
||||
|
||||
class CojemamOrganizatoriView(generic.ListView):
|
||||
model = Organizator
|
||||
template_name = 'personalni/organizatori.html'
|
||||
queryset = aktivniOrganizatori()
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(CojemamOrganizatoriView, self).get_context_data(**kwargs)
|
||||
context['aktivni'] = True
|
||||
return context
|
||||
|
||||
|
||||
class CojemamOrganizatoriStariView(generic.ListView):
|
||||
model = Organizator
|
||||
template_name = 'personalni/organizatori.html'
|
||||
queryset = Organizator.objects.exclude(
|
||||
id__in=aktivniOrganizatori()
|
||||
).order_by('-organizuje_do')
|
||||
|
||||
|
||||
def obalkyView(request, resitele):
|
||||
if len(resitele) == 0:
|
||||
return HttpResponse(
|
||||
render(request, 'universal.html', {
|
||||
'title': 'Není pro koho vyrobit obálky.',
|
||||
'text': 'Právě ses pokusil/a vygenerovat obálky pro prázdnou množinu lidí. Můžeš to zkusit změnit, případně se zeptej webařů :-)',
|
||||
}),
|
||||
status=http.HTTPStatus.NOT_FOUND,
|
||||
)
|
||||
|
||||
tex = render(request, 'personalni/obalky.tex', {
|
||||
'resitele': resitele
|
||||
}).content
|
||||
|
||||
with tempfile.TemporaryDirectory() as tempdir:
|
||||
with open(tempdir+"/obalky.tex", "w") as texfile:
|
||||
texfile.write(tex.decode())
|
||||
shutil.copy(find('seminar/lisak.pdf'), tempdir)
|
||||
subprocess.call(["pdflatex", "obalky.tex"], cwd=tempdir)
|
||||
|
||||
with open(tempdir+"/obalky.pdf", "rb") as pdffile:
|
||||
response = HttpResponse(pdffile.read(), content_type='application/pdf')
|
||||
return response
|
||||
|
||||
|
||||
class OrgoRozcestnikView(TemplateView):
|
||||
""" Zobrazí organizátorský rozcestník."""
|
||||
|
|
|
@ -6,6 +6,10 @@ urlpatterns = [
|
|||
# path('aktualni/temata/', views.TemataRozcestnikView),
|
||||
# path('<int:rocnik>/t<int:tematko>/', views.TematkoView),
|
||||
|
||||
# Organizatori
|
||||
path('o-nas/organizatori/', views.CojemamOrganizatoriView.as_view(), name='organizatori'),
|
||||
path('o-nas/organizatori/organizovali/', views.CojemamOrganizatoriStariView.as_view(), name='stari_organizatori'),
|
||||
|
||||
# Archiv
|
||||
path('archiv/rocniky/', views.ArchivView.as_view(), name="seminar_archiv_rocniky"),
|
||||
path('archiv/temata/', views.ArchivTemataView.as_view(), name="seminar_archiv_temata"),
|
||||
|
|
|
@ -8,11 +8,12 @@ from django.http import Http404
|
|||
from django.db.models import Q, Sum, Count
|
||||
from django.views.generic.base import RedirectView
|
||||
from django.core.exceptions import PermissionDenied
|
||||
from django.contrib.staticfiles.finders import find
|
||||
|
||||
import seminar.models as s
|
||||
import seminar.models as m
|
||||
from seminar.models import Problem, Cislo, Reseni, Nastaveni, Rocnik, \
|
||||
Resitel, Novinky, Tema, Clanek, \
|
||||
Organizator, Resitel, Novinky, Tema, Clanek, \
|
||||
Deadline # Tohle je stare a chceme se toho zbavit. Pouzivejte s.ToCoChci
|
||||
#from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva
|
||||
from seminar import utils
|
||||
|
@ -23,17 +24,21 @@ from vysledkovky.utils import body_resitelu, VysledkovkaCisla, \
|
|||
VysledkovkaRocniku, VysledkovkaDoTeXu
|
||||
|
||||
from datetime import date, datetime
|
||||
from django.utils import timezone
|
||||
from itertools import groupby
|
||||
from collections import OrderedDict
|
||||
import tempfile
|
||||
import subprocess
|
||||
import shutil
|
||||
import os
|
||||
import os.path as op
|
||||
from django.conf import settings
|
||||
import unicodedata
|
||||
import logging
|
||||
import time
|
||||
import http
|
||||
|
||||
from seminar.utils import aktivniResitele
|
||||
import personalni.views
|
||||
|
||||
# ze starého modelu
|
||||
#def verejna_temata(rocnik):
|
||||
|
@ -219,6 +224,34 @@ def aktualni_temata(rocnik):
|
|||
return Tema.objects.filter(rocnik=rocnik, stav='zadany').order_by('kod')
|
||||
|
||||
|
||||
### Co je M&M
|
||||
|
||||
|
||||
# Organizatori
|
||||
def aktivniOrganizatori(datum=timezone.now()):
|
||||
return Organizator.objects.exclude(
|
||||
organizuje_do__isnull=False,
|
||||
organizuje_do__lt=datum
|
||||
).order_by('osoba__jmeno')
|
||||
|
||||
|
||||
class CojemamOrganizatoriView(generic.ListView):
|
||||
model = Organizator
|
||||
template_name = 'seminar/cojemam/organizatori.html'
|
||||
queryset = aktivniOrganizatori()
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(CojemamOrganizatoriView, self).get_context_data(**kwargs)
|
||||
context['aktivni'] = True
|
||||
return context
|
||||
|
||||
|
||||
class CojemamOrganizatoriStariView(generic.ListView):
|
||||
model = Organizator
|
||||
template_name = 'seminar/cojemam/organizatori.html'
|
||||
queryset = Organizator.objects.exclude(
|
||||
id__in=aktivniOrganizatori()).order_by('-organizuje_do')
|
||||
|
||||
### Archiv
|
||||
|
||||
|
||||
|
@ -481,9 +514,31 @@ class RocnikVysledkovkaView(RocnikView):
|
|||
|
||||
def cisloObalkyView(request, rocnik, cislo):
|
||||
realne_cislo = get_object_or_404(Cislo, poradi=cislo, rocnik__rocnik=rocnik)
|
||||
return personalni.views.obalkyView(request, aktivniResitele(realne_cislo))
|
||||
return obalkyView(request, aktivniResitele(realne_cislo))
|
||||
|
||||
|
||||
def obalkyView(request, resitele):
|
||||
if len(resitele) == 0:
|
||||
return HttpResponse(
|
||||
render(request, 'universal.html', {
|
||||
'title': 'Není pro koho vyrobit obálky.',
|
||||
'text': 'Právě ses pokusil/a vygenerovat obálky pro prázdnou množinu lidí. Můžeš to zkusit změnit, případně se zeptej webařů :-)',
|
||||
}),
|
||||
status=http.HTTPStatus.NOT_FOUND,
|
||||
)
|
||||
|
||||
tex = render(request,'seminar/archiv/obalky.tex', {'resitele': resitele}).content
|
||||
|
||||
with tempfile.TemporaryDirectory() as tempdir:
|
||||
with open(tempdir+"/obalky.tex","w") as texfile:
|
||||
texfile.write(tex.decode())
|
||||
shutil.copy(find('seminar/lisak.pdf'), tempdir)
|
||||
subprocess.call(["pdflatex","obalky.tex"], cwd = tempdir)
|
||||
|
||||
with open(tempdir+"/obalky.pdf","rb") as pdffile:
|
||||
response = HttpResponse(pdffile.read(), content_type='application/pdf')
|
||||
return response
|
||||
|
||||
|
||||
### Tituly
|
||||
def TitulyViewRocnik(request, rocnik):
|
||||
|
|
|
@ -11,7 +11,7 @@ import subprocess
|
|||
from pathlib import Path
|
||||
import http
|
||||
|
||||
import personalni.views
|
||||
from seminar.views import obalkyView
|
||||
|
||||
|
||||
class SoustredeniListView(generic.ListView):
|
||||
|
@ -34,7 +34,7 @@ class SoustredeniListView(generic.ListView):
|
|||
|
||||
def soustredeniObalkyView(request, soustredeni):
|
||||
soustredeni = get_object_or_404(Soustredeni, id=soustredeni)
|
||||
return personalni.views.obalkyView(request, soustredeni.ucastnici.all())
|
||||
return obalkyView(request, soustredeni.ucastnici.all())
|
||||
|
||||
|
||||
class SoustredeniUcastniciBaseView(generic.ListView):
|
||||
|
|
Loading…
Reference in a new issue