duplicate ocr settings for other document types
This commit is contained in:
parent
768f8c366e
commit
f10abf3afa
|
@ -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"
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Reference in New Issue