Šifrovačka: podmnožiny odpovědí na šifry
This commit is contained in:
parent
ee2b25f8f0
commit
c5b5813d75
4 changed files with 23 additions and 3 deletions
|
@ -1,8 +1,9 @@
|
|||
from django.contrib import admin
|
||||
|
||||
from .models import OdpovedUcastnika, SpravnaOdpoved, NapovezenoUcastnikovi, Napoveda
|
||||
from .models import OdpovedUcastnika, SpravnaOdpoved, NapovezenoUcastnikovi, Napoveda, SeznamSifer
|
||||
|
||||
admin.site.register(OdpovedUcastnika)
|
||||
admin.site.register(SpravnaOdpoved)
|
||||
admin.site.register(Napoveda)
|
||||
admin.site.register(NapovezenoUcastnikovi)
|
||||
admin.site.register(SeznamSifer)
|
||||
|
|
|
@ -39,3 +39,10 @@ class Napoveda(models.Model):
|
|||
|
||||
def __str__(self):
|
||||
return f"{self.sifra}: {self.text}"
|
||||
|
||||
class SeznamSifer(models.Model):
|
||||
jmeno = models.CharField("Jméno seznamu", max_length=255, blank=False, null=False, help_text="něco co jde zadat do adresy")
|
||||
sifry = models.ManyToManyField(SpravnaOdpoved)
|
||||
|
||||
def __str__(self):
|
||||
return f"{self.jmeno}"
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
from django.urls import path
|
||||
|
||||
from personalni.utils import org_required, resitel_or_org_required
|
||||
from .views import SifrovackaView, SifrovackaListView, NapovedaView, NapovedaListView, PreskoceniView
|
||||
from .views import SifrovackaView, SifrovackaListView, SifrovackaNektereListView, NapovedaView, NapovedaListView, PreskoceniView
|
||||
|
||||
urlpatterns = [
|
||||
path(
|
||||
|
@ -14,6 +14,11 @@ urlpatterns = [
|
|||
org_required(SifrovackaListView.as_view()),
|
||||
name='sifrovacka_odpovedi'
|
||||
),
|
||||
path(
|
||||
'odpovedi/<str:seznam>/',
|
||||
org_required(SifrovackaNektereListView.as_view()),
|
||||
name='sifrovacka_odpovedi_nektere'
|
||||
),
|
||||
path(
|
||||
'napoveda/',
|
||||
resitel_or_org_required(NapovedaView.as_view()),
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
from django.shortcuts import get_object_or_404
|
||||
from django.urls import reverse
|
||||
from django.views.generic import FormView, ListView
|
||||
|
||||
from various.views.pomocne import formularOKView
|
||||
from .forms import SifrovackaForm, NapovedaForm
|
||||
from .models import OdpovedUcastnika, SpravnaOdpoved, Napoveda, NapovezenoUcastnikovi
|
||||
from .models import OdpovedUcastnika, SpravnaOdpoved, Napoveda, NapovezenoUcastnikovi, SeznamSifer
|
||||
from personalni.models import Resitel
|
||||
|
||||
|
||||
|
@ -30,6 +31,12 @@ class SifrovackaListView(ListView):
|
|||
template_name = 'sifrovacka/odpovedi_list.html'
|
||||
model = OdpovedUcastnika
|
||||
|
||||
class SifrovackaNektereListView(SifrovackaListView):
|
||||
def get_queryset(self):
|
||||
seznam = get_object_or_404(SeznamSifer, jmeno=self.kwargs['seznam'])
|
||||
orig = super().get_queryset()
|
||||
return orig.filter(sifra__in=seznam.sifry.all())
|
||||
|
||||
|
||||
class NapovedaView(FormView):
|
||||
template_name = 'sifrovacka/napoveda.html'
|
||||
|
|
Loading…
Reference in a new issue