def gen_excel_report(term): #MINI papers = Paper.objects.filter(term=term, paper_type='BMW', project__id=3) #dlist = ['27221_M','28778_M','29362_M','29388_M','29437_M','27365_M'] dlist = ['27221_M'] for p in papers: print p.dealer.name if p.dealer.name in dlist: print 'gen ', p.dealer.name_cn, 'paperid=', p.id from mc import gen_report gen_report(p, None) print 'finish ', p.dealer.name_cn # BMW papers = Paper.objects.filter(term=term, paper_type='BMW', project__id=2).order_by('-id') #dlist = ['27357','31671','32446','32418','28401','30492','34235','36430','36984','30689','28644','28399'] dlist = ['26563'] for p in papers: if p.dealer.name in dlist: print 'gen ', p.dealer.name_cn, 'paperid=', p.id from mc import gen_report gen_report(p, None) print 'finish ', p.dealer.name_cn
def gen_report_bentch(modeladmin, request, queryset): """ """ opts = modeladmin.model._meta app_label = opts.app_label # Populate modifiable_objects, a data structure of all related objects that will also be deleted. modifiable_objects, perms_needed = get_deleted_objects(queryset, opts, request.user, modeladmin.admin_site, levels_to_root=2) # can_audit = validate_false_paper_have_type(queryset, [enums.BMW_PAPER_TYPE, enums.FH_PAPER_TYPE]) # if can_audit == False: # messages.error(request, u'FW团队终审问卷才能生成单店报告') # return None # The user has already confirmed the deletion. # Do the deletion and return a None to display the change list view again. if request.POST.get('post'): user = request.user # 权限判定 #督导,终审,管理员可用 if not has_fh_end_audit_perm(user) and not has_end_audit_perm(user) and not has_manage_perm(user) and not has_dd_audit_perm(user): raise PermissionDenied n = queryset.count() if n: from mc import gen_report perm = enums.PAPER_STATUS_FINISH for obj in queryset : if obj.status == perm: obj_display = force_unicode(obj) #统计得 gen_report(obj, user) # change modeladmin.log_change(request, obj, obj_display) else: n -= 1 modeladmin.message_user(request, u'生成 %(count)d %(items)s EXCEL单店报告.' % { "count": n, "items": model_ngettext(modeladmin.opts, n) }) # Return None to display the change list page again. return None context = { "title": _("Are you sure?"), "object_name": force_unicode(opts.verbose_name), "modifiable_objects": modifiable_objects, 'queryset': queryset, "opts": opts, "root_path": modeladmin.admin_site.root_path, "app_label": app_label, 'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME, } # Display the confirmation page return render_to_response('gen_report_bentch_confirmation.html', context, context_instance=template.RequestContext(request))
def gen_excel_report(term): # BMW papers = Paper.objects.filter(term = term, paper_type='BMW', project__id=2) for p in papers: print 'gen ',p.dealer.name_cn, 'paperid=', p.id from mc import gen_report gen_report(p, None) print 'finish ', p.dealer.name_cn #MINI papers = Paper.objects.filter(term = term, paper_type='BMW', project__id=3) for p in papers: print 'gen ',p.dealer.name_cn, 'paperid=', p.id from mc import gen_report gen_report(p, None) print 'finish ', p.dealer.name_cn
def gen_excel_report(term): # BMW papers = Paper.objects.filter(term=term, paper_type='BMW', project__id=2) for p in papers: print 'gen ', p.dealer.name_cn, 'paperid=', p.id from mc import gen_report gen_report(p, None) print 'finish ', p.dealer.name_cn #MINI papers = Paper.objects.filter(term=term, paper_type='BMW', project__id=3) for p in papers: print 'gen ', p.dealer.name_cn, 'paperid=', p.id from mc import gen_report gen_report(p, None) print 'finish ', p.dealer.name_cn
def gen_report_req(request): from mc import get_paper_by_id, gen_report paperid = int(request.POST.get('paperid', 0)) paper = get_paper_by_id(paperid) ret = False if paper: #TODO:权限判断 user = request.user ret = gen_report(paper, user) import urllib ret = urllib.quote(ret.encode('utf-8')) sdicts = {} sdicts['result'] = ret and 1 or 0 sdicts['purl'] = ret return HttpResponse(simplejson.dumps(sdicts, ensure_ascii=False))
def gen_report_bentch(modeladmin, request, queryset): """ """ opts = modeladmin.model._meta app_label = opts.app_label # Populate modifiable_objects, a data structure of all related objects that will also be deleted. modifiable_objects, perms_needed = get_deleted_objects( queryset, opts, request.user, modeladmin.admin_site, levels_to_root=2) # can_audit = validate_false_paper_have_type(queryset, [enums.BMW_PAPER_TYPE, enums.FH_PAPER_TYPE]) # if can_audit == False: # messages.error(request, u'FW团队终审问卷才能生成单店报告') # return None # The user has already confirmed the deletion. # Do the deletion and return a None to display the change list view again. if request.POST.get('post'): user = request.user # 权限判定 #督导,终审,管理员可用 if not has_fh_end_audit_perm(user) and not has_end_audit_perm( user) and not has_manage_perm(user) and not has_dd_audit_perm( user): raise PermissionDenied n = queryset.count() if n: from mc import gen_report perm = enums.PAPER_STATUS_FINISH for obj in queryset: if obj.status == perm: obj_display = force_unicode(obj) #统计得 gen_report(obj, user) # change modeladmin.log_change(request, obj, obj_display) else: n -= 1 modeladmin.message_user( request, u'生成 %(count)d %(items)s EXCEL单店报告.' % { "count": n, "items": model_ngettext(modeladmin.opts, n) }) # Return None to display the change list page again. return None context = { "title": _("Are you sure?"), "object_name": force_unicode(opts.verbose_name), "modifiable_objects": modifiable_objects, 'queryset': queryset, "opts": opts, "root_path": modeladmin.admin_site.root_path, "app_label": app_label, 'action_checkbox_name': helpers.ACTION_CHECKBOX_NAME, } # Display the confirmation page return render_to_response( 'gen_report_bentch_confirmation.html', context, context_instance=template.RequestContext(request))