Skip to content

Commit 7a56d27

Browse files
authored
Merge pull request #455 from pythoncanarias/navidad2022
Efecto navidades 2022
2 parents e38f263 + c1ad919 commit 7a56d27

File tree

4 files changed

+28
-1
lines changed

4 files changed

+28
-1
lines changed

apps/commons/context_processors.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import json
22
import os
33

4+
from django.utils import timezone
45
from django.conf import settings
56

67
from apps.organizations.models import Organization
@@ -22,3 +23,19 @@ def glob(request):
2223

2324
def main_organization_data(request):
2425
return dict(organization=Organization.load_main_organization())
26+
27+
28+
def global_data(request):
29+
"""Añade al contexto datos de uso general.
30+
31+
Agrega los datos de:
32+
33+
- La fecha actual
34+
- El valor DEBUG definido en el `settings.py`.
35+
"""
36+
now = timezone.now()
37+
hoy = now.date()
38+
return {
39+
'current_date': hoy,
40+
'DEBUG': settings.DEBUG,
41+
}

apps/commons/templates/base.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,11 @@
5858
{% include "footer.html" %}
5959

6060
<script src="{{ assets|get_asset_key:'commons/custom.min.js' }}"></script>
61-
{% block js %}{% endblock %}
61+
{% block js %}
62+
{% if current_date.month == 12 and current_date.day >= 21 and current_date.day <= 31 %}
63+
<script src="https://app.embed.im/snow.js" defer></script>
64+
{% endif %}
65+
{% endblock %}
6266

6367
</body>
6468
</html>

apps/homepage/templates/homepage/index.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,11 @@ <h4 class="content blog-message">Para más noticias, pásate por nuestro
125125
const quotes_api_url = "{% url 'api:random_quote' %}";
126126
</script>
127127
<script src="{{ assets|get_asset_key:'homepage/custom.min.js' }}"></script>
128+
{% block js %}
129+
{% if current_date.month == 12 and current_date.day >= 21 and current_date.day <= 31 %}
130+
<script src="https://app.embed.im/snow.js" defer></script>
131+
{% endif %}
132+
{% endblock %}
128133

129134
</body>
130135
</html>

main/settings.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
'django.contrib.messages.context_processors.messages',
118118
'apps.commons.context_processors.glob',
119119
'apps.commons.context_processors.main_organization_data',
120+
'apps.commons.context_processors.global_data',
120121
],
121122
},
122123
},

0 commit comments

Comments
 (0)