From 39d363993c1cb616faa3041407bc49340b870522 Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Mon, 14 Nov 2016 18:50:02 +0100 Subject: [PATCH] Add link options, more includes simplifying base.html, add host_organization in context --- app/organization/core/context_processors.py | 16 ++- .../migrations/0005_linktype_fa_option.py | 20 +++ app/organization/core/models.py | 1 + .../migrations/0062_auto_20161114_1842.py | 19 +++ app/settings.py | 3 +- app/templates/base.html | 124 +----------------- app/templates/includes/footer.html | 91 +++++++++++++ app/templates/includes/languages.html | 26 ++++ 8 files changed, 174 insertions(+), 126 deletions(-) create mode 100644 app/organization/core/migrations/0005_linktype_fa_option.py create mode 100644 app/organization/network/migrations/0062_auto_20161114_1842.py create mode 100644 app/templates/includes/footer.html create mode 100644 app/templates/includes/languages.html diff --git a/app/organization/core/context_processors.py b/app/organization/core/context_processors.py index f98ae2c3..bc1e71b3 100644 --- a/app/organization/core/context_processors.py +++ b/app/organization/core/context_processors.py @@ -1,10 +1,22 @@ from django.conf import settings # import the settings file from datetime import datetime, date +from organization.pages.models import Page +from organization.network.models import Organization -def static(request): +def settings(request): date_now = datetime.now() CURRENT_SEASON = int(date_now.year) - 1 if datetime(date_now.year, 1,1) <= date_now and date_now <= datetime(date_now.year, 7, 31) else date_now.year CURRENT_SEASON_STYLED = str(CURRENT_SEASON)[-2:]+"."+str(CURRENT_SEASON+1)[-2:] + newsletter_page = Page.objects.filter(slug="newsletter") + NEWSLETTER_SUBSCRIBING_URL = "" + if newsletter_page: + NEWSLETTER_SUBSCRIBING_URL = newsletter_page.first().get_absolute_url() + + host_organization = Organization.objects.get(is_host=True) + return {'CURRENT_SEASON': CURRENT_SEASON, - 'CURRENT_SEASON_STYLED': CURRENT_SEASON_STYLED} + 'CURRENT_SEASON_STYLED': CURRENT_SEASON_STYLED, + 'NEWSLETTER_SUBSCRIBING_URL': NEWSLETTER_SUBSCRIBING_URL, + 'host_organization': host_organization, + } diff --git a/app/organization/core/migrations/0005_linktype_fa_option.py b/app/organization/core/migrations/0005_linktype_fa_option.py new file mode 100644 index 00000000..9f8d034a --- /dev/null +++ b/app/organization/core/migrations/0005_linktype_fa_option.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.10 on 2016-11-14 17:42 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('organization-core', '0004_auto_20160923_1141'), + ] + + operations = [ + migrations.AddField( + model_name='linktype', + name='fa_option', + field=models.CharField(blank=True, help_text='will be added to fa-', max_length=64, null=True, verbose_name='fontawesome icon name option'), + ), + ] diff --git a/app/organization/core/models.py b/app/organization/core/models.py index b077a4b1..e1ed5f31 100644 --- a/app/organization/core/models.py +++ b/app/organization/core/models.py @@ -167,6 +167,7 @@ class LinkType(models.Model): blank=True, ) ordering = models.PositiveIntegerField(verbose_name=_('ordering'), null=True, blank=True) + fa_option = models.CharField(max_length=64, verbose_name=_('fontawesome icon name option'), null=True, blank=True, help_text="will be added to fa-") class Meta: ordering = ['ordering', ] diff --git a/app/organization/network/migrations/0062_auto_20161114_1842.py b/app/organization/network/migrations/0062_auto_20161114_1842.py new file mode 100644 index 00000000..c1a2d9e3 --- /dev/null +++ b/app/organization/network/migrations/0062_auto_20161114_1842.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.10 on 2016-11-14 17:42 +from __future__ import unicode_literals + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('organization-network', '0061_auto_20161114_1517'), + ] + + operations = [ + migrations.AlterModelOptions( + name='personactivity', + options={'ordering': ['-date_from'], 'verbose_name': 'activity', 'verbose_name_plural': 'activities'}, + ), + ] diff --git a/app/settings.py b/app/settings.py index 4683ad6e..890d51d1 100644 --- a/app/settings.py +++ b/app/settings.py @@ -268,8 +268,7 @@ TEMPLATES = [{'APP_DIRS': True, 'django.core.context_processors.tz', 'mezzanine.conf.context_processors.settings', 'mezzanine.pages.context_processors.page', - 'organization.core.context_processors.static', - 'organization.pages.context_processors.page_static', + 'organization.core.context_processors.settings', ) } }] diff --git a/app/templates/base.html b/app/templates/base.html index 282b513a..e10af1bb 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -5,9 +5,7 @@ - - {% spaceless %}{% block meta_title %}{% endblock %}{% endspaceless %}{% if settings.SITE_TITLE %} | {{ settings.SITE_TITLE }}{% endif %} @@ -61,31 +59,7 @@ {% page_menu "pages/menus/action.html" %}
- {% if settings.USE_MODELTRANSLATION and languages|length > 1 %} - {% nevercache %} - {% include "includes/language_selector.html" %} - {% endnevercache %} - - {% endif %} + {% include "includes/languages.html" %}
@@ -121,101 +95,7 @@
- - - + {% include "includes/footer.html" %}
{% search_form %} diff --git a/app/templates/includes/footer.html b/app/templates/includes/footer.html new file mode 100644 index 00000000..050af638 --- /dev/null +++ b/app/templates/includes/footer.html @@ -0,0 +1,91 @@ +{% load i18n pages_tags mezzanine_tags staticfiles keyword_tags event_tags organization_tags %} + + + diff --git a/app/templates/includes/languages.html b/app/templates/includes/languages.html new file mode 100644 index 00000000..eba0fbd8 --- /dev/null +++ b/app/templates/includes/languages.html @@ -0,0 +1,26 @@ +{% load i18n pages_tags mezzanine_tags staticfiles keyword_tags event_tags organization_tags %} +{% if settings.USE_MODELTRANSLATION and languages|length > 1 %} + {% nevercache %} + {% include "includes/language_selector.html" %} + {% endnevercache %} + +{% endif %} -- 2.39.5