[Mpuls-commits] r5372 - in base/trunk/mpulsweb: controllers lib

scm-commit@wald.intevation.org scm-commit at wald.intevation.org
Tue Sep 20 11:34:16 CEST 2011


Author: torsten
Date: 2011-09-20 11:34:15 +0200 (Tue, 20 Sep 2011)
New Revision: 5372

Modified:
   base/trunk/mpulsweb/controllers/meta.py
   base/trunk/mpulsweb/lib/metaclient.py
Log:
search_cases_by_hash now return a tuple of list of found cases and the number
of remaining open searches. The number of open searches is used to display a
warning if there are less then X trys reamining or display a Dialog informing
the user that the meta-user has been deactivated.


Modified: base/trunk/mpulsweb/controllers/meta.py
===================================================================
--- base/trunk/mpulsweb/controllers/meta.py	2011-09-19 15:03:18 UTC (rev 5371)
+++ base/trunk/mpulsweb/controllers/meta.py	2011-09-20 09:34:15 UTC (rev 5372)
@@ -20,10 +20,8 @@
 from mpulsweb.model.meta import MetaException, get_meta_client
 from mpulsweb.model.agencysettings import Agency
 
-
 log = logging.getLogger(__name__)
 
-
 def generate_hash(birthname, firstname, birthdate, gender):
     '''Return hash build from birthname, firstname, birthdate and gender'''
     hashsrc = ":".join([str(len(birthname)), str(len(firstname)),
@@ -212,6 +210,9 @@
         form_defaults = validator.from_python(c.case.getHashFields())
         form = render('meta/search.mako')
         c.fields = []
+        # NOTE: Think about showing remaining open searches here. This will
+        # require a request to the server but IMO ist would be a big plus for
+        # useablility.
         return formencode.htmlfill.render(form, defaults=form_defaults,
                                           auto_insert_errors=False,
                                           errors={})
@@ -238,9 +239,21 @@
             session.save()
 
             form_defaults = validator.from_python(form_result)
+            c.result, c.remaining_searches = \
+                get_meta_client().search_cases_by_hash(hash)
+            c.show_create = True
+            if c.remaining_searches <= 0:
+                return error(header=_("Meta user disabled!"),
+                             text=_("The meta user has been disabled "
+                             "to prevent misuse of the meta-search. "
+                             "Connections to the meta-serve are not "
+                             "possible from now on. Please contact the "
+                             "administration of the meta-server to "
+                             "reactivate your account."),
+                             url_ok=url_for(controller="/meta", 
+                                            action="index", 
+                                            id = c.case.id))
 
-            c.result = get_meta_client().search_cases_by_hash(hash)
-            c.show_create = True
         except formencode.Invalid, exc:
             form_defaults = exc.value
             form_errors = exc.error_dict or {}

Modified: base/trunk/mpulsweb/lib/metaclient.py
===================================================================
--- base/trunk/mpulsweb/lib/metaclient.py	2011-09-19 15:03:18 UTC (rev 5371)
+++ base/trunk/mpulsweb/lib/metaclient.py	2011-09-20 09:34:15 UTC (rev 5372)
@@ -290,8 +290,12 @@
         """
         json = self.perform_get_request("/meta/cases/hash/%s" % hash)
         parsed = simplejson.loads(json)
-        return parsed["cases"]
+        return parsed.get("cases", []), parsed.get("remaining_searches", 0)
 
+    def disable_meta_user(self):
+        """Will disable login of the meta-user on the meta-server"""
+        return self.perform_get_request("/meta/user/disable")
+
     def meta_case_as_html(self, uuid):
         """Return the meta dataset for the given uuid.
         The return value is a string containing the dataset rendered as



More information about the Mpuls-commits mailing list