|
@@ -1,6 +1,7 @@
|
|
|
# coding=utf-8
|
|
|
from rest_framework.views import APIView
|
|
|
from django.db.models import Q
|
|
|
+import json
|
|
|
import traceback
|
|
|
import datetime
|
|
|
from django.db import transaction
|
|
@@ -315,6 +316,7 @@ class NewCustomerViewSet(CustomModelViewSet):
|
|
|
@action(methods=['post'], detail=True)
|
|
|
def inner_review(self, request , pk):
|
|
|
#内部跟踪
|
|
|
+ check_permission(request, 'customer.inner_review')
|
|
|
description = request.POST.get('description')
|
|
|
next_time = request.POST.get('next_time')
|
|
|
is_copy = request.POST.get('is_copy') == '1'
|
|
@@ -377,9 +379,9 @@ class NewCustomerViewSet(CustomModelViewSet):
|
|
|
|
|
|
@action(methods=['post'], detail=True)
|
|
|
def add_projects(self, request, pk):
|
|
|
-
|
|
|
- projects = request.POST.get('projects')
|
|
|
- projects = projects.split(',')
|
|
|
+ # 添加项目
|
|
|
+ check_permission(request, 'customer.add_review')
|
|
|
+ projects = json.loads(request.POST.get('projects'))
|
|
|
try:
|
|
|
with transaction.atomic():
|
|
|
instance = NewCustomer.objects.filter(id=pk).first()
|
|
@@ -389,7 +391,6 @@ class NewCustomerViewSet(CustomModelViewSet):
|
|
|
if not stage_progress.track_day:
|
|
|
raise CustomError('当前阶段,没有设置跟踪天数!')
|
|
|
next_time = (timezone.now() + datetime.timedelta(days=stage_progress.track_day)).strftime('%Y-%m-%d')
|
|
|
- projects = Option.objects.filter(id__in=projects)
|
|
|
for project in projects:
|
|
|
customer = NewCustomer.objects.create(report_customer=instance.report_customer, gender=instance.gender,
|
|
|
track_user=instance.track_user, stage_progress=stage_progress,
|
|
@@ -398,7 +399,7 @@ class NewCustomerViewSet(CustomModelViewSet):
|
|
|
address=instance.address, source=instance.source,
|
|
|
notes=instance.notes,next_time=next_time,
|
|
|
)
|
|
|
- customer.project.add(project.id)
|
|
|
+ customer.project.add(project)
|
|
|
|
|
|
NewCustomerRemind.objects.create(customer=customer, store=customer.store, next_time=next_time,
|
|
|
remind_user_id=instance.track_user_id,)
|