[Mpuls-commits] r5560 - in base/trunk/mpulsweb: controllers model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Nov 8 17:45:34 CET 2011
Author: bh
Date: 2011-11-08 17:45:32 +0100 (Tue, 08 Nov 2011)
New Revision: 5560
Modified:
base/trunk/mpulsweb/controllers/case.py
base/trunk/mpulsweb/model/case.py
Log:
Only import logbook or documents from XML if the features are enabled.
This involves two parts: The MPulsXMLImporter constructor has two new
parameters that can be used to switch on support for logbook and
document import independently, and the caller is extended to pass the
correct values for those new paramers, depending on whether the
application supports documents or the logbook at all.
Modified: base/trunk/mpulsweb/controllers/case.py
===================================================================
--- base/trunk/mpulsweb/controllers/case.py 2011-11-08 14:11:53 UTC (rev 5559)
+++ base/trunk/mpulsweb/controllers/case.py 2011-11-08 16:45:32 UTC (rev 5560)
@@ -687,9 +687,15 @@
@checkRole('cm')
def importXMLAction(self):
try:
+ allow_documents = g.mpuls_config.is_enabled('case-module',
+ 'documents')
+ allow_logbook = g.mpuls_config.is_enabled('case-module', 'logbook')
+ importer = MPulsXMLImporter(g.formedTree,
+ allow_logbook=allow_logbook,
+ allow_documents=allow_documents)
+
xmlfile = request.POST['xmlfile']
try:
- importer = MPulsXMLImporter(g.formedTree)
importer.import_xml(PostgresDBInterface(), xmlfile.file)
finally:
xmlfile.file.close()
Modified: base/trunk/mpulsweb/model/case.py
===================================================================
--- base/trunk/mpulsweb/model/case.py 2011-11-08 14:11:53 UTC (rev 5559)
+++ base/trunk/mpulsweb/model/case.py 2011-11-08 16:45:32 UTC (rev 5560)
@@ -1472,11 +1472,14 @@
WHERE m.uuid_id = %(uuid)s
"""
- def __init__(self, meta_tree, extra_factories=None):
+ def __init__(self, meta_tree, extra_factories=None,
+ allow_logbook=False, allow_documents=False):
if extra_factories is None:
extra_factories = dict()
- extra_factories["tagebuch"] = get_logbook_import_factory()
- extra_factories["anlagen"] = get_documents_import_factory()
+ if allow_logbook:
+ extra_factories["tagebuch"] = get_logbook_import_factory()
+ if allow_documents:
+ extra_factories["anlagen"] = get_documents_import_factory()
DBXMLImporter.__init__(self, meta_tree, extra_factories)
self.imported_ids = []
More information about the Mpuls-commits
mailing list