def getDefaultJsonDataTemplate(model, exception_fields=[], addition_fields=[], master_field=None): from data_utils import change_to_master_field additionHeader={} if master_field: additionFields=[change_to_master_field(model, master_field, f) for f in addition_fields] exceptionFields=[change_to_master_field(model, master_field, f) for f in exception_fields] else: additionFields=addition_fields exceptionFields=exception_fields if additionFields: fs=[] for f in additionFields: header="" field=f filter="" if f.find("</th>")>=0: header,field=f.split("</th>",1) header+="</th>" additionHeader[field]=header fs.append(field) additionFields=fs if model.__class__==cached_model.MetaCaching: defDataList=["%s%s"%(f.name, default_filter(f.__class__)) for f in model._meta.fields if f.name not in default_fields]#('change_operator','create_operator','delete_operator','change_time','create_time','delete_time')] else: defDataList=["%s%s"%(f.name, default_filter(f.__class__)) for f in model._meta.fields] try: defDataListDefined=[f for f in model.Admin.list_display if f.find("_")!=0] except Exception, e: defDataListDefined=[]
def getDefaultJsonDataTemplate(model, exception_fields=[], addition_fields=[], master_field=None): from data_utils import change_to_master_field additionHeader = {} if master_field: additionFields = [ change_to_master_field(model, master_field, f) for f in addition_fields ] exceptionFields = [ change_to_master_field(model, master_field, f) for f in exception_fields ] else: additionFields = addition_fields exceptionFields = exception_fields if additionFields: fs = [] for f in additionFields: header = "" field = f filter = "" if f.find("</th>") >= 0: header, field = f.split("</th>", 1) header += "</th>" additionHeader[field] = header fs.append(field) additionFields = fs if model.__class__ == cached_model.MetaCaching: defDataList = [ "%s%s" % (f.name, default_filter(f.__class__)) for f in model._meta.fields if f.name not in default_fields ] #('change_operator','create_operator','delete_operator','change_time','create_time','delete_time')] else: defDataList = [ "%s%s" % (f.name, default_filter(f.__class__)) for f in model._meta.fields ] try: defDataListDefined = [ f for f in model.Admin.list_display if f.find("_") != 0 ] except Exception, e: defDataListDefined = []
fs.append(field) additionFields=fs if model.__class__==cached_model.MetaCaching: defDataList=["%s%s"%(f.name, default_filter(f.__class__)) for f in model._meta.fields if f.name not in default_fields]#('change_operator','create_operator','delete_operator','change_time','create_time','delete_time')] else: defDataList=["%s%s"%(f.name, default_filter(f.__class__)) for f in model._meta.fields] try: defDataListDefined=[f for f in model.Admin.list_display if f.find("_")!=0] except Exception, e: defDataListDefined=[] if defDataListDefined: defDataList=defDataListDefined if master_field: defDataList=[change_to_master_field(model, master_field, f) for f in defDataList] if additionFields: defDataList=defDataList+[f for f in additionFields if f not in defDataList] if exceptionFields: defDataList=[field for field in defDataList if (field not in exceptionFields)]; if "pk" not in defDataList: if model._meta.pk.name not in defDataList: defDataList.insert(0,model._meta.pk.name) defFieldList=defDataList defDataList=[] defHeaderList=[] for field in defFieldList: if ("get_"+field+"_display" in dir(model)): defDataList.append('"{{ item.get_'+field+'_display }}"')
defDataList = [ "%s%s" % (f.name, default_filter(f.__class__)) for f in model._meta.fields ] try: defDataListDefined = [ f for f in model.Admin.list_display if f.find("_") != 0 ] except Exception, e: defDataListDefined = [] if defDataListDefined: defDataList = defDataListDefined if master_field: defDataList = [ change_to_master_field(model, master_field, f) for f in defDataList ] if additionFields: defDataList = defDataList + [ f for f in additionFields if f not in defDataList ] if exceptionFields: defDataList = [ field for field in defDataList if (field not in exceptionFields) ] if "pk" not in defDataList: if model._meta.pk.name not in defDataList: defDataList.insert(0, model._meta.pk.name) defFieldList = defDataList defDataList = []