[Mpuls-commits] r1974 - wasko/branches/2.0/jmdweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Mar 16 12:52:56 CET 2010
Author: torsten
Date: 2010-03-16 12:52:56 +0100 (Tue, 16 Mar 2010)
New Revision: 1974
Modified:
wasko/branches/2.0/jmdweb/controllers/case_overview.py
Log:
* jmdweb/controllers/case_overview.py: Deleted code which was moved to
mpulsbase.
Modified: wasko/branches/2.0/jmdweb/controllers/case_overview.py
===================================================================
--- wasko/branches/2.0/jmdweb/controllers/case_overview.py 2010-03-16 11:51:15 UTC (rev 1973)
+++ wasko/branches/2.0/jmdweb/controllers/case_overview.py 2010-03-16 11:52:56 UTC (rev 1974)
@@ -37,22 +37,24 @@
from paste.httpexceptions import HTTPNotFound
from mpulsweb.lib.base import c, h, render, request, session
-from mpulsweb.controllers.case_overview import CaseOverviewController \
- as CaseBaseOverviewController
import mpulsweb.lib.helper.filters as F
-from jmdweb.lib.validators import SearchCaseForm, BundleActionForm, \
- SetBundleEditorForm, SetBundleStandinForm, CasePartSelectionForm
from mpulsweb.lib.security import checkRole
+from mpulsweb.model.user import UserListObject, UserObject, UserGroupList
+from mpulsweb.model.case import MpulsCaseOverview
+
+from mpulsweb.controllers.case_overview import CaseOverviewController \
+ as CaseBaseOverviewController, FORM_DEFAULTS_ADMIN, \
+ FORM_DEFAULTS_CM, parseSearchOptions
+
+from jmdweb.lib.validators import BundleActionForm, \
+ SetBundleEditorForm, SetBundleStandinForm, CasePartSelectionForm
from jmdweb.lib.search import INCONSISTENCY_CHECK_AFTER
from jmdweb.lib.exportselection import CasePartsSelection
-from jmdweb.model.case import CaseOverview, CaseBundle
-from mpulsweb.model.user import UserListObject, UserObject, UserGroupList
+from jmdweb.model.case import CaseBundle
-
log = logging.getLogger(__name__)
-
DIALOG_EMPTY_SELECTION = u'''Keine Fallakten ausgewählt.'''
DIALOG_EMPTY_SELECTION_EXPLAINATION = u'''\
Sie haben keine Fallakten ausgewählt für die Sie die gewählte Aktion
@@ -180,200 +182,9 @@
Bei dem Überprüfen der Validität ist einer Fehler aufgetreten. Klicken
Sie auf 'OK', um fortzufahren."""
-FORM_DEFAULTS_ADMIN = {
- 'show_own': '1',
- 'search_str': '',
- 'show_open': '0',
- 'show_markdelete': '1',
- 'show_markanonymize': '1',
- }
-
-FORM_DEFAULTS_CM = {
- 'show_own': '1',
- 'search_str': '',
- 'show_open': '1',
- }
-
-def parseSearchOptions(options=None):
- search_options = []
- user = session['USER_AUTHORIZED']
- if options.get('editor', '-1') != '-1':
- search_options.append('editor:%s' % options.get('editor'))
- if options.get('show_own') == '1':
- search_options.append('own:%s' % user.id)
- if options.get('show_other') == '1':
- search_options.append('standin:%s' % user.id)
- if options.get('show_open') == '1':
- search_options.append('state:%s' % 1)
- search_options.append('state:%s' % 2)
- if options.get('show_closed') == '1':
- search_options.append('state:%s' % 2)
- if options.get('show_markdelete') == '1':
- search_options.append('state:%s' % 3)
- if options.get('show_markanonymize') == '1':
- search_options.append('state:%s' % 4)
- if options.get('show_anonymized') == '1':
- search_options.append('state:%s' % 5)
- # For cm users show cases which are marked for anon too
- if h.hasRole(['cm_ka']):
- search_options.append('state:%s' % 4)
- if options.get('gender', '-2') != '-2':
- search_options.append('gender:%s' % options.get('gender'))
- if options.get('branch'):
- search_options.append('branch:%s' % options.get('branch'))
- if options.get('search_str'):
- search_options.append(options.get('search_str'))
-
- #Migration
- if options.get('migration', '-2') != '-2':
- search_options.append('migration:%s' % options.get('migration'))
-
- #cm-states
- cm_state = options.get('cm_state')
- phases = [] # default
- if cm_state:
- if cm_state == 'none':
- phases = []
- if cm_state == 'clearing':
- phases = [0,1]
- if cm_state == 'active':
- phases = [2]
- if cm_state == 'finished':
- phases = [3,4,5]
- if cm_state == 'all':
- phases = [-1,0,1,2,3,4,5]
- phases = '%s' % ";".join("phase:%s" % p for p in phases)
- if phases:
- search_options.append(phases)
-
- #check build time_interval
- year = options.get('year')
- quarter = options.get('quarter')
- if year != '-1' and year:
- q_start = "01-01"
- q_end = "12-31"
- if quarter == '1':
- q_end = "03-31"
- if quarter == '2':
- q_start = "04-01"
- q_end = "06-30"
- if quarter == '3':
- q_start = "07-01"
- q_end = "09-30"
- if quarter == '4':
- q_start = "10-01"
-
- search_options.append("interval_start_date:%s" % "-".join([year,
- q_start]))
- search_options.append("interval_end_date:%s" % "-".join([year, q_end]))
-
- return search_options
-
-def get_sort(params):
- sort = params.get('sort_field', 'id')
- order = params.get('sort_order', 'asc')
- return sort, order
-
-
class CaseOverviewController(CaseBaseOverviewController):
- #@checkRole(('admin_ka', 'cm_ka', 'pt_dlr'))
- #def index(self):
- # return self.overview()
-
- #@checkRole(('admin_ka', 'cm_ka', 'pt_dlr'))
- #def overview_extended(self):
- # extended = session.get('EXTENDED_SEARCH')
- # if extended is not None:
- # extended = not extended
- # else:
- # extended = True
- # session['EXTENDED_SEARCH'] = extended
- # session.save()
- # return self.overview()
-
@checkRole(('admin_ka', 'cm_ka', 'pt_dlr'))
- def overview(self):
- reset = self._checkBool(request.params.get('reset', '0'))
- sort_field, sort_order = get_sort(request.params)
- if reset:
- session['CASE_OVERVIEW_SEARCHOPTIONS'] = {}
- session['CASE_OVERVIEW_SELECTION'] = {}
- session['EXTENDED_SEARCH'] = False
- session.save()
-
- c.extended_search = session.get('EXTENDED_SEARCH', False)
- user = session['USER_AUTHORIZED']
-
- ulo = UserListObject()
- filter = [u.id for u in ulo.getAdminList()]
- c.userlist = ulo.getUserList(filter)
-
- # If the user is admin then he should see only cases which are
- # marked for deletion or anonymisation
- if user.isAdmin():
- FORM_DEFAULTS = FORM_DEFAULTS_ADMIN
- else:
- FORM_DEFAULTS = FORM_DEFAULTS_CM
-
- form_defaults = (session.get('CASE_OVERVIEW_SEARCHOPTIONS')
- or FORM_DEFAULTS)
- search_options = parseSearchOptions(form_defaults)
-
- # Sorting of the cases
- if sort_field == "name_1":
- search_options.append('sort_field:name')
- if sort_field == "vorname_1":
- search_options.append('sort_field:m.vorname')
- if sort_field == "zugriff":
- search_options.append('sort_field:zugriff')
- if sort_field == "kundennummer":
- search_options.append('sort_field:fn')
- if sort_field == "bearbeiter_id":
- search_options.append('sort_field:bearbeiter_id')
-
- if sort_order == "desc":
- search_options.append('sort_order:desc')
- else:
- search_options.append('sort_order:asc')
-
- search_str = ";".join(search_options)
-
- c.cases = CaseOverview()
- c.cases.search(search_str)
-
- #count num of cases
- c.count_all = len([x for x in c.cases.getDatasets()])
- c.count_own = len([x for x in c.cases.getDatasets()
- if x.getEditor().id == user.id])
- c.count_standin = c.count_all - c.count_own
- if h.hasRole(['cm_ka']):
- c.count_anon = len([x for x in c.cases.getDatasets()
- if x.getState().getState() in (4,5)])
- else:
- c.count_anon = len([x for x in c.cases.getDatasets()
- if x.getState().getState() == 5])
- c.count_markanon = len([x for x in c.cases.getDatasets()
- if x.getState().getState() == 4])
- c.count_del = len([x for x in c.cases.getDatasets()
- if x.getState().getState() == 3])
-
- # Load case-selection and merge with default search options
- # Ok please close your eyes now!!! This is.... well ugly
- form_defaults_copy = form_defaults.copy()
- form_defaults_copy.update(session.get('CASE_OVERVIEW_SELECTION', {}))
-
- # Hide evaluation option if someone did a search for a particular editor
- c.hide_evaluation = False
- expr = re.compile('.*editor:[0-9]+.*')
- if expr.match(search_str):
- c.hide_evaluation = True
-
- overview = render('/casemanagement/overview.mako')
- return formencode.htmlfill.render(unicode(overview, 'utf-8'),
- defaults=form_defaults_copy)
-
- @checkRole(('admin_ka', 'cm_ka', 'pt_dlr'))
def search(self):
validator = SearchCaseForm()
c.form_result = {}
@@ -414,7 +225,7 @@
or FORM_DEFAULTS)
search_str = ";".join(parseSearchOptions(search_options))
case_bundle = CaseBundle([case.id for case in
- CaseOverview().search(search_str)])
+ MpulsCaseOverview().search(search_str)])
else:
case_bundle = CaseBundle(form_result.get('case_id', []))
More information about the Mpuls-commits
mailing list