def set_persistent_value(my): filter_data = FilterData.get_from_cgi() json = filter_data.serialize() # use widget settings instead # Using solely TableLayoutWdg will result in having no search view if my.view: key = SearchWdg._get_key(my.search_type, my.view) WidgetSettings.set_value_by_key(key, json) #value = WidgetSettings.get_value_by_key(key) #print "value: ", value return
def set_persistent_value(my): filter_data = FilterData.get_from_cgi() json = filter_data.serialize() # use widget settings instead key = SearchWdg._get_key(my.search_type, my.view) WidgetSettings.set_value_by_key(key, json) #value = WidgetSettings.get_value_by_key(key) #print "value: ", value return
def get_display(my): filter_data = FilterData.get_from_cgi() values = filter_data.get_values("custom", "year") year = 0 for value in values: if value: try: year = int(value) except: pass if not year: date = Date() year = int(date.get_year()) sobject = my.get_current_sobject() id = sobject.get_id() column = my.get_option("column") month = int( my.get_option('month') ) end_year = year end_month = month + 1 if end_month > 12: end_month = 1 end_year += 1 search_type = 'MMS/personal_time_log' if year: search = Search(search_type) search.add_filter('login_id', id) search.add_filter('work_performed_date', '%s-%0.2d-01' % (year,month), '>') search.add_filter('work_performed_date', '%s-%0.2d-01' % (end_year,end_month), '<') sobjects = search.get_sobjects() else: sobjects = [] if sobjects: parser = ExpressionParser() sum = parser.eval("@SUM(%s.%s)" % (search_type,column),sobjects=sobjects) else: sum = 0 div = DivWdg() div.add(sum) return div
def get_display(self): filter_data = FilterData.get_from_cgi() values = filter_data.get_values("custom", "year") year = 0 for value in values: if value: try: year = int(value) except: pass if not year: date = Date() year = int(date.get_year()) sobject = self.get_current_sobject() id = sobject.get_id() column = self.get_option("column") month = int(self.get_option('month')) end_year = year end_month = month + 1 if end_month > 12: end_month = 1 end_year += 1 search_type = 'MMS/personal_time_log' if year: search = Search(search_type) search.add_filter('login_id', id) search.add_filter('work_performed_date', '%s-%0.2d-01' % (year, month), '>') search.add_filter('work_performed_date', '%s-%0.2d-01' % (end_year, end_month), '<') sobjects = search.get_sobjects() else: sobjects = [] if sobjects: parser = ExpressionParser() sum = parser.eval("@SUM(%s.%s)" % (search_type, column), sobjects=sobjects) else: sum = 0 div = DivWdg() div.add(sum) return div
def alter_search(self, search): print "Introspect alter_search" # see if any of the filters have a class handler defined from tactic.ui.filter import FilterData filter_data = FilterData.get_from_cgi() values = filter_data.get_values_by_index("introspect", 0) do_search = values.get('search') if not do_search: return #search.add_filter("code", "chr002") session = SessionContents.get() node_names = session.get_node_names() snapshot_codes = session.get_snapshot_codes() snapshot_search = Search("sthpw/snapshot") snapshot_search.add_filters("code", snapshot_codes) snapshots = snapshot_search.get_sobjects() state_search_type = self.kwargs.get("search_type") # get ids ids = [] for snapshot in snapshots: search_type = snapshot.get_value("search_type") if state_search_type: search_type_obj = SearchType.get(search_type) key = search_type_obj.get_base_key() print "compare: ", key, state_search_type if key != state_search_type: continue id = snapshot.get_value("search_id") ids.append(id) print "ids: ", ids if ids: search.add_filters("id", ids)