[Mpuls-commits] r1979 - wasko/branches/2.0/mpulsweb/controllers
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Tue Mar 16 16:07:22 CET 2010
Author: torsten
Date: 2010-03-16 16:07:22 +0100 (Tue, 16 Mar 2010)
New Revision: 1979
Modified:
wasko/branches/2.0/mpulsweb/controllers/case_overview.py
Log:
Fixed case_overview.py
Modified: wasko/branches/2.0/mpulsweb/controllers/case_overview.py
===================================================================
--- wasko/branches/2.0/mpulsweb/controllers/case_overview.py 2010-03-16 15:06:32 UTC (rev 1978)
+++ wasko/branches/2.0/mpulsweb/controllers/case_overview.py 2010-03-16 15:07:22 UTC (rev 1979)
@@ -31,81 +31,6 @@
order = params.get('sort_order', 'asc')
return sort, order
-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
-
class CaseOverviewController(BaseController):
@checkRole(('admin', 'cm', 'pt_dlr'))
@@ -126,7 +51,6 @@
@checkRole(('admin', 'cm', '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'] = {}
@@ -149,25 +73,10 @@
form_defaults = (session.get('CASE_OVERVIEW_SEARCHOPTIONS')
or FORM_DEFAULTS)
- search_options = parseSearchOptions(form_defaults)
+ search_options = self.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_options.extend(self.parseSortOptions(request.params))
search_str = ";".join(search_options)
c.cases = MpulsCaseOverview()
@@ -218,4 +127,21 @@
session.save()
return self.overview()
+ def parseSortOptions(self, options=None):
+ search_options = []
+ sort_field, sort_order = get_sort(options)
+ # default behavior is to take the sortfield for sorting
+ search_options.append('sort_field:%s' % sort_field)
+ search_options.append('sort_order:%s' % sort_order)
+ return search_options
+
+ #def parseSearchOptions(self, options=None):
+ # search_options = []
+ # log.debug(options)
+ # # Status
+ # if options.has_key('status'):
+ # pass
+ #
+ # return search_options
+
# vim:set ts=4 sw=4 si et sta sts=4 fenc=utf8:
More information about the Mpuls-commits
mailing list