Browse Source

Prozatímní zveřejňování čísla spolu s jeho Úlohami a Tématy

middleware_test
Jonas Havelka 3 years ago
parent
commit
6255c9c957
  1. 48
      seminar/admin.py

48
seminar/admin.py

@ -10,6 +10,9 @@ from django_reverse_admin import ReverseModelAdmin
from solo.admin import SingletonModelAdmin from solo.admin import SingletonModelAdmin
from django.utils.safestring import mark_safe from django.utils.safestring import mark_safe
from seminar.views.vysledkovka import hlavni_problem
# TODO Přesunout do utils
# Todo: reversion # Todo: reversion
@ -58,23 +61,36 @@ class CisloAdmin(admin.ModelAdmin):
def force_publish(self,request,queryset): def force_publish(self,request,queryset):
for cislo in queryset: for cislo in queryset:
cn = m.CisloNode.objects.get(cislo=cislo) # cn = m.CisloNode.objects.get(cislo=cislo)
for ch in tl.all_children(cn): # for ch in tl.all_children(cn):
print(ch) # if isinstance(ch, m.TemaVCisleNode):
if isinstance(ch, m.TemaVCisleNode): # if ch.tema.stav not in (m.Problem.STAV_ZADANY, m.Problem.STAV_VYRESENY):
if ch.tema.stav not in (m.Problem.STAV_ZADANY, m.Problem.STAV_VYRESENY): # ch.tema.stav = m.Problem.STAV_ZADANY
ch.tema.stav = m.Problem.STAV_ZADANY # ch.tema.save()
ch.tema.save() #
# if isinstance(ch, m.UlohaZadaniNode) or isinstance(ch, m.UlohaVzorakNode):
# if ch.uloha.stav not in (m.Problem.STAV_ZADANY, m.Problem.STAV_VYRESENY):
# ch.uloha.stav = m.Problem.STAV_ZADANY
# ch.uloha.save()
# if isinstance(ch, m.ReseniNode):
# for problem in ch.reseni.problem_set:
# if problem not in (m.Problem.STAV_ZADANY, m.Problem.STAV_VYRESENY):
# problem.stav = m.Problem.STAV_ZADANY
# problem.save()
for ch in m.Uloha.objects.filter(cislo_zadani=cislo):
if ch.stav not in (m.Problem.STAV_ZADANY, m.Problem.STAV_VYRESENY):
ch.stav = m.Problem.STAV_ZADANY
ch.save()
hp = hlavni_problem(ch)
if hp.stav not in (m.Problem.STAV_ZADANY, m.Problem.STAV_VYRESENY):
hp.stav = m.Problem.STAV_ZADANY
hp.save()
# TODO Řešení, vzoráky?
# TODO Konfera/Článek?
if isinstance(ch, m.UlohaZadaniNode) or isinstance(ch, m.UlohaVzorakNode):
if ch.uloha.stav not in (m.Problem.STAV_ZADANY, m.Problem.STAV_VYRESENY):
ch.uloha.stav = m.Problem.STAV_ZADANY
ch.uloha.save()
if isinstance(ch, m.ReseniNode):
for problem in ch.reseni.problem_set:
if problem not in (m.Problem.STAV_ZADANY, m.Problem.STAV_VYRESENY):
problem.stav = m.Problem.STAV_ZADANY
problem.save()
cislo.verejne_db = True cislo.verejne_db = True
cislo.save() cislo.save()

Loading…
Cancel
Save