add settings for thesaurus
This commit is contained in:
parent
c550715605
commit
21397d21aa
|
@ -267,6 +267,56 @@
|
|||
|
||||
</dd>
|
||||
|
||||
<dt id="fieldsetlegend-topics">Topics settings</dt>
|
||||
<dd id="fieldset-topics">
|
||||
|
||||
<form
|
||||
name="topics"
|
||||
method="post"
|
||||
class="enableUnloadProtection"
|
||||
tal:attributes="action request/URL"
|
||||
tal:define="errors view/errors">
|
||||
|
||||
<div
|
||||
tal:define="error errors/topics | nothing;
|
||||
topics python:request.get('topics', view.settings.topics)"
|
||||
tal:attributes="class python:'field error' if error else 'field'">
|
||||
|
||||
<label for="topics" i18n:translate="label_topics">Topics</label>
|
||||
<div tal:content="error" tal:condition="error" />
|
||||
<textarea
|
||||
name="topics"
|
||||
id="topics"
|
||||
type="text"
|
||||
rows="20"
|
||||
cols="80"
|
||||
tal:content="topics"
|
||||
>...</textarea>
|
||||
</div>
|
||||
|
||||
<div class="formControls">
|
||||
<input
|
||||
type="submit"
|
||||
name="form.button.TopicsSave"
|
||||
class="context"
|
||||
value="Save"
|
||||
i18n:attributes="value" />
|
||||
|
||||
<input
|
||||
type="submit"
|
||||
name="form.button.Cancel"
|
||||
class="context"
|
||||
value="Cancel"
|
||||
i18n:attributes="value" />
|
||||
</div>
|
||||
|
||||
<input tal:replace="structure context/@@authenticator/authenticator" />
|
||||
|
||||
</form>
|
||||
|
||||
</dd>
|
||||
|
||||
|
||||
|
||||
<dt id="fieldsetlegend-greffier">Greffier settings</dt>
|
||||
<dd id="fieldset-greffier">
|
||||
|
|
|
@ -71,6 +71,11 @@ class TabellioControlpanel(BrowserView):
|
|||
submitted = True
|
||||
self.settings.sessions = form.get('sessions')
|
||||
|
||||
if 'form.button.TopicsSave' in form:
|
||||
self.authorize()
|
||||
submitted = True
|
||||
self.settings.topics = form.get('topics')
|
||||
|
||||
if 'form.button.GreffierSave' in form:
|
||||
self.authorize()
|
||||
submitted = True
|
||||
|
|
|
@ -51,6 +51,10 @@ class ITabellioSettings(Interface):
|
|||
title=_('sessions', 'Sessions'),
|
||||
required=False)
|
||||
|
||||
topics = schema.Text(
|
||||
title=_('topics', 'Topics'),
|
||||
required=False)
|
||||
|
||||
greffier_name = schema.Text(title=_(u'Greffier Name'), required=False)
|
||||
greffier_email = schema.Text(title=_(u'Greffier Email'), required=False)
|
||||
greffier_address_line1 = schema.Text(title=_(u'Greffier Address Line 1'), required=False)
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import time
|
||||
|
||||
from zope import component
|
||||
from plone.registry.interfaces import IRegistry
|
||||
from interfaces import ITabellioSettings
|
||||
from plone.memoize import ram
|
||||
|
||||
def get_dossiers_path():
|
||||
return component.getUtility(IRegistry).forInterface(ITabellioSettings, False).dossiersPath
|
||||
|
@ -24,6 +27,18 @@ def get_sessions():
|
|||
terms = [x.split(':')[1].strip() for x in sessions.splitlines() if x]
|
||||
return terms
|
||||
|
||||
@ram.cache(lambda *args: time.time() // (5 * 60)) # 5 minutes
|
||||
def get_topics_dict():
|
||||
from plone.i18n.normalizer.fr import normalizer
|
||||
settings = component.getUtility(IRegistry).forInterface(ITabellioSettings, False)
|
||||
if not settings.topics:
|
||||
return {}
|
||||
topics = {}
|
||||
for line in settings.topics.splitlines():
|
||||
id, term = line.strip().split('|')
|
||||
topics[id] = (term, normalizer.normalize(term).lower())
|
||||
return topics
|
||||
|
||||
def get_legisl_and_sessions():
|
||||
settings = component.getUtility(IRegistry).forInterface(ITabellioSettings, False)
|
||||
sessions = settings.sessions
|
||||
|
|
Reference in New Issue