Rozstřílení seminářové aplikace #60
|
@ -51,6 +51,9 @@ urlpatterns = [
|
|||
# Aesop (ma vlastni podadresare)
|
||||
path('', include('aesop.urls')),
|
||||
|
||||
# Various = co se nevešlo jinam
|
||||
path('', include('various.urls')),
|
||||
|
||||
# REST API
|
||||
# path('api/', include(router.urls)),
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ import seminar.models as m
|
|||
from . import forms as f
|
||||
from .forms import OdevzdavatkoTabulkaFiltrForm as FiltrForm
|
||||
from seminar.utils import resi_v_rocniku
|
||||
from seminar.views import formularOKView
|
||||
from various.views.pomocne import formularOKView
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ from datetime import date
|
|||
import logging
|
||||
import csv
|
||||
|
||||
from seminar.views import formularOKView
|
||||
from various.views.pomocne import formularOKView
|
||||
from various.autentizace.views import LoginView
|
||||
from various.autentizace.utils import posli_reset_hesla
|
||||
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% load humanize %}
|
||||
{% load static %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class=jakresit>
|
||||
|
||||
{% include 'seminar/jakresit/jakresit_1.svg' %}
|
||||
{% include 'seminar/jakresit/jakresit_2.svg' %}
|
||||
{% include 'seminar/jakresit/jakresit_3.svg' %}
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
|
@ -65,19 +65,11 @@ urlpatterns = [
|
|||
org_required(views.TitulyView),
|
||||
name='seminar_cislo_titul'
|
||||
),
|
||||
path(
|
||||
'stav',
|
||||
org_required(views.StavDatabazeView),
|
||||
name='stav_databaze'
|
||||
),
|
||||
path(
|
||||
'cislo/<int:trocnik>.<str:tcislo>/odmeny/<int:frocnik>.<str:fcislo>/',
|
||||
org_required(views.OdmenyView.as_view()),
|
||||
name="seminar_archiv_odmeny"),
|
||||
|
||||
path('', views.TitulniStranaView.as_view(), name='titulni_strana'),
|
||||
path('jak-resit/', views.JakResitView.as_view(), name='jak_resit'),
|
||||
|
||||
# Dočasné & neodladěné:
|
||||
path(
|
||||
'hidden/hromadne_pridani',
|
||||
|
|
|
@ -18,7 +18,6 @@ from seminar.models import Problem, Cislo, Reseni, Nastaveni, Rocnik, \
|
|||
#from .models import VysledkyZaCislo, VysledkyKCisluZaRocnik, VysledkyKCisluOdjakziva
|
||||
from seminar import utils
|
||||
from treenode import treelib
|
||||
from novinky.views import spravne_novinky
|
||||
import treenode.templatetags as tnltt
|
||||
import treenode.serializers as vr
|
||||
from vysledkovky.utils import body_resitelu, VysledkovkaCisla, \
|
||||
|
@ -37,7 +36,6 @@ from django.conf import settings
|
|||
import unicodedata
|
||||
import logging
|
||||
import time
|
||||
from collections.abc import Sequence
|
||||
import http
|
||||
|
||||
from seminar.utils import aktivniResitele
|
||||
|
@ -226,33 +224,6 @@ def aktualni_temata(rocnik):
|
|||
return Tema.objects.filter(rocnik=rocnik, stav='zadany').order_by('kod')
|
||||
|
||||
|
||||
class TitulniStranaView(generic.ListView):
|
||||
template_name= 'seminar/titulnistrana/titulnistrana.html'
|
||||
|
||||
def get_queryset(self):
|
||||
return spravne_novinky(self.request)[:3]
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(TitulniStranaView, self).get_context_data(**kwargs)
|
||||
nastaveni = get_object_or_404(Nastaveni)
|
||||
|
||||
deadline = m.Deadline.objects.filter(deadline__gte=timezone.now()).order_by("deadline").first()
|
||||
context['nejblizsi_deadline'] = deadline
|
||||
|
||||
# Aktuální témata
|
||||
nazvy_a_odkazy_na_aktualni_temata = []
|
||||
akt_temata = aktualni_temata(nastaveni.aktualni_rocnik)
|
||||
|
||||
for tema in akt_temata:
|
||||
# FIXME: netuším, jestli funguje tema.verejne_url(), nemáme testdata na témátka - je to asi url vzhledem k ročníku
|
||||
nazvy_a_odkazy_na_aktualni_temata.append({'nazev':tema.nazev,'url':tema.verejne_url()})
|
||||
|
||||
context['aktualni_temata'] = nazvy_a_odkazy_na_aktualni_temata
|
||||
|
||||
print(context)
|
||||
|
||||
return context
|
||||
|
||||
### Co je M&M
|
||||
|
||||
|
||||
|
@ -652,47 +623,7 @@ class ClankyResitelView(generic.ListView):
|
|||
# queryset = Problem.objects.filter(stav=Problem.STAV_ZADANY).select_related('cislo_zadani__rocnik').order_by('-cislo_zadani__rocnik__rocnik', 'kod')
|
||||
|
||||
|
||||
### Status
|
||||
|
||||
def StavDatabazeView(request):
|
||||
# nastaveni = Nastaveni.objects.get()
|
||||
problemy = utils.seznam_problemu()
|
||||
muzi = Resitel.objects.filter(osoba__osloveni=m.Osoba.OSLOVENI_MUZSKE)
|
||||
zeny = Resitel.objects.filter(osoba__osloveni=m.Osoba.OSLOVENI_ZENSKE)
|
||||
return render(request, 'seminar/stav_databaze.html',
|
||||
{
|
||||
# 'nastaveni': nastaveni,
|
||||
'problemy': problemy,
|
||||
|
||||
'resitele': Resitel.objects.all(),
|
||||
'muzi': muzi,
|
||||
'zeny': zeny,
|
||||
'jmena_muzu': utils.histogram([r.osoba.jmeno for r in muzi]),
|
||||
'jmena_zen': utils.histogram([r.osoba.jmeno for r in zeny]),
|
||||
})
|
||||
|
||||
|
||||
# Interní, nemá se nikdy objevit v urls (jinak to účastníci vytrolí)
|
||||
def formularOKView(request, text='', dalsi_odkazy: Sequence[tuple[str, str]] = ()):
|
||||
template_name = 'seminar/formular_ok.html'
|
||||
odkazy = list(dalsi_odkazy) + [
|
||||
# (Text, odkaz)
|
||||
('Vrátit se na titulní stránku', reverse('titulni_strana')),
|
||||
('Zobrazit aktuální zadání', reverse('seminar_aktualni_zadani')),
|
||||
]
|
||||
context = {
|
||||
'odkazy': odkazy,
|
||||
'text': text,
|
||||
}
|
||||
return render(request, template_name, context)
|
||||
|
||||
#------------------ Jak řešit - možná má být udělané úplně jinak
|
||||
|
||||
class JakResitView(generic.ListView):
|
||||
template_name = 'seminar/jakresit/jak-resit.html'
|
||||
|
||||
def get_queryset(self):
|
||||
return None
|
||||
|
||||
class AktualniRocnikRedirectView(RedirectView):
|
||||
permanent=False
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from django.urls import reverse
|
||||
from django.views.generic import FormView, ListView
|
||||
|
||||
from seminar.views import formularOKView
|
||||
from various.views.pomocne import formularOKView
|
||||
from .forms import SifrovackaForm, NapovedaForm
|
||||
from .models import OdpovedUcastnika, SpravnaOdpoved, Napoveda, NapovezenoUcastnikovi
|
||||
from personalni.models import Resitel
|
||||
|
|
16
various/templates/various/jakresit/jak-resit.html
Normal file
|
@ -0,0 +1,16 @@
|
|||
{% extends 'base.html' %}
|
||||
|
||||
{% load humanize %}
|
||||
{% load static %}
|
||||
|
||||
|
||||
{% block content %}
|
||||
|
||||
<div class=jakresit>
|
||||
|
||||
{% include 'various/jakresit/jakresit_1.svg' %}
|
||||
{% include 'various/jakresit/jakresit_2.svg' %}
|
||||
{% include 'various/jakresit/jakresit_3.svg' %}
|
||||
|
||||
</div>
|
||||
{% endblock %}
|
Before Width: | Height: | Size: 664 KiB After Width: | Height: | Size: 664 KiB |
Before Width: | Height: | Size: 689 KiB After Width: | Height: | Size: 689 KiB |
Before Width: | Height: | Size: 767 KiB After Width: | Height: | Size: 767 KiB |
|
@ -10,7 +10,7 @@
|
|||
<p>
|
||||
Na této stránce velmi intenzivně pracujeme.
|
||||
Za dočasnou nedostupnost se omlouváme.
|
||||
Zkuste přejít na <a href="/">titulní stránku</a>
|
||||
Zkuste přejít na <a href="/static">titulní stránku</a>
|
||||
zelvuska marked this conversation as resolved
Outdated
|
||||
nebo se podívat na <a href="{% url 'seminar_aktualni_zadani' %}">aktuální zadání</a>.
|
||||
</p>
|
||||
<img src="{% static '404.png' %}">
|
Before Width: | Height: | Size: 35 KiB After Width: | Height: | Size: 35 KiB |
|
@ -79,7 +79,7 @@ function sousdeadline() {
|
|||
<div class="graf">
|
||||
|
||||
<div class="graf-svg">
|
||||
{% include 'seminar/titulnistrana/graph.svg' %} <!-- TODO: aby to nemuselo být v templates -->
|
||||
{% include 'various/titulnistrana/graph.svg' %} <!-- TODO: aby to nemuselo být v templates -->
|
||||
</div>
|
||||
|
||||
<span class="zjistit_vic">
|
9
various/urls.py
Normal file
|
@ -0,0 +1,9 @@
|
|||
from django.urls import path
|
||||
from .views.final import TitulniStranaView, JakResitView, StavDatabazeView
|
||||
from seminar.utils import org_required
|
||||
|
||||
urlpatterns = [
|
||||
path('', TitulniStranaView.as_view(), name='titulni_strana'),
|
||||
path('jak-resit/', JakResitView.as_view(), name='jak_resit'),
|
||||
path('stav', org_required(StavDatabazeView), name='stav_databaze'),
|
||||
]
|
73
various/views/final.py
Normal file
|
@ -0,0 +1,73 @@
|
|||
"""
|
||||
Stránky, které se mi nepovedlo lépe zařadit.
|
||||
|
||||
Oproti `./pomocne.py` se tyto views používají přímo ve various
|
||||
a naopak importují spoustu věcí odjinud
|
||||
"""
|
||||
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
from django.utils import timezone
|
||||
from django.views import generic
|
||||
|
||||
import novinky.views
|
||||
import seminar.utils
|
||||
import seminar.views
|
||||
from personalni.models import Resitel
|
||||
from seminar import models as m
|
||||
|
||||
from ..models import Nastaveni
|
||||
|
||||
|
||||
class TitulniStranaView(generic.ListView):
|
||||
template_name = 'various/titulnistrana/titulnistrana.html'
|
||||
|
||||
def get_queryset(self):
|
||||
return novinky.views.spravne_novinky(self.request)[:3]
|
||||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super(TitulniStranaView, self).get_context_data(**kwargs)
|
||||
nastaveni = get_object_or_404(Nastaveni)
|
||||
|
||||
deadline = m.Deadline.objects.filter(
|
||||
deadline__gte=timezone.now()).order_by("deadline").first()
|
||||
context['nejblizsi_deadline'] = deadline
|
||||
|
||||
# Aktuální témata
|
||||
nazvy_a_odkazy_na_aktualni_temata = []
|
||||
akt_temata = seminar.views.aktualni_temata(nastaveni.aktualni_rocnik)
|
||||
|
||||
for tema in akt_temata:
|
||||
# FIXME: netuším, jestli funguje tema.verejne_url(), nemáme testdata na témátka - je to asi url vzhledem k ročníku
|
||||
nazvy_a_odkazy_na_aktualni_temata.append({
|
||||
'nazev': tema.nazev,
|
||||
'url': tema.verejne_url()
|
||||
})
|
||||
|
||||
context['aktualni_temata'] = nazvy_a_odkazy_na_aktualni_temata
|
||||
|
||||
return context
|
||||
|
||||
|
||||
class JakResitView(generic.ListView):
|
||||
template_name = 'various/jakresit/jak-resit.html'
|
||||
|
||||
def get_queryset(self):
|
||||
return None
|
||||
|
||||
|
||||
### Status
|
||||
def StavDatabazeView(request):
|
||||
# nastaveni = Nastaveni.objects.get()
|
||||
problemy = seminar.utils.seznam_problemu()
|
||||
muzi = Resitel.objects.filter(osoba__osloveni=m.Osoba.OSLOVENI_MUZSKE)
|
||||
zeny = Resitel.objects.filter(osoba__osloveni=m.Osoba.OSLOVENI_ZENSKE)
|
||||
return render(request, 'various/stav_databaze.html', {
|
||||
# 'nastaveni': nastaveni,
|
||||
'problemy': problemy,
|
||||
|
||||
'resitele': Resitel.objects.all(),
|
||||
'muzi': muzi,
|
||||
'zeny': zeny,
|
||||
'jmena_muzu': seminar.utils.histogram([r.osoba.jmeno for r in muzi]),
|
||||
'jmena_zen': seminar.utils.histogram([r.osoba.jmeno for r in zeny]),
|
||||
})
|
26
various/views/pomocne.py
Normal file
|
@ -0,0 +1,26 @@
|
|||
"""
|
||||
Stránky, které se mi nepovedlo lépe zařadit.
|
||||
|
||||
Oproti `./final.py` se tyto views importují odjinud
|
||||
tedy ideálně neimportovat sem nic od jinud
|
||||
"""
|
||||
|
||||
from typing import Sequence
|
||||
|
||||
from django.shortcuts import render
|
||||
from django.urls import reverse
|
||||
|
||||
|
||||
# Interní, nemá se nikdy objevit v urls (jinak to účastníci vytrolí)
|
||||
def formularOKView(request, text='', dalsi_odkazy: Sequence[tuple[str, str]] = ()):
|
||||
template_name = 'seminar/formular_ok.html'
|
||||
odkazy = list(dalsi_odkazy) + [
|
||||
# (Text, odkaz)
|
||||
('Vrátit se na titulní stránku', reverse('titulni_strana')),
|
||||
('Zobrazit aktuální zadání', reverse('seminar_aktualni_zadani')),
|
||||
]
|
||||
context = {
|
||||
'odkazy': odkazy,
|
||||
'text': text,
|
||||
}
|
||||
return render(request, template_name, context)
|
|
@ -1,7 +1,7 @@
|
|||
from django.views.generic import FormView, ListView
|
||||
|
||||
from seminar.models import Osoba
|
||||
from seminar.views import formularOKView
|
||||
from various.views.pomocne import formularOKView
|
||||
from .forms import UcastnikVyrociForm
|
||||
from .models import UcastnikVyroci
|
||||
|
||||
|
|
ehh? FIXME?