summaryrefslogtreecommitdiffstats
path: root/themis
diff options
context:
space:
mode:
authorFrédéric Péters <fpeters@entrouvert.com>2012-07-18 11:45:17 (GMT)
committerFrédéric Péters <fpeters@entrouvert.com>2012-07-18 11:45:17 (GMT)
commitf10abf3afaeb3ff5ccb46f099585ec64d08585d4 (patch)
tree10abbb15f80f9183c6dad8cc1e6fcaf018ff91ab /themis
parent768f8c366e7f75d0aa8a102ef7f0d0ea4c6e6495 (diff)
downloadthemis.config-f10abf3afaeb3ff5ccb46f099585ec64d08585d4.zip
themis.config-f10abf3afaeb3ff5ccb46f099585ec64d08585d4.tar.gz
themis.config-f10abf3afaeb3ff5ccb46f099585ec64d08585d4.tar.bz2
duplicate ocr settings for other document types
Diffstat (limited to 'themis')
-rw-r--r--themis/config/controlpanel.pt114
-rw-r--r--themis/config/controlpanel.py7
-rw-r--r--themis/config/interfaces.py8
-rw-r--r--themis/config/utils.py20
4 files changed, 143 insertions, 6 deletions
diff --git a/themis/config/controlpanel.pt b/themis/config/controlpanel.pt
index 6621e9b..215acd1 100644
--- a/themis/config/controlpanel.pt
+++ b/themis/config/controlpanel.pt
@@ -101,11 +101,14 @@
tal:attributes="action request/URL"
tal:define="errors view/errors">
+ <h3>Courriers entrants</h3>
+
<div
tal:define="error errors/incoming_mails_path | nothing;
incoming_mails_path python:request.get('incoming_mails_path', view.settings.incoming_mails_path)"
tal:attributes="class python:'field error' if error else 'field'">
+
<label for="incoming_mails_path" i18n:translate="label_incoming_mails_path">Incoming Mails Path</label>
<div tal:content="error" tal:condition="error" />
<input
@@ -134,6 +137,117 @@
>...</textarea>
</div>
+ <h3>Courriers sortants</h3>
+
+ <div
+ tal:define="error errors/outgoing_mails_path | nothing;
+ outgoing_mails_path python:request.get('outgoing_mails_path', view.settings.outgoing_mails_path)"
+ tal:attributes="class python:'field error' if error else 'field'">
+
+
+ <label for="outgoing_mails_path">Chemin</label>
+ <div tal:content="error" tal:condition="error" />
+ <input
+ name="outgoing_mails_path"
+ id="outgoing_mails_path"
+ type="text"
+ size="80"
+ tal:attributes="value outgoing_mails_path"
+ />
+ </div>
+
+ <div
+ tal:define="error errors/ocr_code_outgoing_mails_mapping | nothing;
+ ocr_code_outgoing_mails_mapping python:request.get('ocr_code_outgoing_mails_mapping', view.settings.ocr_code_outgoing_mails_mapping)"
+ tal:attributes="class python:'field error' if error else 'field'">
+
+ <label for="ocr_code_outgoing_mails_mapping" i18n:translate="label_ocr_code_outgoing_mails_mapping">OCR Code Mapping</label>
+ <div tal:content="error" tal:condition="error" />
+ <textarea
+ name="ocr_code_outgoing_mails_mapping"
+ id="ocr_code_outgoing_mails_mapping"
+ type="text"
+ rows="20"
+ cols="80"
+ tal:content="ocr_code_outgoing_mails_mapping"
+ >...</textarea>
+ </div>
+
+
+ <h3>Documents internes</h3>
+
+ <div
+ tal:define="error errors/internal_documents_path | nothing;
+ internal_documents_path python:request.get('internal_documents_path', view.settings.internal_documents_path)"
+ tal:attributes="class python:'field error' if error else 'field'">
+
+
+ <label for="internal_documents_path">Chemin</label>
+ <div tal:content="error" tal:condition="error" />
+ <input
+ name="internal_documents_path"
+ id="internal_documents_path"
+ type="text"
+ size="80"
+ tal:attributes="value internal_documents_path"
+ />
+ </div>
+
+ <div
+ tal:define="error errors/ocr_code_internal_documents_mapping | nothing;
+ ocr_code_internal_documents_mapping python:request.get('ocr_code_internal_documents_mapping', view.settings.ocr_code_internal_documents_mapping)"
+ tal:attributes="class python:'field error' if error else 'field'">
+
+ <label for="ocr_code_internal_documents_mapping" i18n:translate="label_ocr_code_internal_documents_mapping">OCR Code Mapping</label>
+ <div tal:content="error" tal:condition="error" />
+ <textarea
+ name="ocr_code_internal_documents_mapping"
+ id="ocr_code_internal_documents_mapping"
+ type="text"
+ rows="20"
+ cols="80"
+ tal:content="ocr_code_internal_documents_mapping"
+ >...</textarea>
+ </div>
+
+
+ <h3>Documents confidentiels</h3>
+
+ <div
+ tal:define="error errors/confidential_documents_path | nothing;
+ confidential_documents_path python:request.get('confidential_documents_path', view.settings.confidential_documents_path)"
+ tal:attributes="class python:'field error' if error else 'field'">
+
+
+ <label for="confidential_documents_path">Chemin</label>
+ <div tal:content="error" tal:condition="error" />
+ <input
+ name="confidential_documents_path"
+ id="confidential_documents_path"
+ type="text"
+ size="80"
+ tal:attributes="value confidential_documents_path"
+ />
+ </div>
+
+ <div
+ tal:define="error errors/ocr_code_confidential_documents_mapping | nothing;
+ ocr_code_confidential_documents_mapping python:request.get('ocr_code_confidential_documents_mapping', view.settings.ocr_code_confidential_documents_mapping)"
+ tal:attributes="class python:'field error' if error else 'field'">
+
+ <label for="ocr_code_confidential_documents_mapping" i18n:translate="label_ocr_code_confidential_documents_mapping">OCR Code Mapping</label>
+ <div tal:content="error" tal:condition="error" />
+ <textarea
+ name="ocr_code_confidential_documents_mapping"
+ id="ocr_code_confidential_documents_mapping"
+ type="text"
+ rows="20"
+ cols="80"
+ tal:content="ocr_code_confidential_documents_mapping"
+ >...</textarea>
+ </div>
+
+
<div class="formControls">
<input
type="submit"
diff --git a/themis/config/controlpanel.py b/themis/config/controlpanel.py
index 726f1e2..bcecbb7 100644
--- a/themis/config/controlpanel.py
+++ b/themis/config/controlpanel.py
@@ -48,8 +48,15 @@ class ThemisControlpanel(BrowserView):
if 'form.button.OcrSave' in form:
self.authorize()
submitted = True
+
self.settings.ocr_code_mapping = form.get('ocr_code_mapping')
+ self.settings.ocr_code_outgoing_mails_mapping = form.get('ocr_code_outgoing_mails_mapping')
+ self.settings.ocr_code_internal_documents_mapping = form.get('ocr_code_internal_documents_mapping')
+ self.settings.ocr_code_confidential_documents_mapping = form.get('ocr_code_confidential_documents_mapping')
self.settings.incoming_mails_path = form.get('incoming_mails_path')
+ self.settings.outgoing_mails_path = form.get('outgoing_mails_path')
+ self.settings.internal_documents_path = form.get('internal_documents_path')
+ self.settings.confidential_documents_path = form.get('confidential_documents_path')
if submitted and not self.errors:
self._setup()
diff --git a/themis/config/interfaces.py b/themis/config/interfaces.py
index a44cfe1..e873054 100644
--- a/themis/config/interfaces.py
+++ b/themis/config/interfaces.py
@@ -12,6 +12,12 @@ class IThemisSettings(Interface):
documents_path = schema.TextLine(title=_(u'Documents Path'), required=False)
- incoming_mails_path = schema.TextLine(title=_(u'Documents Path'), required=False)
+ incoming_mails_path = schema.TextLine(title=_(u'Incoming Mails Path'), required=False)
+ outgoing_mails_path = schema.TextLine(title=_(u'Outgoing Mails Path'), required=False)
+ internal_documents_path = schema.TextLine(title=_(u'Internal Documents Path'), required=False)
+ confidential_documents_path = schema.TextLine(title=_(u'Confidential Documents Path'), required=False)
ocr_code_mapping = schema.Text(title=_(u'OCR Code Mapping'), required=False)
+ ocr_code_outgoing_mails_mapping = schema.Text(title=_(u'OCR Code Mapping (Outgoing Mails)'), required=False)
+ ocr_code_internal_documents_mapping = schema.Text(title=_(u'OCR Code Mapping (Internal Documents)'), required=False)
+ ocr_code_confidential_documents_mapping = schema.Text(title=_(u'OCR Code Mapping (Confidential Documents)'), required=False)
diff --git a/themis/config/utils.py b/themis/config/utils.py
index 643eb28..0985f67 100644
--- a/themis/config/utils.py
+++ b/themis/config/utils.py
@@ -24,19 +24,29 @@ def get_document_location_for_mail(mail):
settings = component.getUtility(IRegistry).forInterface(IThemisSettings, False)
return settings.documents_path
-def get_incoming_mails_location():
+def get_ocr_location(doctype):
settings = component.getUtility(IRegistry).forInterface(IThemisSettings, False)
- return settings.incoming_mails_path
+ return getattr(settings, doctype+'_path')
-def get_mail_categories_from_ocr_code(ocr_code):
+def get_categories_from_ocr_code(ocr_code, doctype):
+ mapping_name = 'ocr_code_%s_mapping' % doctype
+ if mapping_name == 'ocr_code_incoming_mails_mapping':
+ mapping_name = 'ocr_code_mapping'
settings = component.getUtility(IRegistry).forInterface(IThemisSettings, False)
- mapping = settings.ocr_code_mapping
+ mapping = getattr(settings, mapping_name)
+ if mapping is None:
+ mapping = ''
for line in mapping.splitlines():
if not line:
continue
if line.startswith('#'):
continue
- code, category, subcategory = line.strip().split('|')
+ if line.count('|') == 2:
+ code, category, subcategory = line.strip().split('|')
+ elif line.count('|') == 1:
+ code, category = line.strip().split('|')
+ subcategory = None
if code == ocr_code:
return category, subcategory
return None
+