From 57c8241ac77c2c6f4763e9d64e86fb2f1c6c8d1e Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Fri, 20 Jan 2017 21:20:45 +0100 Subject: [PATCH 1/6] zapomenuta migrace --- .gitignore | 4 ++++ seminar/migrations/0047_auto_20170120_2118.py | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 seminar/migrations/0047_auto_20170120_2118.py diff --git a/.gitignore b/.gitignore index 6b8b5c02..2b08d3e8 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,7 @@ # vim tmp files *~ + +# org poznamky +schemata +TODO diff --git a/seminar/migrations/0047_auto_20170120_2118.py b/seminar/migrations/0047_auto_20170120_2118.py new file mode 100644 index 00000000..1876fe25 --- /dev/null +++ b/seminar/migrations/0047_auto_20170120_2118.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('seminar', '0046_merge'), + ] + + operations = [ + migrations.AlterField( + model_name='cislo', + name='faze', + field=models.CharField(default='admin', help_text='B\u011bhem f\xe1ze "\xdapravy na webu" se obsah \u010d\xedsla vytv\xe1\u0159\xed (a p\u0159\xedpadn\u011b komentuje) ve webov\xe9m rozhran\xed. B\u011bhem f\xe1ze "\xdapravy v TeXu" u\u017e obsah ve webov\xe9m rozhran\xed editovat nelze a n\xe1vrhy na \xfapravy se p\xed\u0161\xed do korekturov\xe1tka a zan\xe1\u0161ej\xed do gitu. Z n\u011bj se pak vygeneruje verze pro web a \u010d\xedslo se p\u0159epne do f\xe1ze "Nahr\xe1no na web", co\u017e jen znamen\xe1, \u017ee u\u017e nejde automaticky st\xe1hnout obsah pro zalo\u017een\xed \u010d\xedsla v TeXu.', max_length=32, verbose_name='F\xe1ze vytv\xe1\u0159en\xed obsahu', choices=[('admin', '\xdapravy na webu'), ('tex', '\xdapravy v TeXu'), ('nahrano', 'Nahr\xe1no na web')]), + ), + ] From 5adc4eecb977ab09782069bc30a1cdb37c3d2a8a Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Fri, 20 Jan 2017 21:57:43 +0100 Subject: [PATCH 2/6] seminar | Cislo | pridan datum pro ucast na soustredeni --- seminar/admin.py | 4 +-- ...48_add_cislo_datum_deadline_soustredeni.py | 19 ++++++++++++ seminar/models.py | 5 +++ seminar/templates/seminar/titulnistrana.html | 2 +- .../seminar/zadani/AktualniZadani.html | 20 ++++++++---- seminar/views.py | 31 ++++++++++++++----- 6 files changed, 64 insertions(+), 17 deletions(-) create mode 100644 seminar/migrations/0048_add_cislo_datum_deadline_soustredeni.py diff --git a/seminar/admin.py b/seminar/admin.py index 89901c6b..e9a8801c 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -84,7 +84,7 @@ class ResitelInline(admin.TabularInline): class CisloInline(admin.TabularInline): model = Cislo - fields = ['cislo', 'datum_vydani', 'datum_deadline', 'verejne_db', 'poznamka'] + fields = ['cislo', 'datum_vydani', 'datum_deadline', 'datum_deadline_soustredeni', 'verejne_db', 'poznamka'] readonly_fields = ['cislo'] extra = 0 formfield_overrides = { @@ -256,7 +256,7 @@ class CisloAdmin(VersionAdmin): 'pdf' ] }), - (u'Data', {'fields': ['datum_vydani', 'datum_deadline']}), + (u'Data', {'fields': ['datum_vydani', 'datum_deadline', 'datum_deadline_soustredeni']}), ] list_display = [ 'kod', diff --git a/seminar/migrations/0048_add_cislo_datum_deadline_soustredeni.py b/seminar/migrations/0048_add_cislo_datum_deadline_soustredeni.py new file mode 100644 index 00000000..134a00a8 --- /dev/null +++ b/seminar/migrations/0048_add_cislo_datum_deadline_soustredeni.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('seminar', '0047_auto_20170120_2118'), + ] + + operations = [ + migrations.AddField( + model_name='cislo', + name='datum_deadline_soustredeni', + field=models.DateField(help_text='Datum pro p\u0159\xedjem \u0159e\u0161en\xed pro \xfa\u010dast na soust\u0159ed\u011bn\xed', null=True, verbose_name='datum deadline soust\u0159ed\u011bn\xed', blank=True), + ), + ] diff --git a/seminar/models.py b/seminar/models.py index 79b49eea..00237230 100644 --- a/seminar/models.py +++ b/seminar/models.py @@ -338,6 +338,11 @@ class Cislo(SeminarModelBase): datum_deadline = models.DateField(u'datum deadline', blank=True, null=True, help_text=u'Datum pro příjem řešení úloh zadaných v tomto čísle') + datum_deadline_soustredeni = models.DateField( + u'datum deadline soustředění', + blank=True, null=True, + help_text=u'Datum pro příjem řešení pro účast na soustředění') + verejne_db = models.BooleanField(u'číslo zveřejněno', db_column='verejne', default=False) verejna_vysledkovka = models.BooleanField(u'zveřejněna výsledkovka', default=False, diff --git a/seminar/templates/seminar/titulnistrana.html b/seminar/templates/seminar/titulnistrana.html index 7f4b2799..d73e65e3 100644 --- a/seminar/templates/seminar/titulnistrana.html +++ b/seminar/templates/seminar/titulnistrana.html @@ -20,7 +20,7 @@ M&M je korespondenční seminář. Několikrát do roka zdarma vydáváme č
{% if dead %}
-

Do konce odeslání řešení zbývá:
+

Do konce odeslání řešení {% if deadline_soustredeni %}(pro účast na soustředění) {% endif %}zbývá:
{{ted|timesince:dead}}

{% endif %} diff --git a/seminar/templates/seminar/zadani/AktualniZadani.html b/seminar/templates/seminar/zadani/AktualniZadani.html index ab870c2b..b611eee9 100644 --- a/seminar/templates/seminar/zadani/AktualniZadani.html +++ b/seminar/templates/seminar/zadani/AktualniZadani.html @@ -19,12 +19,20 @@ {% if user.is_staff or verejne %} {% if user.is_staff and not verejne %}
{% endif %} - {% if ac.zadane_problemy.all %} -
- Termín odeslání {{ac.cislo}}. série: {{ac.datum_deadline}} -
- {% endif %} - {#TODO a co speciální deadline pro účast na soustředění? #} + {% if ac.zadane_problemy.all %} + {% if ac.datum_deadline_soustredeni %} +
+ Termín odeslání {{ac.cislo}}. série pro účast na soustředění: + {{ac.datum_deadline_soustredeni}} +
+ {% endif %} + {% endif %} + {% if ac.zadane_problemy.all %} +
+ Termín odeslání {{ac.cislo}}. série: {{ac.datum_deadline}} +
+ {% endif %} + {% if ac.pdf %}

Aktuální číslo v PDF

diff --git a/seminar/views.py b/seminar/views.py index 08a27162..c04e7d13 100644 --- a/seminar/views.py +++ b/seminar/views.py @@ -101,16 +101,31 @@ class TitulniStranaView(generic.ListView): def get_context_data(self, **kwargs): context = super(TitulniStranaView, self).get_context_data(**kwargs) nastaveni = get_object_or_404(Nastaveni) - cas_deadline = nastaveni.aktualni_cislo.datum_deadline + + # zjisteni spravneho terminu + if nastaveni.aktualni_cislo.datum_deadline_soustredeni: + cas_deadline_soustredeni = nastaveni.aktualni_cislo.datum_deadline_soustredeni + if (datetime.now().date() < cas_deadline_soustredeni): + cas_deadline = cas_deadline_soustredeni + deadline_soustredeni = True + else: + cas_deadline = nastaveni.aktualni_cislo.datum_deadline + deadline_soustredeni = False + else: + cas_deadline = nastaveni.aktualni_cislo.datum_deadline + deadline_soustredeni = False + # Pokud neni zverejnene cislo nezverejnuj odpocet if nastaveni.aktualni_cislo.verejne(): - # pokus se zjistit termin odeslani a pokud neni zadany, - # nezverejnuj odpocet - try: - context['dead'] = datetime.combine(cas_deadline, datetime.max.time()) - context['ted'] = datetime.now() - except: - context['dead'] = None + # pokus se zjistit termin odeslani a pokud neni zadany, + # nezverejnuj odpocet + try: + context['dead'] = datetime.combine(cas_deadline, + datetime.max.time()) + context['ted'] = datetime.now() + context['deadline_soustredeni'] = deadline_soustredeni + except: + context['dead'] = None else: context['dead'] = None return context From 4fda307664adadd0438c2ef83e72dbe6acea9ba4 Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Fri, 20 Jan 2017 22:06:10 +0100 Subject: [PATCH 3/6] seminar | admin | kdyz cislo nema prirazene cislo reseni Kdyz cislo nema prirazene cislo reseni, tak nelze zjistovat fazy --- seminar/admin.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/seminar/admin.py b/seminar/admin.py index e9a8801c..7c67f69e 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -418,8 +418,9 @@ class ProblemAdmin(VersionAdmin): return readonly_fields if obj.cislo_zadani.faze != 'admin': readonly_fields += ['nazev', 'text_zadani', 'body'] - if obj.cislo_reseni.faze != 'admin': - readonly_fields += ['text_reseni'] + if obj.cislo_reseni: + if obj.cislo_reseni.faze != 'admin': + readonly_fields += ['text_reseni'] return readonly_fields def get_queryset(self, request): From 9954f8359dcc16a6142107a0c85daba5543036f7 Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Fri, 20 Jan 2017 22:44:20 +0100 Subject: [PATCH 4/6] opravy podle flake8 --- seminar/admin.py | 3 ++- seminar/models.py | 7 +++++-- seminar/views.py | 15 ++++++++------- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/seminar/admin.py b/seminar/admin.py index 89901c6b..811a309d 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -84,7 +84,8 @@ class ResitelInline(admin.TabularInline): class CisloInline(admin.TabularInline): model = Cislo - fields = ['cislo', 'datum_vydani', 'datum_deadline', 'verejne_db', 'poznamka'] + fields = ['cislo', 'datum_vydani', 'datum_deadline', + 'verejne_db', 'poznamka'] readonly_fields = ['cislo'] extra = 0 formfield_overrides = { diff --git a/seminar/models.py b/seminar/models.py index 79b49eea..08908185 100644 --- a/seminar/models.py +++ b/seminar/models.py @@ -340,8 +340,11 @@ class Cislo(SeminarModelBase): verejne_db = models.BooleanField(u'číslo zveřejněno', db_column='verejne', default=False) - verejna_vysledkovka = models.BooleanField(u'zveřejněna výsledkovka', default=False, - help_text=u'Je-li false u veřejného čísla, není výsledkovka zatím veřejná.') + verejna_vysledkovka = models.BooleanField( + u'zveřejněna výsledkovka', + default=False, + help_text=u'Je-li false u veřejného čísla,\ + není výsledkovka zatím veřejná.') poznamka = models.TextField(u'neveřejná poznámka', blank=True, help_text=u'Neveřejná poznámka k číslu (plain text)') diff --git a/seminar/views.py b/seminar/views.py index 08a27162..5c7b3355 100644 --- a/seminar/views.py +++ b/seminar/views.py @@ -104,13 +104,14 @@ class TitulniStranaView(generic.ListView): cas_deadline = nastaveni.aktualni_cislo.datum_deadline # Pokud neni zverejnene cislo nezverejnuj odpocet if nastaveni.aktualni_cislo.verejne(): - # pokus se zjistit termin odeslani a pokud neni zadany, - # nezverejnuj odpocet - try: - context['dead'] = datetime.combine(cas_deadline, datetime.max.time()) - context['ted'] = datetime.now() - except: - context['dead'] = None + # pokus se zjistit termin odeslani a pokud neni zadany, + # nezverejnuj odpocet + try: + context['dead'] = datetime.combine(cas_deadline, + datetime.max.time()) + context['ted'] = datetime.now() + except: + context['dead'] = None else: context['dead'] = None return context From 47005053f9920f4a73865581d167f6ec0007a4ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mat=C4=9Bj=20Koci=C3=A1n?= Date: Fri, 20 Jan 2017 22:49:45 +0100 Subject: [PATCH 5/6] admin: fix get_readonly_fields --- seminar/admin.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/seminar/admin.py b/seminar/admin.py index 811a309d..47e065a9 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -417,9 +417,9 @@ class ProblemAdmin(VersionAdmin): readonly_fields = ['timestamp', 'import_dakos_id'] if not obj: return readonly_fields - if obj.cislo_zadani.faze != 'admin': + if obj.cislo_zadani and obj.cislo_zadani.faze != 'admin': readonly_fields += ['nazev', 'text_zadani', 'body'] - if obj.cislo_reseni.faze != 'admin': + if obj.cislo_reseni and obj.cislo_reseni.faze != 'admin': readonly_fields += ['text_reseni'] return readonly_fields From f4fde1643dbbf8ea039453e814e96db5af938686 Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Fri, 20 Jan 2017 23:23:15 +0100 Subject: [PATCH 6/6] seminar | titulka | posledni den zobrazuj Posledni den, kdy lze odevzdavat pro ucast na soustredeni zobrazuj odpocet pro ucast a ne globalni. --- seminar/views.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seminar/views.py b/seminar/views.py index d074a8ac..d70ef712 100644 --- a/seminar/views.py +++ b/seminar/views.py @@ -106,7 +106,7 @@ class TitulniStranaView(generic.ListView): if nastaveni.aktualni_cislo.datum_deadline_soustredeni: cas_deadline_soustredeni = nastaveni.aktualni_cislo.\ datum_deadline_soustredeni - if (datetime.now().date() < cas_deadline_soustredeni): + if (datetime.now().date() <= cas_deadline_soustredeni): cas_deadline = cas_deadline_soustredeni deadline_soustredeni = True else: