Esempio n. 1
0
 def get_data_rows(self,ar):
     qs = contacts.Partner.objects.all()
     if ar.quick_search is not None:
         qs = dbtables.add_quick_search_filter(qs,ar.quick_search)
     if ar.gridfilters is not None:
         qs = dbtables.add_gridfilters(qs,ar.gridfilters)
     
     rows = []
     for p in qs:
         row = self.get_row_for(p)
         if row.amount >= min_amount and row.first_date is not None:
             rows.append(row)
     
     def f(a,b): return cmp(a.first_date,b.first_date)
     rows.sort(f)
     return rows
Esempio n. 2
0
def choices_response(request,qs,row2dict,emptyValue):
    quick_search = request.GET.get(ext_requests.URL_PARAM_FILTER,None)
    if quick_search is not None:
        qs = dbtables.add_quick_search_filter(qs,quick_search)
        
    count = len(qs)
        
    offset = request.GET.get(ext_requests.URL_PARAM_START,None)
    if offset:
        qs = qs[int(offset):]
        #~ kw.update(offset=int(offset))
    limit = request.GET.get(ext_requests.URL_PARAM_LIMIT,None)
    if limit:
        #~ kw.update(limit=int(limit))
        qs = qs[:int(limit)]
        
    rows = [ row2dict(row,{}) for row in qs ]
    if emptyValue is not None: # 20121203
        empty = dict()
        empty[ext_requests.CHOICES_TEXT_FIELD] = emptyValue
        empty[ext_requests.CHOICES_VALUE_FIELD] = None
        rows.insert(0,empty)
    return json_response_kw(count=count,rows=rows) 
Esempio n. 3
0
def choices_response(request, qs, row2dict, emptyValue):
    quick_search = request.GET.get(constants.URL_PARAM_FILTER, None)
    if quick_search is not None:
        qs = dbtables.add_quick_search_filter(qs, quick_search)

    count = len(qs)

    offset = request.GET.get(constants.URL_PARAM_START, None)
    if offset:
        qs = qs[int(offset):]
        #~ kw.update(offset=int(offset))
    limit = request.GET.get(constants.URL_PARAM_LIMIT, None)
    if limit:
        #~ kw.update(limit=int(limit))
        qs = qs[:int(limit)]

    rows = [row2dict(row, {}) for row in qs]
    if emptyValue is not None:  # 20121203
        empty = dict()
        empty[constants.CHOICES_TEXT_FIELD] = emptyValue
        empty[constants.CHOICES_VALUE_FIELD] = None
        rows.insert(0, empty)
    return json_response_kw(count=count, rows=rows)