Ejemplo n.º 1
0
def report_details(request):
    '''
    报告->活动有效性评估->报告详情
    :param request:
    :return:
    '''
    param = apps_apis.get_parameter(request.POST, [("report_id", "请选择一个报告", "int")])
    data = apis.report_details(param["report_id"], request.user)
    return JsonResponse(data, safe=True)
Ejemplo n.º 2
0
def ao_volume_trend(request):
    '''
    活动定位 -> 品牌声量趋势
    :param request:
    :return:
    '''
    params = apps_apis.get_parameter(request.POST, ao_params + activity_tag)
    data = apis.ao_volume_trend(params)

    return JsonResponse(data=data, safe=False)
Ejemplo n.º 3
0
def ao_activity_content(request):
    '''
    活动定位 -> 热帖一览
    :param request:
    :return:
    '''
    params = apps_apis.get_parameter(request.POST, ao_params + activity_tag)
    data = apis.ao_activity_content(params)

    return JsonResponse(data=data, safe=False)
Ejemplo n.º 4
0
def ao_activity_tag_list(request):
    '''
    活动定位 -> 标签列表
    :param request:
    :return:
    '''
    params = apps_apis.get_parameter(request.POST, ao_params)
    data = apis.ao_activity_tag_list(params)

    return JsonResponse(data=data, safe=False)
Ejemplo n.º 5
0
def ao_keywords_cloud(request):
    '''
    活动定位 -> 获取关键词云
    :param request:
    :return:
    '''
    params = apps_apis.get_parameter(request.POST, ao_params + activity_tag)
    data = apis.ao_keywords_cloud(params)

    return JsonResponse(data=data, safe=False)
Ejemplo n.º 6
0
def sales_point_list(request):
    '''
    宣传卖点列表
    :param request:
    :return:
    '''
    param = apps_apis.get_parameter(request.POST,
                                    [("category_id", "请选择品类", "int")])
    data = apis.sales_point_list(param["category_id"])

    return JsonResponse(data, safe=False)
Ejemplo n.º 7
0
def category_list(request):
    '''
    品类列表
    :param request:
    :return:
    '''
    param = apps_apis.get_parameter(request.POST,
                                    [("industry_id", "请选择行业", "int")])
    data = apis.category_list(param["industry_id"])

    return JsonResponse(data, safe=False)
Ejemplo n.º 8
0
def competitor_del(request):
    '''
    设置 删除 指定的 主要竞品
    :param request:
    :return:
    '''
    param = apps_apis.get_parameter(request.POST,
                                    [("id", "请输入主要竞品的 id", "int")])
    apis.competitor_del(param, request.user)

    return HttpResponse("ok")
Ejemplo n.º 9
0
def competitor_get(request):
    '''
    设置, 获取单个 主要竞品的详细信息
    :param request:
    :return:
    '''
    param = apps_apis.get_parameter(request.POST,
                                    [("id", "请输入主要竞品的 id", "int")])
    competitor = apis.competitor_get(param, request.user)

    return JsonResponse(competitor, safe=False)
Ejemplo n.º 10
0
def competitor_list(request):
    '''
    设置, 竞品列表
    :param request:
    :return:
    '''
    param = apps_apis.get_parameter(request.POST,
                                    [("queue_filter", "", "str")])
    competitors = apis.competitor_list(param, request.user)

    return JsonResponse(competitors, safe=False)
Ejemplo n.º 11
0
def report_config_edit(request):
    '''
    报告->活动有效性评估->报告配置编辑
    :param request:
    :return:
    '''
    param = apps_apis.get_parameter(request.POST, [("report_id", "请选择一个报告", "int")])
    data = apis.get_report_config(param["report_id"], request.user)
    data.__dict__.pop("_state")
    data = apis.formatted_report([data.__dict__])[0]
    return JsonResponse(data, safe=False)
Ejemplo n.º 12
0
def get_competitor(request):
    '''
    根据 品类品牌 获取 品牌竞品列表
    :param request:
    :return:
    '''
    param = apps_apis.get_parameter(request.POST, [
        ("category_id", "请输入 品类 id", "int"),
        ("brand", "请输入品牌信息", "list"),
    ])

    competitor = apis.get_competitor(param, request.user)

    return JsonResponse(competitor, safe=False)
Ejemplo n.º 13
0
def activity_contrast(request):
    '''
    活动对比
    :param request:
    :return:
    '''
    param = apps_apis.get_parameter(request.POST, [("report_ids", "请选择报告", "list")])

    if len(param["report_ids"]) > 5 or len(param["report_ids"]) < 2:
        raise Exception("报告个数必须大于 2 小于 5")

    data = apis.activity_contrast(param, request.user)

    return JsonResponse(data, safe=False)
Ejemplo n.º 14
0
def get_report(request):
    '''
    获取特定状态的报告列表
    :param request:
    :return:
    '''

    ip = apps_apis.get_ip(request)
    if not (ip.startswith("172.16.1.") or ip in apps_apis.domains_2_ips(whitelist)):
        return JsonResponse(dict(code=403))

    param = apps_apis.get_parameter(request.POST, [("status", "请输入报告状态", "int")])
    data = apis.get_reports(param["status"])

    return JsonResponse(data, safe=True)
Ejemplo n.º 15
0
def report_config_create(request):
    '''
    报告->活动有效性评估->报告配置新建
    :param request:
    :return:
    '''
    params = [
        ("report_id", "", "int"),
        ("industry_id", "请选择行业", "int"),
        ("brand_id", "请选择品牌", "list"),
        ("category_id", "请选择品类", "int"),
        ("competitors", "", "list"),
        ("product_line", "", "str"),
        ("name", "请输入报告名称", "str"),
        ("title", "请输入活动主题", "str"),
        ("tag", "", "list"),
        ("monitor_start_date", "请选择活动检测周期", "str"),
        ("monitor_end_date", "请选择活动检测周期", "str"),
        ("platform", "", "list"),
        ("accounts", "", "dict"),
        ("sales_points", "", "list"),
        ("remark", "", "str"),
        ("bgc", "", "bool"),
        ("kol", "", "bool"),
    ]

    if request.user.is_admin:
        raise Exception("管理员不具有创建报告的权限")

    ip = apps_apis.get_ip(request)
    param = apps_apis.get_parameter(request.POST, params)

    # 这里判断标签  请选择投放渠道
    if not param['accounts'].get("url") and not param['tag']:
        raise Exception("请输入标签")
    if not param['accounts'].get("url") and not param['platform']:
        raise Exception("请选择投放渠道")
    diff_date = (apps_apis.str2date(param["monitor_end_date"]) - apps_apis.str2date(param["monitor_start_date"])).days + 1
    if diff_date < 1 or diff_date > 90:
        raise Exception("请选择正确的检测周期")

    if len(param["sales_points"]) > 3:
        raise Exception("宣传卖点最多选择 3 个")

    report = apis.report_config_create(param, request.user, ip)

    return JsonResponse(dict(code=200, report_id=report.id))
Ejemplo n.º 16
0
def update_report(request):
    '''
    更新报告状态
    :param request:
    :return:
    '''
    ip = apps_apis.get_ip(request)
    if not (ip.startswith("172.16.1.") or ip in apps_apis.domains_2_ips(whitelist)):
        return JsonResponse(dict(code=403))

    param = apps_apis.get_parameter(request.POST, [
        ("report_id", "请选择报告", "int"),
        ("status", "请输入报告状态", "int"),
        ("data", "", "dict")
    ])
    data = apis.update_report(param["report_id"], param["status"], param["data"], ip)
    return JsonResponse(data, safe=True)
Ejemplo n.º 17
0
def report_unscramble_save(request):
    '''
    报告->活动有效性评估->报告解读保存
    :param request:
    :return:
    '''
    params = [
        ("report_id", "请选择报告", "int"),
        ("content", "请输入报告解读内容", "str"),
    ]
    param = apps_apis.get_parameter(request.POST, params)

    if request.user.is_admin:
        raise Exception("管理员不具有编辑解读权限")

    data = apis.report_unscramble_save(param, request.user)

    return JsonResponse(dict(code=200, data=data))
Ejemplo n.º 18
0
def competitor_save(request):
    '''
    设置, 添加 主要竞品
    :param request:
    :return:
    '''
    param = apps_apis.get_parameter(request.POST, [
        ("id", "", "int"),
        ("category_id", "请选择品类", "int"),
        ("brand", "请选择品牌", "list"),
        ("competitors", "请选择竞品", "list"),
    ])

    if len(param["competitors"]) > 10:
        raise Exception("主要竞品最多只能选择 10 个")

    apis.competitor_save(param, request.user)

    return HttpResponse("ok")