diff --git a/Makefile b/Makefile index 982300e..b3a7aa2 100644 --- a/Makefile +++ b/Makefile @@ -65,13 +65,10 @@ django-shell: logs: docker-compose logs -f --tail=500 -django-backup: +backup: docker-compose exec web ./manage.py dumpdata --natural-foreign --indent=4 -e contenttypes -e auth.Permission -e sessions -e wagtailcore.pagerevision -e wagtailcore.groupcollectionpermission > ~/publichealth.home.json - -backup-archive: - gzip -1q ~/publichealth.home.json - -backup: django-backup backup-archive + zip ~/publichealth.home.json.`date +"%d%m%Y-%H%M"`.zip ~/publichealth.home.json + rm ~/publichealth.home.json django-loaddata: gunzip ~/publichealth.home.json.gz @@ -90,10 +87,15 @@ pg-exec: docker-compose exec postgres bash pg-dump: - docker-compose exec postgres bash -c 'pg_dump -U postgres -d postgres -f ./dumps/latest.sql' + docker-compose exec postgres bash -c 'pg_dump -U postgres -d postgres -f ./latest.sql' + +pg-backup: + docker-compose exec postgres bash -c 'pg_dump -U postgres -d postgres' > ~/pg-backup.sql + zip ~/pg-backup.sql.`date +"%d%m%Y-%H%M"`.zip ~/pg-backup.sql + rm ~/pg-backup.sql pg-restore: - docker-compose exec postgres bash -c 'psql -U postgres -d postgres -f ./dumps/latest.sql' + docker-compose exec postgres bash -c 'psql -U postgres -d postgres -f ./latest.sql' pg-surefire-drop-restore-db: # drop existing database, recreate it, and then restore its content from backup. diff --git a/ansible/roles/web/templates/nginx.conf.j2 b/ansible/roles/web/templates/nginx.conf.j2 index 6bdc5f6..aedb183 100644 --- a/ansible/roles/web/templates/nginx.conf.j2 +++ b/ansible/roles/web/templates/nginx.conf.j2 @@ -19,8 +19,7 @@ server { gzip_vary on; location /static/ { - access_log off; - expires 3600; + access_log off; expires 36000; alias {{ release_dir }}/static/; add_header Cache-Control "public"; add_header Access-Control-Allow-Origin https://{{ domain }}; @@ -28,17 +27,20 @@ server { # Set a longer expiry for CACHE/, because the filenames are unique. location /static/CACHE/ { - access_log off; - expires 864000; + access_log off; expires 864000; alias {{ release_dir }}/static/CACHE/; } + location /favicon.ico { + access_log off; expires max; + alias {{ release_dir }}/static/images/favicon.ico; + } + # Only serve /media/images by default, not e.g. original_images/. location /media/images { alias {{ release_dir }}/media/images; - access_log off; - expires max; - add_header Cache-Control "public"; + access_log off; expires max; + add_header Cache-Control "public"; } location / { diff --git a/docs/public-health.conf b/docs/public-health.conf deleted file mode 100644 index 790dcac..0000000 --- a/docs/public-health.conf +++ /dev/null @@ -1,57 +0,0 @@ -# Public Health CMS stage -upstream wagtail-stage { - server localhost:5000; -} -server { - listen 80; - server_name ph-alpha.nebula1.public-health.ch; - client_max_body_size 64M; - - gzip on; - gzip_types text/plain text/css application/x-javascript image/svg+xml; - gzip_comp_level 1; - gzip_disable msie6; - gzip_http_version 1.0; - gzip_proxied any; - gzip_vary on; - - location /static/ { - access_log off; - expires 3600; - alias /opt/public-health-ch/static/; - } - - # Set a longer expiry for CACHE/, because the filenames are unique. - location /static/CACHE/ { - access_log off; - expires 864000; - alias /opt/public-health-ch/static/CACHE/; - } - - # Only server /media/images by default, not e.g. original_images/. - location /media/images { - expires 864000; - alias /opt/public-health-ch/media/images; - } - - location / { - proxy_set_header X-Real-IP $remote_addr; - proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; - proxy_set_header Host $http_host; - proxy_redirect off; - proxy_pass http://wagtail-stage; - } -} - -server { - listen 80; listen 443 ssl; - server_name conference.public-health.ch; - location /fr { - return 301 $scheme://sph17.organizers-congress.org/frontend/index.php?sub=89; - } - location / { - return 301 $scheme://sph17.organizers-congress.org; - } -} - - diff --git a/publichealth/home/migrations/0018_contact_contact_form.py b/publichealth/home/migrations/0018_contact_contact_form.py new file mode 100644 index 0000000..c412115 --- /dev/null +++ b/publichealth/home/migrations/0018_contact_contact_form.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10.7 on 2017-05-11 08:01 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('home', '0017_auto_20170510_1627'), + ] + + operations = [ + migrations.AddField( + model_name='contact', + name='contact_form', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='home.ContactForm'), + ), + ] diff --git a/publichealth/home/models/snippets.py b/publichealth/home/models/snippets.py index 319e5e9..045d2a8 100644 --- a/publichealth/home/models/snippets.py +++ b/publichealth/home/models/snippets.py @@ -7,8 +7,9 @@ from django.db import models from wagtail.wagtailsnippets.models import register_snippet from wagtail.wagtailcore.models import Page -from wagtail.wagtailadmin.edit_handlers import FieldPanel +from wagtail.wagtailadmin.edit_handlers import FieldPanel, PageChooserPanel +from .forms import ContactForm from ..util import TranslatedField # List of supported social networks @@ -59,11 +60,19 @@ class Contact(models.Model): phone = models.CharField(max_length=40, default="") email = models.EmailField(max_length=100, default="") www = models.URLField(null=True, blank=True) + map_url = models.URLField(null=True, blank=True, help_text="Optional link of address to mapping provider") analytics = models.CharField(max_length=60, default="", blank=True, help_text="Optional web analytics property code") + contact_form = models.ForeignKey( + 'home.ContactForm', + null=True, blank=True, + on_delete=models.SET_NULL, + related_name='+', + ) + panels = Page.content_panels + [ FieldPanel('title_fr'), FieldPanel('address'), @@ -72,6 +81,7 @@ class Contact(models.Model): FieldPanel('www'), FieldPanel('map_url'), FieldPanel('analytics'), + PageChooserPanel('contact_form', 'home.ContactForm'), ] def phone_link(self): diff --git a/publichealth/home/templates/banner.html b/publichealth/home/templates/banner.html index 7475b16..c60f2b2 100644 --- a/publichealth/home/templates/banner.html +++ b/publichealth/home/templates/banner.html @@ -9,7 +9,7 @@ {{ entry.trans_title }} - {{ entry.trans_intro|richtext }} + {{ entry.trans_intro|richtext }} diff --git a/publichealth/home/templates/home/contact_form_landing.html b/publichealth/home/templates/home/contact_form_landing.html index c68f4b8..d56d479 100644 --- a/publichealth/home/templates/home/contact_form_landing.html +++ b/publichealth/home/templates/home/contact_form_landing.html @@ -6,10 +6,8 @@ {% block content %} - - {{ page.title }} - + {{ page.title }} {{ page.thanks|richtext }} diff --git a/publichealth/home/templates/home/home_page.html b/publichealth/home/templates/home/home_page.html index 575146a..4c5e3ff 100644 --- a/publichealth/home/templates/home/home_page.html +++ b/publichealth/home/templates/home/home_page.html @@ -1,8 +1,13 @@ {% extends "base.html" %} -{% load wagtailcore_tags %} +{% load static wagtailcore_tags %} {% block body_class %}template-{{ self.get_verbose_name|slugify }}{% endblock %} +{% block extra_css %} + + +{% endblock %} + {% block content %} diff --git a/publichealth/home/templates/tags/contact_form.html b/publichealth/home/templates/tags/contact_form.html deleted file mode 100644 index 157b8e7..0000000 --- a/publichealth/home/templates/tags/contact_form.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - Senden / Envoi - diff --git a/publichealth/home/templates/tags/contact_links.html b/publichealth/home/templates/tags/contact_links.html index 942d18d..e491d98 100644 --- a/publichealth/home/templates/tags/contact_links.html +++ b/publichealth/home/templates/tags/contact_links.html @@ -1,4 +1,4 @@ - + {% for sc in socials %} @@ -6,10 +6,16 @@ {% endfor %} - + {{ contact.phone }} - + {{ contact.email }} + + + + + + diff --git a/publichealth/home/templates/tags/footer_form.html b/publichealth/home/templates/tags/footer_form.html new file mode 100644 index 0000000..a85c6d3 --- /dev/null +++ b/publichealth/home/templates/tags/footer_form.html @@ -0,0 +1,16 @@ +{% load wagtailcore_tags %} +{% if form %} + + {% csrf_token %} + + + + + + + + + + Senden / Envoi + +{% endif %} diff --git a/publichealth/home/templatetags/information.py b/publichealth/home/templatetags/information.py index 564a230..6bebdc1 100644 --- a/publichealth/home/templatetags/information.py +++ b/publichealth/home/templatetags/information.py @@ -15,11 +15,12 @@ def contact_info(): } # Contact form (footer) -@register.inclusion_tag('tags/contact_form.html') -def contact_form(): - return { - 'contact': Contact.objects.last(), - } +@register.inclusion_tag('tags/footer_form.html') +def footer_form(): + if Contact.objects.last(): + return { + 'form': Contact.objects.last().contact_form, + } # Contact links (header) @register.inclusion_tag('tags/contact_links.html') diff --git a/publichealth/static/css/modules/_forms.scss b/publichealth/static/css/modules/_forms.scss index f63f55a..0d91356 100644 --- a/publichealth/static/css/modules/_forms.scss +++ b/publichealth/static/css/modules/_forms.scss @@ -28,6 +28,11 @@ border: 1px solid $gray-light; padding: 3px; } + + // Full width comment on mobile screens + @include max-screen($screen-xs-max) { + textarea { width: 100%; } + } } } diff --git a/publichealth/static/css/modules/_navbar.scss b/publichealth/static/css/modules/_navbar.scss index e656e6b..c4687b8 100644 --- a/publichealth/static/css/modules/_navbar.scss +++ b/publichealth/static/css/modules/_navbar.scss @@ -18,6 +18,13 @@ &.link { text-transform: uppercase; } + &:hover { + text-decoration: none; + } + } + .social-networks { + top: -1px; position: relative; + a { margin: 0 10px; } } } .language-nav { diff --git a/publichealth/static/images/favicon.ico b/publichealth/static/images/favicon.ico new file mode 100644 index 0000000..65a4fe6 Binary files /dev/null and b/publichealth/static/images/favicon.ico differ diff --git a/publichealth/templates/500.html b/publichealth/templates/500.html index 2a5be4c..3542ce4 100644 --- a/publichealth/templates/500.html +++ b/publichealth/templates/500.html @@ -1,8 +1,5 @@ - - - - + diff --git a/publichealth/templates/base.html b/publichealth/templates/base.html index df87e5f..7680ee9 100644 --- a/publichealth/templates/base.html +++ b/publichealth/templates/base.html @@ -1,11 +1,6 @@ {% load compress static wagtailuserbar %} - - - - - - + @@ -14,14 +9,15 @@ {% compress css %} - - + {% block extra_css %}{% endblock %} {% endcompress %} - {% block extra_css %} - - {% endblock %} + + diff --git a/publichealth/templates/footer.html b/publichealth/templates/footer.html index 45ce539..3bcb9e2 100644 --- a/publichealth/templates/footer.html +++ b/publichealth/templates/footer.html @@ -17,14 +17,14 @@ - + + + {% contact_info %} - diff --git a/publichealth/templates/header.html b/publichealth/templates/header.html index ca961e5..8b56123 100644 --- a/publichealth/templates/header.html +++ b/publichealth/templates/header.html @@ -5,7 +5,10 @@ - Kontakt + + + Contact + {% contact_links %} @@ -16,10 +19,9 @@ - - Toggle navigation + Navigation
{{ entry.trans_intro|richtext }}
{{ page.thanks|richtext }}