[Mpuls-commits] r1993 - in wasko/branches/2.0: . jmdweb/model mpulsweb/model
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed Mar 17 12:20:31 CET 2010
Author: torsten
Date: 2010-03-17 12:20:30 +0100 (Wed, 17 Mar 2010)
New Revision: 1993
Modified:
wasko/branches/2.0/ChangeLog
wasko/branches/2.0/jmdweb/model/case.py
wasko/branches/2.0/mpulsweb/model/case.py
Log:
Moved Parts of CaseList and CaseBundle into mpulsweb
Modified: wasko/branches/2.0/ChangeLog
===================================================================
--- wasko/branches/2.0/ChangeLog 2010-03-17 11:18:46 UTC (rev 1992)
+++ wasko/branches/2.0/ChangeLog 2010-03-17 11:20:30 UTC (rev 1993)
@@ -18,6 +18,9 @@
* mpulsweb/templates/casemanagement/overview.mako: Show export options
only if they are enabled in config
* jmd.json: Disable caseexport in jmd-config.
+ * mpulsweb/model/case.py,
+ jmdweb/model/case.py: Moved CaseList and Parts of CaseBundle into
+ mpulsweb
2010-03-16 Torsten Irländer <torsten.irlaender at intevation.de>
Modified: wasko/branches/2.0/jmdweb/model/case.py
===================================================================
--- wasko/branches/2.0/jmdweb/model/case.py 2010-03-17 11:18:46 UTC (rev 1992)
+++ wasko/branches/2.0/jmdweb/model/case.py 2010-03-17 11:20:30 UTC (rev 1993)
@@ -47,7 +47,8 @@
from mpulsweb.model.user import UserObject
from mpulsweb.model.agencysettings import Agency
from mpulsweb.model.document import listDocuments
-from mpulsweb.model.case import MpulsCase, MpulsCaseFactory, MpulsCaseOverview
+from mpulsweb.model.case import MpulsCase, MpulsCaseFactory, MpulsCaseOverview, \
+ MpulsCaseBundle
#from jmdweb.lib.csv import exportAsCSV
#from jmdweb.lib.excel import exportAsXLS
@@ -116,123 +117,8 @@
ANONYMIZE_CASE = """SELECT anonymize_case_wrapper(%(id)s)"""
-class CaseList:
+class CaseBundle(MpulsCaseBundle):
- def __init__(self, case_ids=None):
- self.case_list = case_ids or []
-
- def listDatasetIds(self):
- return self.case_list
-
- def isEmpty(self):
- return len(self.case_list) == 0
-
- def numDatasets(self):
- return len(self.case_list)
-
- def getCases(self, filter=None):
- list = []
- if filter:
- cases = [id for id in self.case_list if id not in filter]
- else:
- cases = self.case_list
- for id in cases:
- list.append(g.case_factory.loadById(id))
- return list
-
-
-class CaseBundle(CaseList):
-
- def __init__(self, case_ids=None):
- CaseList.__init__(self, case_ids)
-
- def setEditor(self, user_id):
- factory = g.case_factory
- num = 0
- for id in self.case_list:
- case = factory.loadById(id)
- try:
- case.setEditor(user_id)
- num += 1
- except:
- print >> sys.stderr, "Could not set editor for case in bundle"
- return num
-
- def setStandin(self, group_ids):
- factory = g.case_factory
- num = 0
- for id in self.case_list:
- case = factory.loadById(id)
- try:
- standin = case.getStandin()
- standin.setGroups(group_ids)
- num += 1
- except:
- print >> sys.stderr, "Could not set standin for case in bundle"
- return num
-
- def delete(self):
- factory = g.case_factory
- num = 0
- for id in self.case_list:
- case = factory.loadById(id)
- try:
- case.delete()
- num += 1
- except:
- print >> sys.stderr, "Could not delete Case from bundle"
- return num
-
- def anonymize(self):
- factory = g.case_factory
- num = 0
- for id in self.case_list:
- case = factory.loadById(id)
- try:
- case.anonymize()
- num += 1
- except:
- print >> sys.stderr, "Could not anonymize Case from bundle"
- return num
-
- def restore(self):
- factory = g.case_factory
- num = 0
- for id in self.case_list:
- case = factory.loadById(id)
- try:
- case.restore()
- num += 1
- except StandardError, e:
- print >> sys.stderr, "Could not restore case in bundle: %s" % e
- return num
-
- def markAnonymize(self):
- factory = g.case_factory
- num = 0
- for id in self.case_list:
- case = factory.loadById(id)
- try:
- case.getState().setState(4)
- num += 1
- except:
- print >> sys.stderr, \
- "Could not mark case for anonymisation in bundle"
- return num
-
- def markDelete(self):
- factory = g.case_factory
- num = 0
- for id in self.case_list:
- case = factory.loadById(id)
- try:
- state = case.getState()
- state.setState(3)
- num += 1
- except:
- print >> sys.stderr, "Could not mark Case to delete from bundle"
- return num
-
def exportAsCSV(self, case_parts=None, anonymize=False):
con, cur = None, None
f = StringIO.StringIO()
Modified: wasko/branches/2.0/mpulsweb/model/case.py
===================================================================
--- wasko/branches/2.0/mpulsweb/model/case.py 2010-03-17 11:18:46 UTC (rev 1992)
+++ wasko/branches/2.0/mpulsweb/model/case.py 2010-03-17 11:20:30 UTC (rev 1993)
@@ -199,7 +199,126 @@
value = ensure_unicode(value)
return value
+class MpulsCaseList:
+ def __init__(self, case_ids=None):
+ self.case_list = case_ids or []
+
+ def listDatasetIds(self):
+ return self.case_list
+
+ def isEmpty(self):
+ return len(self.case_list) == 0
+
+ def numDatasets(self):
+ return len(self.case_list)
+
+ def getCases(self, filter=None):
+ list = []
+ if filter:
+ cases = [id for id in self.case_list if id not in filter]
+ else:
+ cases = self.case_list
+ for id in cases:
+ list.append(g.case_factory.loadById(id))
+ return list
+
+class MpulsCaseBundle(MpulsCaseList):
+
+ def __init__(self, case_ids=None):
+ MpulsCaseList.__init__(self, case_ids)
+
+ def setEditor(self, user_id):
+ factory = g.case_factory
+ num = 0
+ for id in self.case_list:
+ case = factory.loadById(id)
+ try:
+ case.setEditor(user_id)
+ num += 1
+ except:
+ print >> sys.stderr, "Could not set editor for case in bundle"
+ return num
+
+ def setStandin(self, group_ids):
+ factory = g.case_factory
+ num = 0
+ for id in self.case_list:
+ case = factory.loadById(id)
+ try:
+ standin = case.getStandin()
+ standin.setGroups(group_ids)
+ num += 1
+ except:
+ print >> sys.stderr, "Could not set standin for case in bundle"
+ return num
+
+ def delete(self):
+ factory = g.case_factory
+ num = 0
+ for id in self.case_list:
+ case = factory.loadById(id)
+ try:
+ case.delete()
+ num += 1
+ except:
+ print >> sys.stderr, "Could not delete Case from bundle"
+ return num
+
+ def anonymize(self):
+ factory = g.case_factory
+ num = 0
+ for id in self.case_list:
+ case = factory.loadById(id)
+ try:
+ case.anonymize()
+ num += 1
+ except:
+ print >> sys.stderr, "Could not anonymize Case from bundle"
+ return num
+
+ def restore(self):
+ factory = g.case_factory
+ num = 0
+ for id in self.case_list:
+ case = factory.loadById(id)
+ try:
+ case.restore()
+ num += 1
+ except StandardError, e:
+ print >> sys.stderr, "Could not restore case in bundle: %s" % e
+ return num
+
+ def markAnonymize(self):
+ factory = g.case_factory
+ num = 0
+ for id in self.case_list:
+ case = factory.loadById(id)
+ try:
+ case.getState().setState(4)
+ num += 1
+ except:
+ print >> sys.stderr, \
+ "Could not mark case for anonymisation in bundle"
+ return num
+
+ def markDelete(self):
+ factory = g.case_factory
+ num = 0
+ for id in self.case_list:
+ case = factory.loadById(id)
+ try:
+ state = case.getState()
+ state.setState(3)
+ num += 1
+ except:
+ print >> sys.stderr, "Could not mark Case to delete from bundle"
+ return num
+
+
+
+
+
class MpulsCase:
def __init__(self, id=None, preset=None):
More information about the Mpuls-commits
mailing list