Merge pull request 'Sifrovacka Seznamy' (!94) from sifrovacka_seznamy into master
Reviewed-on: #94
This commit is contained in:
commit
9af624e87e
5 changed files with 44 additions and 3 deletions
sifrovacka
|
@ -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)
|
||||
|
|
21
sifrovacka/migrations/0008_seznamsifer.py
Normal file
21
sifrovacka/migrations/0008_seznamsifer.py
Normal file
|
@ -0,0 +1,21 @@
|
|||
# Generated by Django 4.2.20 on 2025-03-19 21:39
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('sifrovacka', '0007_alter_napoveda_sifra_and_more'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='SeznamSifer',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('jmeno', models.CharField(help_text='něco co jde zadat do adresy', max_length=255, verbose_name='Jméno seznamu')),
|
||||
('sifry', models.ManyToManyField(to='sifrovacka.spravnaodpoved')),
|
||||
],
|
||||
),
|
||||
]
|
|
@ -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().values('sifra')) # poslední je kvůli tomu, že máme odkaz na celý objekt a ne jen na jméno šifry.
|
||||
|
||||
|
||||
class NapovedaView(FormView):
|
||||
template_name = 'sifrovacka/napoveda.html'
|
||||
|
|
Loading…
Reference in a new issue