[Mpuls-commits] r5710 - base/trunk/mpulsweb/lib
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Thu Dec 15 12:34:42 CET 2011
Author: torsten
Date: 2011-12-15 12:34:41 +0100 (Thu, 15 Dec 2011)
New Revision: 5710
Modified:
base/trunk/mpulsweb/lib/dialogs.py
Log:
Added new docorator which checks if the sync-permission of the case is set and
not unclear. Check is only done if the privacy-statement is signed and the
meta-server is enabled.
Modified: base/trunk/mpulsweb/lib/dialogs.py
===================================================================
--- base/trunk/mpulsweb/lib/dialogs.py 2011-12-15 11:32:51 UTC (rev 5709)
+++ base/trunk/mpulsweb/lib/dialogs.py 2011-12-15 11:34:41 UTC (rev 5710)
@@ -66,7 +66,54 @@
raise
return decorator(validate)
+def checkSyncPermission(context='select'):
+ '''Decorator for the methods in the case controller'''
+ def validate(func, self, *args, **kwargs):
+ if not g.mpuls_config.is_enabled('case-module', 'meta-server'):
+ log.debug('Meta-Server disabled... No checks on syn permission done')
+ return func(self, *args, **kwargs)
+ #load case and check if the sync permission is set
+ try:
+ if context == "showAppointment":
+ try:
+ app_id = int(args[0])
+ confirmed = int(args[1])
+ except:
+ raise HTTPNotFound()
+ app_factory = CaseAppointmentFactory()
+ app = app_factory.loadById(app_id)
+ case_id = app.case_id
+ c.targeturl = url_for(controller="/caseappointment",
+ action="show",
+ id=app_id, confirmed=1)
+ else:
+ try:
+ case_id = int(args[0])
+ confirmed = int(args[1])
+ except:
+ raise HTTPNotFound()
+ c.targeturl = url_for(controller="/case", action=context,
+ id=case_id, confirmed=1)
+ case = g.case_factory.loadById(case_id)
+ meta = case.getMeta()
+ statement = case.getPrivacyStatement()
+ # Only check if there is a "Syncpermission" if the Privacy
+ # statement is set and the meta-serber is enabled. None if it is
+ # not either signed or declined
+ if (statement.isSigned()
+ and meta.is_sync_allowed() is not None
+ or (confirmed == 1)):
+ return func(self, *args, **kwargs)
+ else:
+ c.ds_id = case_id
+ return render('/privacy/dialogs/missing_syncpermission.mako')
+ except:
+ log.exception('Fehler in der Validierung')
+ raise
+ return decorator(validate)
+
+
# FUTURE CONFIRM DIALOG
# ---------------------
# Not used yet. Use this confirm decaorator in future to set up general
More information about the Mpuls-commits
mailing list