From 3429596595b1eb1362e711294d443168303cbf55 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kate=C5=99ina=20=C4=8C?= Date: Tue, 30 Mar 2021 22:17:51 +0200 Subject: [PATCH 1/9] =?UTF-8?q?smaz=C3=A1na=20p=C5=99ebyte=C4=8Dn=C3=A1=20?= =?UTF-8?q?=C4=8D=C3=A1rka=20v=20mailu?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/templates/seminar/registrace/password_reset_email.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/seminar/templates/seminar/registrace/password_reset_email.html b/seminar/templates/seminar/registrace/password_reset_email.html index 8e7186f9..8687a6cb 100644 --- a/seminar/templates/seminar/registrace/password_reset_email.html +++ b/seminar/templates/seminar/registrace/password_reset_email.html @@ -4,5 +4,5 @@ Obdrželi jsme od Tebe žádost o obnovu hesla uživatele {{ user }} na webu M&M Pro zadání nového hesla přejdi na následující stránku: {{ protocol}}://{{ domain }}{% url 'password_reset_confirm' uidb64=uid token=token %} -S pozdravem, +S pozdravem organizátoři M&M \ No newline at end of file From 2a292f3a828a62241c377d6d0ab1f77e050c0d5f Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Tue, 30 Mar 2021 22:26:37 +0200 Subject: [PATCH 2/9] =?UTF-8?q?Templatetagy=20na=20hezk=C3=A9=20vykreslov?= =?UTF-8?q?=C3=A1n=C3=AD=20a=20dohled=C3=A1v=C3=A1n=C3=AD=20deadlin=C5=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Nikdo neví, k čemu jsou dobré, ale už jsou napsané... --- seminar/templatetags/deadliny.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 seminar/templatetags/deadliny.py diff --git a/seminar/templatetags/deadliny.py b/seminar/templatetags/deadliny.py new file mode 100644 index 00000000..29ea5c79 --- /dev/null +++ b/seminar/templatetags/deadliny.py @@ -0,0 +1,24 @@ +from django import template +from seminar.utils import TypDeadline, deadline +register = template.Library() + +@register.filter(name='deadline') +def deadline_text(datum): + typ, cislo, deadline = deadline(datum) + strings = { + TypDeadline.PredDeadline: f"1. deadline čísla {cislo} ({datum})", + TypDeadline.SousDeadline: f"Soustřeďkový deadline čísla {cislo} ({datum})", + TypDeadline.FinalDeadline: f"Finální deadline čísla {cislo} ({datum})", + } + return strings[typ] + +@register.filter(name='deadline_html') +def deadline_html(datum): + typ, _, _ = deadline(datum) + text = deadline_text(datum) + classes = { + TypDeadline.PredDeadline: 'preddeadline', + TypDeadline.SousDeadline: 'sous_deadline', + TypDeadline.FinalDeadline: 'final_deadline', + } + return f'{text}' From b37953bc902f07084886d5da37d5f543735429d4 Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Tue, 30 Mar 2021 22:31:50 +0200 Subject: [PATCH 3/9] =?UTF-8?q?Fix=20=C5=A1patn=C3=A1=20prom=C4=9Bnn=C3=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/templatetags/deadliny.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/seminar/templatetags/deadliny.py b/seminar/templatetags/deadliny.py index 29ea5c79..18bfbf08 100644 --- a/seminar/templatetags/deadliny.py +++ b/seminar/templatetags/deadliny.py @@ -6,9 +6,9 @@ register = template.Library() def deadline_text(datum): typ, cislo, deadline = deadline(datum) strings = { - TypDeadline.PredDeadline: f"1. deadline čísla {cislo} ({datum})", - TypDeadline.SousDeadline: f"Soustřeďkový deadline čísla {cislo} ({datum})", - TypDeadline.FinalDeadline: f"Finální deadline čísla {cislo} ({datum})", + TypDeadline.PredDeadline: f"1. deadline čísla {cislo} ({deadline})", + TypDeadline.SousDeadline: f"Soustřeďkový deadline čísla {cislo} ({deadline})", + TypDeadline.FinalDeadline: f"Finální deadline čísla {cislo} ({deadline})", } return strings[typ] From 70c3ec8b6c9127332ff2ebd7091faec57f81cf0f Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Tue, 30 Mar 2021 23:01:31 +0200 Subject: [PATCH 4/9] =?UTF-8?q?Hodn=C4=9B=20oprav?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Neumím kódit :-) --- seminar/templatetags/deadliny.py | 11 ++++++----- seminar/utils.py | 14 ++++++++------ 2 files changed, 14 insertions(+), 11 deletions(-) diff --git a/seminar/templatetags/deadliny.py b/seminar/templatetags/deadliny.py index 18bfbf08..b7a0142d 100644 --- a/seminar/templatetags/deadliny.py +++ b/seminar/templatetags/deadliny.py @@ -1,14 +1,15 @@ from django import template +from django.utils.safestring import mark_safe from seminar.utils import TypDeadline, deadline register = template.Library() @register.filter(name='deadline') def deadline_text(datum): - typ, cislo, deadline = deadline(datum) + typ, cislo, dl = deadline(datum) strings = { - TypDeadline.PredDeadline: f"1. deadline čísla {cislo} ({deadline})", - TypDeadline.SousDeadline: f"Soustřeďkový deadline čísla {cislo} ({deadline})", - TypDeadline.FinalDeadline: f"Finální deadline čísla {cislo} ({deadline})", + TypDeadline.PredDeadline: f"1. deadline čísla {cislo} ({dl})", + TypDeadline.SousDeadline: f"Soustřeďkový deadline čísla {cislo} ({dl})", + TypDeadline.FinalDeadline: f"Finální deadline čísla {cislo} ({dl})", } return strings[typ] @@ -21,4 +22,4 @@ def deadline_html(datum): TypDeadline.SousDeadline: 'sous_deadline', TypDeadline.FinalDeadline: 'final_deadline', } - return f'{text}' + return mark_safe(f'{text}') diff --git a/seminar/utils.py b/seminar/utils.py index a41b4111..68bce110 100644 --- a/seminar/utils.py +++ b/seminar/utils.py @@ -309,7 +309,7 @@ def deadline_v_rocniku(datum, rocnik): deadliny.append((TypDeadline.FinalDeadline, c, c.datum_deadline)) deadliny = sorted(deadliny, key=lambda x: x[2]) # podle data for dl in deadliny: - if datum <= dl: + if datum <= dl[2]: # První takový deadline je ten nejtěsnější return dl @@ -319,20 +319,22 @@ def deadline(datum): Vrací trojici (TypDeadline, Cislo, datumDeadline: date). """ + if isinstance(datum, datetime.datetime): + datum = datum.date() rok = datum.year # Dva ročníky podezřelé z obsahování dat - pozdejsi_rocnik = m.Rocnik.filter(prvni_rok=rok) - drivejsi_rocnik = m.Rocnik.filter(druhy_rok=rok) - if any( + pozdejsi_rocnik = m.Rocnik.objects.filter(prvni_rok=rok) + drivejsi_rocnik = m.Rocnik.objects.filter(prvni_rok=rok-1) + if any([ pozdejsi_rocnik.count() > 1, drivejsi_rocnik.count() > 1, - ): + ]): raise ValueError(f"Více ročníků začíná/končí stejným rokem: {rok}") pozdejsi_rocnik = pozdejsi_rocnik.first() if pozdejsi_rocnik.count() > 0 else None drivejsi_rocnik = drivejsi_rocnik.first() if drivejsi_rocnik.count() > 0 else None # Předpokládáme, že neexistuje číslo, které má deadline ale nemá finální deadline. - posledni_deadline_drivejsiho_rocniku = m.Cislo.objects.get(rocnik=drivejsi_rocnik, datum_deadline__isnull=False).datum_deadline + posledni_deadline_drivejsiho_rocniku = m.Cislo.objects.filter(rocnik=drivejsi_rocnik, datum_deadline__isnull=False).last().datum_deadline if datum <= posledni_deadline_drivejsiho_rocniku: return deadline_v_rocniku(datum, drivejsi_rocnik) From 08e31a849ca6926b190e383dce24c210b713725e Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Tue, 30 Mar 2021 23:01:58 +0200 Subject: [PATCH 5/9] =?UTF-8?q?Zobrazen=C3=AD=20deadlinu=20doru=C4=8Den?= =?UTF-8?q?=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- seminar/templates/seminar/odevzdavatko/detail.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/seminar/templates/seminar/odevzdavatko/detail.html b/seminar/templates/seminar/odevzdavatko/detail.html index dadeff41..14094fb8 100644 --- a/seminar/templates/seminar/odevzdavatko/detail.html +++ b/seminar/templates/seminar/odevzdavatko/detail.html @@ -1,5 +1,6 @@ {% extends "base.html" %} {% load static %} +{% load deadliny %} {% block content %} @@ -62,7 +63,9 @@ $(document).ready(function(){

Řešitelé: {{ object.resitele.all | join:", " }}

{# 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 }}

+

Forma: {{ object.get_forma_display }}

+ +

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

{# Soubory: #}

Přílohy:

From 41e95fc5742fe0445f3dcdf62ddecaff1f2a93fe Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Wed, 31 Mar 2021 21:30:51 +0200 Subject: [PATCH 6/9] =?UTF-8?q?Zalo=C5=BEena=20aplikace=20'various'=20na?= =?UTF-8?q?=20random=20v=C4=9Bci?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mamweb/settings_common.py | 2 ++ various/__init__.py | 0 various/admin.py | 3 +++ various/apps.py | 5 +++++ various/context_processors.py | 14 ++++++++++++++ various/migrations/__init__.py | 0 various/models.py | 3 +++ various/tests.py | 3 +++ various/views.py | 3 +++ 9 files changed, 33 insertions(+) create mode 100644 various/__init__.py create mode 100644 various/admin.py create mode 100644 various/apps.py create mode 100644 various/context_processors.py create mode 100644 various/migrations/__init__.py create mode 100644 various/models.py create mode 100644 various/tests.py create mode 100644 various/views.py diff --git a/mamweb/settings_common.py b/mamweb/settings_common.py index 75a5493c..925d5961 100644 --- a/mamweb/settings_common.py +++ b/mamweb/settings_common.py @@ -78,6 +78,7 @@ TEMPLATES = [ 'django.contrib.messages.context_processors.messages', 'sekizai.context_processors.sekizai', 'header_fotky.context_processors.vzhled', + 'various.context_processors.april', ) }, }, @@ -132,6 +133,7 @@ INSTALLED_APPS = ( 'korektury', 'prednasky', 'header_fotky', + 'various', # Admin upravy: diff --git a/various/__init__.py b/various/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/various/admin.py b/various/admin.py new file mode 100644 index 00000000..8c38f3f3 --- /dev/null +++ b/various/admin.py @@ -0,0 +1,3 @@ +from django.contrib import admin + +# Register your models here. diff --git a/various/apps.py b/various/apps.py new file mode 100644 index 00000000..c24a4428 --- /dev/null +++ b/various/apps.py @@ -0,0 +1,5 @@ +from django.apps import AppConfig + + +class VariousConfig(AppConfig): + name = 'various' diff --git a/various/context_processors.py b/various/context_processors.py new file mode 100644 index 00000000..c0be2975 --- /dev/null +++ b/various/context_processors.py @@ -0,0 +1,14 @@ +def april(req): + if 'X-April' in req.headers: + try: + year = int(req.headers['X-April']) + return {'april': year} + except: + pass # Fall-back to regular behaviour + + import datetime + today = datetime.date.today() + if today.day == 1 and today.month == 4: + return {'april': today.year} + return {} + diff --git a/various/migrations/__init__.py b/various/migrations/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/various/models.py b/various/models.py new file mode 100644 index 00000000..71a83623 --- /dev/null +++ b/various/models.py @@ -0,0 +1,3 @@ +from django.db import models + +# Create your models here. diff --git a/various/tests.py b/various/tests.py new file mode 100644 index 00000000..7ce503c2 --- /dev/null +++ b/various/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/various/views.py b/various/views.py new file mode 100644 index 00000000..91ea44a2 --- /dev/null +++ b/various/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. From afff7973fed8f541b10fa9300490af5d30a210db Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Wed, 31 Mar 2021 21:34:08 +0200 Subject: [PATCH 7/9] =?UTF-8?q?Apr=C3=ADl=202021:=20Rotace=20webu=20:-)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mamweb/templates/base.html | 44 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/mamweb/templates/base.html b/mamweb/templates/base.html index b79060b5..3b6b4f25 100644 --- a/mamweb/templates/base.html +++ b/mamweb/templates/base.html @@ -131,6 +131,50 @@ $("a[rel^='gallery-image']").prettyPhoto(prettyparams); }); + {% if april == 2021 %} + + {% endif %} {% render_block "js" %} From f1aa2d63684917b259e058c21bc61d37543416e3 Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Wed, 31 Mar 2021 21:40:33 +0200 Subject: [PATCH 8/9] =?UTF-8?q?Fix=20bugu,=20kdy=20se=20na=20apr=C3=ADla?= =?UTF-8?q?=20objev=C3=AD=20na=20chv=C3=ADli=20str=C3=A1nka=20norm=C3=A1ln?= =?UTF-8?q?=C4=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mamweb/templates/base.html | 6 ++---- various/context_processors.py | 1 + 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/mamweb/templates/base.html b/mamweb/templates/base.html index 3b6b4f25..8f2b7a7d 100644 --- a/mamweb/templates/base.html +++ b/mamweb/templates/base.html @@ -169,10 +169,8 @@ return Math.floor(360*Math.random()); } - $(document).ready(function(){ - $('.container').css('margin', 0); - rotace_a_posun($('.container'), randomUhel()); - }); + $('.container').css('margin', 0); + rotace_a_posun($('.container'), randomUhel()); {% endif %} {% render_block "js" %} diff --git a/various/context_processors.py b/various/context_processors.py index c0be2975..28a34858 100644 --- a/various/context_processors.py +++ b/various/context_processors.py @@ -1,4 +1,5 @@ def april(req): + return {'april': 2021} if 'X-April' in req.headers: try: year = int(req.headers['X-April']) From a68e04abe00cf63f71dc922dc608631aa6560f21 Mon Sep 17 00:00:00 2001 From: "Pavel \"LEdoian\" Turinsky" Date: Wed, 31 Mar 2021 21:41:14 +0200 Subject: [PATCH 9/9] =?UTF-8?q?Apr=C3=ADl=20nen=C3=AD=20po=C5=99=C3=A1d=20?= =?UTF-8?q?:-D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- various/context_processors.py | 1 - 1 file changed, 1 deletion(-) diff --git a/various/context_processors.py b/various/context_processors.py index 28a34858..c0be2975 100644 --- a/various/context_processors.py +++ b/various/context_processors.py @@ -1,5 +1,4 @@ def april(req): - return {'april': 2021} if 'X-April' in req.headers: try: year = int(req.headers['X-April'])