diff --git a/templates/theme.html b/templates/theme.html
index 969b7d9..2ac9380 100644
--- a/templates/theme.html
+++ b/templates/theme.html
@@ -45,7 +45,6 @@
@@ -74,8 +73,7 @@
- {% blurp "services" %}
- {% for item in menu %}
+ {% for item in services %}
- {{ item.title }}
{% if item.sub_items %}
{% endif %}
{% endfor %}
- {% endblurp %}
@@ -99,8 +96,7 @@
- {% blurp "acces-directs" %}
- {% for item in menu %}
+ {% for item in acces_directs %}
- {{ item.title }}
{% if item.sub_items %}
{% endif %}
{% endfor %}
- {% endblurp %}
@@ -122,8 +117,7 @@
- {% blurp "kiosque" %}
- {% for item in menu %}
+ {% for item in kiosque %}
- {{ item.title }}
{% if item.sub_items %}
{% endif %}
{% endfor %}
- {% endblurp %}
@@ -145,8 +138,7 @@
- {% blurp "grand-projets" %}
- {% for item in menu %}
+ {% for item in grand_projets %}
- {{ item.title }}
{% if item.sub_items %}
{% endif %}
{% endfor %}
- {% endblurp %}
diff --git a/update-vincennes-content.py b/update-vincennes-content.py
index a980eb3..eedebd7 100755
--- a/update-vincennes-content.py
+++ b/update-vincennes-content.py
@@ -1,12 +1,10 @@
#! /usr/bin/env python
-import os
+import json
import requests
-CACHE_DIR = '/var/cache/vincennes'
-
-if not os.path.exists(CACHE_DIR):
- os.mkdir(CACHE_DIR)
+from hobo.deploy.signals import notify_agents
+from hobo.environment.models import Variable
PARTS = ['menu', 'demarches', 'partenaires', 'agenda', 'magazine', 'autopromo',
'services', 'acces-directs', 'kiosque', 'grand-projets', 'actualites']
@@ -14,6 +12,12 @@ PARTS = ['menu', 'demarches', 'partenaires', 'agenda', 'magazine', 'autopromo',
for part in PARTS:
r = requests.get('https://www.vincennes.fr/api/data/(Element)/' + part)
r.raise_for_status()
- fd = file(os.path.join(CACHE_DIR, part), 'w')
- fd.write(r.content)
- fd.close()
+ variable, created = Variable.objects.get_or_create(
+ name=part.replace('-', '_'),
+ defaults={'auto': True})
+ if variable.json == r.json():
+ continue
+ variable.value = json.dumps(r.json())
+ variable.save()
+
+notify_agents(None)