Django查看数据流

时间:2019-04-03 20:23:12

标签: python django django-views

我有一个功能完善的django服务,已为销售团队实施了一些疯狂的付款规则。然后,董事更改这些规则,以便节省时间,在代码的微妙部分中,我需要一种快速的方法来在django视图中分析信息流。顺便说一句,我有大量的测试来检查是否有一些改动使整个系统崩溃。感兴趣的视图如下所示。

from datetime import date
from collections import OrderedDict
from sales_report.models import *
from django.http import JsonResponse
from django.contrib.auth.decorators import login_required
from itertools import chain
import pprint
from django.conf import settings

def report(request, month, year):
    month_lock_status = report_lock.get_month(month, year)

    if month_lock_status['cod'] != 'ok':
        return JsonResponse(month_lock_status)

    if month_lock_status['msg'].is_locked == 1:
        response = {
            'cod': 'report month is locked',
            'msg': 'Carga travada para mês: ' + str(month) + ' ano: ' + str(year)
        }
        return JsonResponse(response)

    if month_lock_status['msg'].is_locked == 0:
        seller_history.clear_data(month, year)
        seller_report.clear_data(month, year)
        # sellers = seller.get_active_sellers()
        list_of_sellers = {}
        total_sales = 0
        total_payment = 0
        special_super_prize = prize.get_super_prize()
        ret = ''

        # É necessário percorrer os supervisores depois para que se faça o cálculo dos ganhos da equipe
        non_managers_qs = role_hist.get_managers(month, year, False)
        managers_qs = role_hist.get_managers(month, year, True)
        sellers = chain(non_managers_qs, managers_qs)

        if settings.TESTING:
            print('\n\nsales_report/views/report.py')
            pprint.pprint('vendedores: ' + str(len(non_managers_qs)))
            pprint.pprint('gerentes: ' + str(len(managers_qs)))

        # percorre apenas os vendedores ativos
        for s in sellers:
            """
            Lots of decisions
            """
        if ret == '':
            ret = 'ok'
        response = {
            'cod': 'report ok',
            'msg': ret
        }
        return JsonResponse(response)

我希望这种图像带有决策树或该视图的工作流程。

0 个答案:

没有答案