From 2ed70b367345452fb2be3573f4ac1e90137e957b Mon Sep 17 00:00:00 2001 From: MaM Web user Date: Wed, 31 Mar 2021 21:57:16 +0200 Subject: [PATCH] =?UTF-8?q?Apr=C3=ADl=202021:=20random=20oto=C4=8Den=C3=AD?= =?UTF-8?q?=20webu=20+=20context=20processor?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit V testu to je, tenhle commit není pro merge zajímavý. P. --- mamweb/context_processors.py | 15 +++++++++++++ mamweb/settings_common.py | 1 + mamweb/templates/base.html | 43 ++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/mamweb/context_processors.py b/mamweb/context_processors.py index ec6481df..90ca195b 100644 --- a/mamweb/context_processors.py +++ b/mamweb/context_processors.py @@ -10,3 +10,18 @@ def vzhled(request): noc = False return {'noc' : noc} +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/mamweb/settings_common.py b/mamweb/settings_common.py index b0a80dbd..84a9d7b3 100644 --- a/mamweb/settings_common.py +++ b/mamweb/settings_common.py @@ -76,6 +76,7 @@ TEMPLATES = [ 'django.contrib.messages.context_processors.messages', 'sekizai.context_processors.sekizai', 'mamweb.context_processors.vzhled', + 'mamweb.context_processors.april', ) }, }, diff --git a/mamweb/templates/base.html b/mamweb/templates/base.html index 2f5826ef..f74e03bc 100644 --- a/mamweb/templates/base.html +++ b/mamweb/templates/base.html @@ -125,6 +125,49 @@ $("a[rel^='gallery-image']").prettyPhoto(prettyparams); }); + {% if april == 2021 %} + + {% endif %} + {% render_block "js" %}