diff --git a/.gitignore b/.gitignore index e4e23e8..60d6eb5 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ .DS_Store *.swp *.sqlite3 +/docker-compose.yml /env/ /venv/ /static/ diff --git a/Makefile b/Makefile index d550332..c747862 100644 --- a/Makefile +++ b/Makefile @@ -39,10 +39,18 @@ setup: release: docker-compose build web + docker-compose exec web ./manage.py collectstatic --noinput + docker-compose exec web ./manage.py compress docker-compose stop web docker-compose kill web docker-compose up -d web +reindex: + docker-compose exec web ./manage.py update_index + +clear_index: + docker-compose exec elasticsearch curl -XDELETE localhost:9200/_all + django-exec-bash: # execute bash in the currently running container docker-compose exec web bash diff --git a/README.md b/README.md index 5170a16..86db6f0 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,9 @@ Now access the admin panel with the user account you created earlier: http://loc We use [Ansible](https://www.ansible.com) and [Docker Compose](https://docs.docker.com/compose/reference/overview/) for automated deployment. -You need to obtain SSH and vault keys, and place these in a `.keys` folder - then to deploy a site: +To use Docker Compose to deploy the site, copy `ansible/roles/web/templates/docker-compose.j2` to `/docker-compose.yml` and fill in all `{{ variables }}`. This is done automatically in Ansible. + +To do production deployments, you need to obtain SSH and vault keys from your system administrator (who has followed the Ansible guide to set up a vault..), and place these in a `.keys` folder - then to deploy a site: ``` ansible-playbook -s ansible/<*.yaml> -i ansible/inventories/production diff --git a/ansible/roles/web/templates/docker-compose.j2 b/ansible/roles/web/templates/docker-compose.j2 index 88fe9a8..836bbd0 100644 --- a/ansible/roles/web/templates/docker-compose.j2 +++ b/ansible/roles/web/templates/docker-compose.j2 @@ -31,6 +31,6 @@ postgres: ports: - "5432:5432" elasticsearch: - image: orchardup/elasticsearch + image: elasticsearch:2 ports: - "9200:9200" diff --git a/publichealth/home/models/forms.py b/publichealth/home/models/forms.py index d0d2072..41e2f2c 100644 --- a/publichealth/home/models/forms.py +++ b/publichealth/home/models/forms.py @@ -2,17 +2,16 @@ from modelcluster.fields import ParentalKey -from wagtail.wagtailadmin.edit_handlers import ( - FieldPanel, FieldRowPanel, - InlinePanel, MultiFieldPanel -) - from django.db.models import CharField + from wagtail.wagtailcore.fields import RichTextField from wagtail.wagtailforms.models import ( AbstractEmailForm, AbstractFormField ) -from wagtail.wagtailsearch import index +from wagtail.wagtailadmin.edit_handlers import ( + FieldPanel, FieldRowPanel, + InlinePanel, MultiFieldPanel +) from ..util import TranslatedField @@ -23,8 +22,6 @@ class ContactForm(AbstractEmailForm): intro = RichTextField(default='', blank=True) thanks = RichTextField(default='', blank=True) - search_fields = [ index.SearchField('intro') ] - content_panels = AbstractEmailForm.content_panels + [ FieldPanel('intro', classname="full"), FieldPanel('thanks', classname="full"), diff --git a/publichealth/home/models/models.py b/publichealth/home/models/models.py index 3fde000..03c4c55 100644 --- a/publichealth/home/models/models.py +++ b/publichealth/home/models/models.py @@ -112,12 +112,12 @@ class ArticlePage(Page): ) search_fields = Page.search_fields + [ - index.SearchField('body_de'), - index.SearchField('body_fr'), - index.SearchField('title'), - index.SearchField('title_fr'), - index.SearchField('intro_de'), - index.SearchField('intro_fr'), + index.SearchField('title', partial_match=True, boost=10), + index.SearchField('title_fr', partial_match=True, boost=10), + index.SearchField('body_de', partial_match=True), + index.SearchField('body_fr', partial_match=True), + index.SearchField('intro_de', partial_match=True), + index.SearchField('intro_fr', partial_match=True), ] content_panels = [ MultiFieldPanel([ diff --git a/publichealth/home/templates/home/article_content.html b/publichealth/home/templates/home/article_content.html index 459d358..d8b778d 100644 --- a/publichealth/home/templates/home/article_content.html +++ b/publichealth/home/templates/home/article_content.html @@ -40,9 +40,9 @@ {{ block.value.summary|richtext }} {% if block.value.action %} - + {% endif %} {% endif %} diff --git a/publichealth/home/templatetags/navigation.py b/publichealth/home/templatetags/navigation.py index 5bd7d5e..7ea6d0f 100644 --- a/publichealth/home/templatetags/navigation.py +++ b/publichealth/home/templatetags/navigation.py @@ -7,10 +7,12 @@ register = template.Library() # Language switcher @register.inclusion_tag('tags/language.html', takes_context=True) def language_switcher(context): - url = context['page'].url.split('/') - if len(url) > 2 and len(url[1]) >= 2: - url[1] = '$lang$' - url = '/'.join(url) + url = '/$lang$' + if 'page' in context: + url = context['page'].url.split('/') + if len(url) > 2 and len(url[1]) >= 2: + url[1] = '$lang$' + url = '/'.join(url) return { 'languages': [ { 'code': 'de', 'title': 'De', 'url': url.replace('$lang$','de') }, diff --git a/publichealth/search/templates/search/search.html b/publichealth/search/templates/search/search.html index faa5d37..93f36c2 100644 --- a/publichealth/search/templates/search/search.html +++ b/publichealth/search/templates/search/search.html @@ -10,7 +10,7 @@