Skip to content

Instantly share code, notes, and snippets.

View frague59's full-sized avatar

François GUÉRIN frague59

View GitHub Profile
@frague59
frague59 / search.py
Created November 6, 2015 09:03
search features with attachment supports
# -*- coding: utf-8 -*-
"""
Search features for an elasticsearch / haystack / elasticstack
:creationdate: 05/11/15 15:05
:moduleauthor: François GUÉRIN <fguerin@ville-tourcoing.fr>
:modulename: intrautils.search
"""
import base64
@frague59
frague59 / __init__.py
Created February 1, 2016 09:55
elasticsearch_index_settings
ELASTICSEARCH_INDEX_SETTINGS = {
'settings': {
'index': {
'number_of_shards': 6,
'analysis': {
'tokenizer': {
'haystack_ngram_tokenizer': {
'type': 'nGram',
'min_gram': 3,
'max_gram': 15,
[2016-02-01 10:37:01,526][DEBUG][action.admin.indices.mapping.put] [intranet] failed to put mappings on indices [[intranet_dev]], type [modelresult]
java.lang.NullPointerException
at org.elasticsearch.index.mapper.attachment.AttachmentMapper$TypeParser.findMapperBuilder(AttachmentMapper.java:302)
at org.elasticsearch.index.mapper.attachment.AttachmentMapper$TypeParser.parse(AttachmentMapper.java:326)
at org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseProperties(ObjectMapper.java:310)
at org.elasticsearch.index.mapper.object.ObjectMapper$TypeParser.parseObjectOrDocumentTypeProperties(ObjectMapper.java:223)
at org.elasticsearch.index.mapper.object.RootObjectMapper$TypeParser.parse(RootObjectMapper.java:139)
at org.elasticsearch.index.mapper.DocumentMapperParser.parse(DocumentMapperParser.java:140)
at org.elasticsearch.index.mapper.DocumentMapperParser.parseCompressed(DocumentMapperParser.java:121)
at org.elasticsearch.index.mapper.MapperService.parse(MapperService.java:391)
PUT intranet_dev/_mapping/modelresult
{
"properties": {
"document_file": {
"fields": {
"content_length": {
"type": "integer",
"store": "yes"
},
"language": "french",
# -*- coding: utf-8 -*-
"""
Search features for :
* :mod:`elasticsearch.elasticsearch`
* :mod:`haystack:haystack`
* :mod:`elasticstack:elasticstack`
:creationdate: 05/11/15 15:05
:moduleauthor: François GUÉRIN <fguerin@ville-tourcoing.fr>
@frague59
frague59 / edit.py
Created June 13, 2016 11:13
Formset mixin
class InlineFormsetMixin(SingleObjectTemplateResponseMixin, BaseFormsetMixin):
object = None
formset_link_field = None
def get_formset_kwargs(self):
"""
Gets the formset kwargs
:returns: dict of kwargs
"""
@frague59
frague59 / edit.py
Created June 13, 2016 11:16
BaseFormsetMixin
class BaseFormsetMixin(TemplateResponseMixin, FormMixin):
"""
Base formset mixin, which provide the use of a (model) form with an (inline) formset. This mixin can be used vith
an :class:`django:django.views.UpdateView` or a :class:`django:django.views.CreateView`
"""
formset_class = None
formset_visible_fields = None
formset_continuable = False
template_name = "base_form.html"
# Simple service unit to start / stop the scheduler.
# This unit has been mainly written to manage start of scheduler on reboot,
# but it can be used to stop / start the scheduler at any time.
# François GUÉRIN <fguerin@ville-tourcoing.fr> 2016
# WTFPL :)
[Unit]
Description=Phraseanet Scheduler Service
Documentation=https://docs.phraseanet.com/3.8/fr/Admin/MoteurDeTaches.html
Documentation=https://docs.phraseanet.com/3.8/en/Admin/TaskManager.html
@frague59
frague59 / widget.html
Created May 5, 2017 08:56
Updates to use __PREFIX__ template variable.
<!-- wagtailleaflet/templates/leaflet/widget.html -->
{% load leaflet_tags %}
{% load static from staticfiles %}
<style type="text/css">{% block map_css %}
{% if map_width and map_height %}#{{ id_map }} { width: {{ map_width }}; height: {{ map_height }}; }{% endif %}
{% if not display_raw %}#{{ id }} { display: none; }{% endif %}
{% endblock map_css %}
</style>
@frague59
frague59 / _leaflet_map.html
Created May 5, 2017 08:57
Updates to use __PREFIX__ TEMPLATE VARIABLE
{% load i18n %}
{% load static from staticfiles %}
{% if creatediv %}
<div id="{{ name }}" class="leaflet-container-default"></div>{% endif %}
<script type="text/javascript">
(function () {
window.DEBUG_LEAFLET && console.debug('_leaflet_map.html : name = ' + '{{ name }}');
function loadmap() {
window.DEBUG_LEAFLET && console.debug('_leaflet_map.html:loadmap()');