summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2018-12-23 10:51:40 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2018-12-23 10:51:40 (GMT)
commit4ff0e7a591b78a376bef8931ca2d9e099940f127 (patch)
tree4efb8f12a8257f5fb03034ba49a3a59a7f9a1898
parent52f51179c8c00b94c9ec2e6487ae9b55bdf6a8d2 (diff)
downloadpublik-client-scripts-4ff0e7a591b78a376bef8931ca2d9e099940f127.zip
publik-client-scripts-4ff0e7a591b78a376bef8931ca2d9e099940f127.tar.gz
publik-client-scripts-4ff0e7a591b78a376bef8931ca2d9e099940f127.tar.bz2
strasbourg: add script to push formdef data to elasticsearch
-rw-r--r--clients/strasbourg/index-formdefs-in-elasticsearch.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/clients/strasbourg/index-formdefs-in-elasticsearch.py b/clients/strasbourg/index-formdefs-in-elasticsearch.py
new file mode 100644
index 0000000..54a7914
--- /dev/null
+++ b/clients/strasbourg/index-formdefs-in-elasticsearch.py
@@ -0,0 +1,25 @@
+#! /usr/bin/env python
+#
+# run as:
+# sudo -u wcs wcsctl runscript index-formdefs-in-elasticsearch.py --vhost=...
+
+from elasticsearch import Elasticsearch
+
+import wcs
+from wcs.formdef import FormDef
+
+es = Elasticsearch([{'host': '46.18.194.18', 'port': 9200}])
+
+for formdef in FormDef.select():
+ if formdef.disabled and not formdef.disabled_redirection:
+ continue
+ url = formdef.get_url() if not formdef.disabled else formdef.disabled_redirection
+ es.index(index='liferay-20116',
+ doc_type='LiferayDocumentType',
+ id="wcs:formdef:%s" % formdef.id,
+ body={
+ 'title': formdef.name,
+ 'url': formdef.get_url(),
+ 'description': '',
+ 'type': 'procedure'
+ })