From 72860fab5d982e69ca0f719ba6c80e0453da154f Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Mon, 15 Nov 2021 20:40:24 +0100 Subject: [PATCH 01/14] =?UTF-8?q?Zastaral=C3=A9=20TODO?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/views/odevzdavatko.py | 1 - 1 file changed, 1 deletion(-) diff --git a/seminar/views/odevzdavatko.py b/seminar/views/odevzdavatko.py index ce86958c..54eb46e2 100644 --- a/seminar/views/odevzdavatko.py +++ b/seminar/views/odevzdavatko.py @@ -75,7 +75,6 @@ class TabulkaOdevzdanychReseniView(ListView): # Chceme jen letošní problémy - # FIXME: Neexistuje metoda, jak dostat starší problémy… self.problemy = self.problemy.filter(Q(Tema___rocnik=self.aktualni_rocnik) | Q(Uloha___cislo_zadani__rocnik = self.aktualni_rocnik) | Q(Clanek___cislo__rocnik = self.aktualni_rocnik) | Q(Konfera___soustredeni__rocnik = self.aktualni_rocnik)) self.chteni_resitele = resitele # Zapamatování pro get_context_data From 3f3f6ebb0f25111e62e80ecb95f9f367e7d2563b Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Mon, 15 Nov 2021 20:45:10 +0100 Subject: [PATCH 02/14] =?UTF-8?q?Odevzd=C3=A1v=C3=A1tko:=20zobrazovat=20i?= =?UTF-8?q?=20vy=C5=99e=C5=A1en=C3=A9=20probl=C3=A9my?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/views/odevzdavatko.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/seminar/views/odevzdavatko.py b/seminar/views/odevzdavatko.py index 54eb46e2..ecbef01e 100644 --- a/seminar/views/odevzdavatko.py +++ b/seminar/views/odevzdavatko.py @@ -87,9 +87,14 @@ class TabulkaOdevzdanychReseniView(ListView): if problemy == FiltrForm.PROBLEMY_MOJE: org = m.Organizator.objects.get(osoba__user=self.request.user) - self.problemy = self.problemy.filter(Q(autor=org)|Q(garant=org)|Q(opravovatele=org), stav=m.Problem.STAV_ZADANY) + self.problemy = self.problemy.filter( + Q(autor=org)|Q(garant=org)|Q(opravovatele=org), + Q(stav=m.Problem.STAV_ZADANY)|Q(stav=m.Problem.STAV_VYRESENY), + ) elif problemy == FiltrForm.PROBLEMY_LETOSNI: - self.problemy = self.problemy.filter(stav=m.Problem.STAV_ZADANY) + self.problemy = self.problemy.filter( + Q(stav=m.Problem.STAV_ZADANY)|Q(stav=m.Problem.STAV_VYRESENY), + ) #self.problemy = list(filter(lambda problem: problem.rocnik() == self.aktualni_rocnik, self.problemy)) # DB HOG? # FIXME: některé problémy nemají ročník.... # NOTE: Protože řešení odkazuje přímo na Problém a QuerySet na Hodnocení je nepolymorfní, musíme porovnávat taky s nepolymorfními Problémy. self.problemy = self.problemy.non_polymorphic() From 93966ca2a901f4cd46ed1b02ab525cb59e65661b Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Mon, 15 Nov 2021 21:04:27 +0100 Subject: [PATCH 03/14] =?UTF-8?q?Autocomplete:=20Podpora=20v=C3=ADce=20?= =?UTF-8?q?=C4=8D=C3=A1st=C3=AD=20v=20autocomplete=20=C5=99e=C5=A1itel?= =?UTF-8?q?=C5=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/views/autocomplete.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/api/views/autocomplete.py b/api/views/autocomplete.py index a97fbbab..98087cc8 100644 --- a/api/views/autocomplete.py +++ b/api/views/autocomplete.py @@ -26,11 +26,15 @@ class ResitelAutocomplete(LoginRequiredAjaxMixin,autocomplete.Select2QuerySetVie def get_queryset(self): qs = m.Resitel.objects.all() if self.q: - qs = qs.filter( - Q(osoba__jmeno__istartswith=self.q)| - Q(osoba__prijmeni__istartswith=self.q)| - Q(osoba__prezdivka__istartswith=self.q) + parts = self.q.split() + query = Q() + for part in parts: + query &= ( + Q(osoba__jmeno__istartswith=self.q)| + Q(osoba__prijmeni__istartswith=self.q)| + Q(osoba__prezdivka__istartswith=self.q) ) + qs = qs.filter(query) return qs class OdevzdatelnyProblemAutocomplete(autocomplete.Select2QuerySetView): From 843025d63504a709e3885585d4c56a9b6dd6b330 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Mon, 15 Nov 2021 21:21:03 +0100 Subject: [PATCH 04/14] =?UTF-8?q?Fix=20zobrazov=C3=A1n=C3=AD=20neve=C5=99e?= =?UTF-8?q?jn=C3=BDch=20=C4=8D=C3=ADsel=20v=20archivu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/templates/seminar/archiv/cisla.html | 6 +++--- seminar/views/views_all.py | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/seminar/templates/seminar/archiv/cisla.html b/seminar/templates/seminar/archiv/cisla.html index 4cba99ee..35fd5666 100644 --- a/seminar/templates/seminar/archiv/cisla.html +++ b/seminar/templates/seminar/archiv/cisla.html @@ -35,9 +35,9 @@ Jednotlivá čísla: Výsledková listina diff --git a/seminar/views/views_all.py b/seminar/views/views_all.py index 9392f49a..85a7f9f2 100644 --- a/seminar/views/views_all.py +++ b/seminar/views/views_all.py @@ -630,6 +630,8 @@ class ArchivView(generic.ListView): context = super(ArchivView, self).get_context_data(**kwargs) cisla = Cislo.objects.filter(poradi=1) + if not self.request.user.je_org: + cisla = cisla.filter(verejne_db=True) urls ={} for i, c in enumerate(cisla): From 0dba75203e9a6ffd3c2880e3df5dbf0d962c10ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Mon, 15 Nov 2021 21:37:32 +0100 Subject: [PATCH 05/14] =?UTF-8?q?Fix=20v=C3=BDsledkovka=20ro=C4=8Dn=C3=ADk?= =?UTF-8?q?u=20LaTeX=20i=20s=20neve=C5=99ejn=C3=BDmi?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/templates/seminar/archiv/rocnik.html | 7 +------ seminar/templates/seminar/archiv/rocnik_vysledkovka.tex | 2 ++ 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/seminar/templates/seminar/archiv/rocnik.html b/seminar/templates/seminar/archiv/rocnik.html index aa2f1dbc..93690153 100644 --- a/seminar/templates/seminar/archiv/rocnik.html +++ b/seminar/templates/seminar/archiv/rocnik.html @@ -65,18 +65,13 @@ {% if vysledkovka %} - {% if user.je_org %} - - {% endif %} -

Výsledková listina

{% include "seminar/vysledkovka_rocnik.html" %} {% endif %} {% if user.je_org %}
+ Výsledkovka ročníku (LaTeX, včetně neveřejných)

Výsledková listina včetně neveřejných bodů

{% with radky_vysledkovky_s_neverejnymi as radky_vysledkovky %} {% with cisla_s_neverejnymi as cisla %} diff --git a/seminar/templates/seminar/archiv/rocnik_vysledkovka.tex b/seminar/templates/seminar/archiv/rocnik_vysledkovka.tex index 61c9abbb..217127de 100644 --- a/seminar/templates/seminar/archiv/rocnik_vysledkovka.tex +++ b/seminar/templates/seminar/archiv/rocnik_vysledkovka.tex @@ -1,5 +1,6 @@ {% with lb="{" %} {% with rb="}" %} +{% with radky_vysledkovky=radky_vysledkovky_s_neverejnymi cisla=cisla_s_neverejnymi %} \setlength{\tabcolsep}{3pt} \begin{longtable}{|r|l|c|r|{% for cislo in cisla %}c{% if not forloop.last %}@{\hskip.5em}{% endif %}{% endfor %}|r|}\hline & & & & \multicolumn{{ lb }}{{ cisla|length }}}{c|}{\textbf{Číslo}} & \\\textbf{Poř.} & \textbf{Jméno} & \textbf{R.} & \raisebox{0.7mm}{$\sum_{-1}$} & {% for cislo in cisla %}\textbf{{ lb }}{{ cislo.poradi }}{{ rb }} & {% endfor %}\raisebox{0.7mm}{$\sum_1$} \\\hline @@ -10,3 +11,4 @@ {% endfor %}\end{longtable} {% endwith %} {% endwith %} +{% endwith %} From f777252a96c2ab0b5eb6a58ec5ac89ad61dd2204 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Mon, 15 Nov 2021 21:53:36 +0100 Subject: [PATCH 06/14] =?UTF-8?q?Add=20neve=C5=99ejn=C3=A1=20=C4=8D=C3=ADs?= =?UTF-8?q?la=20pro=20orgy=20v=20archivu=20u=20ro=C4=8Dn=C3=ADku=20(Rocnik?= =?UTF-8?q?View)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/models.py | 5 ++ seminar/templates/seminar/archiv/rocnik.html | 48 ++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/seminar/models.py b/seminar/models.py index daef62e6..b04b31fa 100644 --- a/seminar/models.py +++ b/seminar/models.py @@ -466,6 +466,11 @@ class Rocnik(SeminarModelBase): vc.sort(key=lambda c: c.poradi) return vc + def neverejna_cisla(self): + vc = [c for c in self.cisla.all() if not c.verejne()] + vc.sort(key=lambda c: c.poradi) + return vc + def posledni_verejne_cislo(self): vc = self.verejna_cisla() return vc[-1] if vc else None diff --git a/seminar/templates/seminar/archiv/rocnik.html b/seminar/templates/seminar/archiv/rocnik.html index 93690153..01a9f5ac 100644 --- a/seminar/templates/seminar/archiv/rocnik.html +++ b/seminar/templates/seminar/archiv/rocnik.html @@ -63,6 +63,54 @@ {% endfor %}
+{% if user.je_org and rocnik.neverejna_cisla %} +
+
+ {% for c in rocnik.neverejna_cisla %} +
+ +
Číslo {{ c.kod }}
+ +
+ +
+
+ +
+ {% if c.titulka_nahled %} + {{ c.kod }} + {% else %} + {% load static %} no-picture + {% endif %} +
+ +
+
+ +
+ +
+ + +
+
+
+
+ + {% endfor %} +
+
+{% endif %} + {% if vysledkovka %}

Výsledková listina

From 33ce4a5db5c715aad8fa372ba0056e152516e0a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Mon, 15 Nov 2021 22:05:30 +0100 Subject: [PATCH 07/14] =?UTF-8?q?Fix=20autocomplete=20um=C3=ADraj=C3=ADc?= =?UTF-8?q?=C3=AD=20na=20mezeru?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/views/autocomplete.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/api/views/autocomplete.py b/api/views/autocomplete.py index 98087cc8..630e9106 100644 --- a/api/views/autocomplete.py +++ b/api/views/autocomplete.py @@ -13,7 +13,9 @@ class SkolaAutocomplete(autocomplete.Select2QuerySetView): if self.q: words = self.q.split(' ') #TODO re split podle bileho znaku partq = Q() - for w in words: # Hledej po slovech, zahoď čárky a tečky z konců. + for w in words: # Hledej po slovech, zahoď čárky a tečky z konců. + if len(w) == 0: + continue if w[-1] in (".",","): w = w[:-1] From c0f5f68b8a267a8625d897a87dd1f23c5ecb8ade Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Mon, 15 Nov 2021 22:45:45 +0100 Subject: [PATCH 08/14] =?UTF-8?q?Fix=20kontrola,=20zda=20orgov=C3=A9=20vyp?= =?UTF-8?q?lnili=20probl=C3=A9m=20u=20hodnocen=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/templates/seminar/odevzdavatko/detail.html | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/seminar/templates/seminar/odevzdavatko/detail.html b/seminar/templates/seminar/odevzdavatko/detail.html index f80f0cae..45c3ce54 100644 --- a/seminar/templates/seminar/odevzdavatko/detail.html +++ b/seminar/templates/seminar/odevzdavatko/detail.html @@ -134,6 +134,15 @@ $(document).ready(function(){ return false; } } + + function problem_is_empty(elem, index, array) {return elem.firstElementChild.children.length !== 1 && elem.firstElementChild.children[1].textContent === "";} + + if ($('.hodnoceni').toArray().some(problem_is_empty)) { + alert("Neuloženo! Nezadal jsi problém, ke kterému posíláš hodnocení. Pokud je toto hodnocení navíc, smaž ho prosím křížkem a znovu odešli.") + event.preventDefault() + return false; + } + return true; } From ee40db6e250bb3965f379f81608974c06e680e17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Tue, 16 Nov 2021 00:44:26 +0100 Subject: [PATCH 09/14] =?UTF-8?q?Add=20=C5=99e=C5=A1itelsk=C3=A9=20view=20?= =?UTF-8?q?na=20=C5=99e=C5=A1en=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../seminar/odevzdavatko/detail_resitele.html | 50 +++++++++++++++++++ seminar/urls.py | 2 + seminar/views/odevzdavatko.py | 29 +++++++++++ 3 files changed, 81 insertions(+) create mode 100644 seminar/templates/seminar/odevzdavatko/detail_resitele.html diff --git a/seminar/templates/seminar/odevzdavatko/detail_resitele.html b/seminar/templates/seminar/odevzdavatko/detail_resitele.html new file mode 100644 index 00000000..4e5d7848 --- /dev/null +++ b/seminar/templates/seminar/odevzdavatko/detail_resitele.html @@ -0,0 +1,50 @@ +{% extends "base.html" %} +{% load static %} +{% load deadliny %} + +{% block content %} + +

Řešené problémy: {{ object.problem.all | join:", " }}

+ +

Řešitelé: {% for r in object.resitele.all %} {{ r }} + {% if forloop.revcounter0 != 0 %}, {% endif %} {% endfor %}

+ +{# https://docs.djangoproject.com/en/3.1/ref/models/instances/#django.db.models.Model.get_FOO_display #} +

Forma: {{ object.get_forma_display }}

+ +

Doručeno {{ object.cas_doruceni }}, deadline: {{object.cas_doruceni | deadline_html }}

+ +{# Soubory: #} +

Přílohy:

+{% if object.prilohy.all %} + + +{% for priloha in object.prilohy.all %} + + + + + {# TODO: Orgo-poznámka, ideálně jako formulář #} +{% endfor %} +
SouborŘešitelova poznámkaDatum
{{ priloha.split | last }}{{ priloha.res_poznamka }}{{ priloha.vytvoreno }}
+{% else %} +

Žádné přílohy

+{% endif %} + +{#

Poznámka:

#} +{#

{{ poznamka }}

#} + +{# Hodnocení: #} +

Hodnocení:

+ +{# #} +{% for h in hodnoceni %} + + + +{# #} + +{% endfor %} +
ProblémBodyČíslo pro body
{{ h.problem }}{{ h.body }}{{ h.cislo_body }}
+ +{% endblock %} diff --git a/seminar/urls.py b/seminar/urls.py index 8a6aacf4..5b71d2b3 100644 --- a/seminar/urls.py +++ b/seminar/urls.py @@ -142,4 +142,6 @@ urlpatterns = [ path('org/reseni/', org_required(viewMethodSwitch(get=views.DetailReseniView.as_view(), post=views.hodnoceniReseniView)), name='odevzdavatko_detail_reseni'), path('org/reseni/all', org_required(views.SeznamReseniView.as_view())), path('org/reseni/akt', org_required(views.SeznamAktualnichReseniView.as_view())), + + path('resitel/reseni/', resitel_or_org_required(views.ResitelReseniView.as_view()), name='odevzdavatko_resitel_reseni'), ] diff --git a/seminar/views/odevzdavatko.py b/seminar/views/odevzdavatko.py index ecbef01e..786d263c 100644 --- a/seminar/views/odevzdavatko.py +++ b/seminar/views/odevzdavatko.py @@ -1,3 +1,4 @@ +from django.core.exceptions import PermissionDenied from django.views.generic import ListView, DetailView, FormView from django.views.generic.list import MultipleObjectTemplateResponseMixin,MultipleObjectMixin from django.views.generic.base import View @@ -268,6 +269,34 @@ def hodnoceniReseniView(request, pk, *args, **kwargs): return redirect(success_url) +class ResitelReseniView(DetailView): + model = m.Reseni + template_name = 'seminar/odevzdavatko/detail_resitele.html' + + def aktualni_hodnoceni(self): + self.reseni = get_object_or_404(m.Reseni, id=self.kwargs['pk']) + result = [] + for hodn in m.Hodnoceni.objects.filter(reseni=self.reseni): + result.append( + { + "problem": hodn.problem, + "body": hodn.body, + # "cislo_body": hodn.cislo_body, + } + ) + return result + + def get_context_data(self, **kw): + ctx = super().get_context_data(**kw) + hodnoceni = self.aktualni_hodnoceni() + if self.request.user not in self.reseni.resitele.all(): + raise PermissionDenied() + # ctx['poznamka'] = f.PoznamkaReseniForm(instance=self.reseni) + ctx["hodnoceni"] = hodnoceni + return ctx + + + class PrehledOdevzdanychReseni(ListView): model = m.Hodnoceni template_name = 'seminar/odevzdavatko/resitel_prehled.html' From 42a144abe490ec456b11e45ac0ee39084d7c2e62 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Tue, 16 Nov 2021 09:53:42 +0100 Subject: [PATCH 10/14] =?UTF-8?q?Add=20=C5=99e=C5=A1itelsk=C3=A9=20=C5=99e?= =?UTF-8?q?=C5=A1en=C3=AD=20do=20men=C3=AD=C4=8Dka?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- data/sitetree.json | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/data/sitetree.json b/data/sitetree.json index 5702031a..0416f54b 100644 --- a/data/sitetree.json +++ b/data/sitetree.json @@ -977,5 +977,29 @@ }, "model": "sitetree.treeitem", "pk": 50 + }, + { + "fields": { + "access_guest": false, + "access_loggedin": false, + "access_perm_type": 1, + "access_permissions": [], + "access_restricted": true, + "alias": null, + "description": "", + "hidden": false, + "hint": "", + "inbreadcrumbs": true, + "inmenu": true, + "insitetree": true, + "parent": 42, + "sort_order": 51, + "title": "Detail řešení {{ reseni.id }}", + "tree": 1, + "url": "odevzdavatko_resitel_reseni reseni.id", + "urlaspattern": true + }, + "model": "sitetree.treeitem", + "pk": 51 } -] +] \ No newline at end of file From 50e887f3cea25733933a82cb6ad5708087c7ac24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Tue, 16 Nov 2021 10:04:21 +0100 Subject: [PATCH 11/14] =?UTF-8?q?Fix=20=C5=99e=C5=A1itelsk=C3=A9=20=C5=99e?= =?UTF-8?q?=C5=A1en=C3=AD=20omezen=C3=AD=20p=C5=99=C3=ADstupu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/views/odevzdavatko.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seminar/views/odevzdavatko.py b/seminar/views/odevzdavatko.py index 786d263c..b3e1947d 100644 --- a/seminar/views/odevzdavatko.py +++ b/seminar/views/odevzdavatko.py @@ -289,7 +289,7 @@ class ResitelReseniView(DetailView): def get_context_data(self, **kw): ctx = super().get_context_data(**kw) hodnoceni = self.aktualni_hodnoceni() - if self.request.user not in self.reseni.resitele.all(): + if not self.reseni.resitele.filter(osoba__user=self.request.user).exists(): raise PermissionDenied() # ctx['poznamka'] = f.PoznamkaReseniForm(instance=self.reseni) ctx["hodnoceni"] = hodnoceni From d9dbbbbbff0a1bacaec70b767508441e014c24a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Tue, 16 Nov 2021 10:04:55 +0100 Subject: [PATCH 12/14] =?UTF-8?q?Add=20odkaz=20na=20=C5=99e=C5=A1itelsk?= =?UTF-8?q?=C3=A9=20=C5=99e=C5=A1en=C3=AD=20v=20Moje=20=C5=99e=C5=A1en?= =?UTF-8?q?=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/templates/seminar/odevzdavatko/resitel_prehled.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seminar/templates/seminar/odevzdavatko/resitel_prehled.html b/seminar/templates/seminar/odevzdavatko/resitel_prehled.html index 229b036c..773aa2a3 100644 --- a/seminar/templates/seminar/odevzdavatko/resitel_prehled.html +++ b/seminar/templates/seminar/odevzdavatko/resitel_prehled.html @@ -25,7 +25,7 @@ {{ hodn.reseni.cas_doruceni | date:"d.m.Y H:i"}} {{ hodn.problem.nazev | zkrat_nazev_problemu }} - {{ hodn.body|default_if_none:"---" }} + {{ hodn.body|default_if_none:"---" }} {{ hodn.reseni.cas_doruceni | deadline_html }} {% endfor %} From e90cc4e6b3ec7cfc54de8ef80e4f94753dc313fd Mon Sep 17 00:00:00 2001 From: Jonas Havelka Date: Thu, 16 Sep 2021 18:31:20 +0200 Subject: [PATCH 13/14] =?UTF-8?q?Fix=20=C5=99azen=C3=AD=20v=C4=9Bc=C3=AD?= =?UTF-8?q?=20na=20hlavn=C3=AD=20str=C3=A1nce=20adminu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mamweb/admin.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/mamweb/admin.py b/mamweb/admin.py index 12d063f7..aa93d11a 100644 --- a/mamweb/admin.py +++ b/mamweb/admin.py @@ -1,4 +1,6 @@ +import locale from django.contrib import admin +from django.contrib.admin import AdminSite from django.contrib.flatpages.models import FlatPage # Note: we are renaming the original Admin and Form as we import them! @@ -24,3 +26,24 @@ class FlatPageAdmin(FlatPageAdminOld): admin.site.unregister(FlatPage) admin.site.register(FlatPage, FlatPageAdmin) +locale.setlocale(locale.LC_COLLATE, 'cs_CZ.UTF-8') + +# https://books.agiliq.com/projects/django-admin-cookbook/en/latest/set_ordering.html +# FIXME zpraseno pomocí toho, že Python umí bez problému přepisovat funkce +def get_app_list(self, request): + """ + Return a sorted list of all the installed apps that have been + registered in this site. + """ + + app_dict = self._build_app_dict(request) + # Sort the apps alphabetically. + app_list = sorted(app_dict.values(), key=lambda x: locale.strxfrm('0') if (x['name'] == "Seminar") else locale.strxfrm(x['name'].lower())) + + # Sort the models alphabetically within each app. + for app in app_list: + app['models'].sort(key=lambda x: locale.strxfrm(x['name'].lower())) + + return app_list + +AdminSite.get_app_list = get_app_list From adc0c6897702e9fb54dcf564b7023ca13b1f9862 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=C3=A1=C5=A1=20Havelka?= Date: Tue, 16 Nov 2021 10:14:16 +0100 Subject: [PATCH 14/14] =?UTF-8?q?Fix=20=C5=99adit=20(Node)=20jako=20posled?= =?UTF-8?q?n=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mamweb/admin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mamweb/admin.py b/mamweb/admin.py index aa93d11a..9c421309 100644 --- a/mamweb/admin.py +++ b/mamweb/admin.py @@ -38,11 +38,11 @@ def get_app_list(self, request): app_dict = self._build_app_dict(request) # Sort the apps alphabetically. - app_list = sorted(app_dict.values(), key=lambda x: locale.strxfrm('0') if (x['name'] == "Seminar") else locale.strxfrm(x['name'].lower())) + app_list = sorted(app_dict.values(), key=lambda x: locale.strxfrm('!') if (x['name'] == "Seminar") else locale.strxfrm(x['name'].lower())) # Sort the models alphabetically within each app. for app in app_list: - app['models'].sort(key=lambda x: locale.strxfrm(x['name'].lower())) + app['models'].sort(key=lambda x: locale.strxfrm('žž' + x['name'].lower()) if (x['name'].endswith("(Node)")) else locale.strxfrm(x['name'].lower())) return app_list