|
@@ -42,7 +42,7 @@ class EvaluationActivityView(View):
|
|
if operation == 'getActivity':
|
|
if operation == 'getActivity':
|
|
return self.get_activity(user_id, request_dict, response)
|
|
return self.get_activity(user_id, request_dict, response)
|
|
elif operation == 'getActivityList':
|
|
elif operation == 'getActivityList':
|
|
- return self.get_activity_list(user_id, request_dict, response)
|
|
|
|
|
|
+ return self.get_activity_list(request_dict, response)
|
|
elif operation == 'addOrEditActivity':
|
|
elif operation == 'addOrEditActivity':
|
|
return self.add_or_edit_activity(request, request_dict, response)
|
|
return self.add_or_edit_activity(request, request_dict, response)
|
|
elif operation == 'getActivityUser':
|
|
elif operation == 'getActivityUser':
|
|
@@ -120,7 +120,7 @@ class EvaluationActivityView(View):
|
|
user = ActivityUser.objects.filter(user_id=user_id, activity_id=activity_id)
|
|
user = ActivityUser.objects.filter(user_id=user_id, activity_id=activity_id)
|
|
if user.exists():
|
|
if user.exists():
|
|
user.update(phone=phone, address=address, sex=sex, user_name=user_name, is_reports=is_reports, age=age,
|
|
user.update(phone=phone, address=address, sex=sex, user_name=user_name, is_reports=is_reports, age=age,
|
|
- usage_environment=usage_environment, update_time=now_time)
|
|
|
|
|
|
+ usage_environment=usage_environment, update_time=now_time)
|
|
else:
|
|
else:
|
|
ActivityUser.objects.create(activity_id=activity_id, user_id=user_id, phone=phone, address=address,
|
|
ActivityUser.objects.create(activity_id=activity_id, user_id=user_id, phone=phone, address=address,
|
|
sex=sex, age=age, usage_environment=usage_environment, user_name=user_name,
|
|
sex=sex, age=age, usage_environment=usage_environment, user_name=user_name,
|
|
@@ -202,29 +202,42 @@ class EvaluationActivityView(View):
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
|
@staticmethod
|
|
@staticmethod
|
|
- def get_activity_list(user_id, request_dict, response):
|
|
|
|
|
|
+ def get_activity_list(request_dict, response):
|
|
|
|
+ page = request_dict.get('page', None)
|
|
|
|
+ line = request_dict.get('line', None)
|
|
|
|
+ if not all([page, line]):
|
|
|
|
+ return response.json(444)
|
|
try:
|
|
try:
|
|
- activity_qs = FreeEvaluationActivity.objects.all().values('id', 'activity_name', 'carousel_image_url',
|
|
|
|
- 'details_image_url', 'issue', 'is_show',
|
|
|
|
- 'product_number', 'original_price')
|
|
|
|
|
|
+ page = int(page)
|
|
|
|
+ line = int(line)
|
|
|
|
+ activity_qs = FreeEvaluationActivity.objects.all()
|
|
|
|
+ count = activity_qs.count()
|
|
|
|
+ activity_qs = activity_qs.values('id', 'activity_name', 'carousel_image_url', 'details_image_url', 'issue',
|
|
|
|
+ 'is_show', 'product_number', 'original_price')[
|
|
|
|
+ (page - 1) * line: page * line]
|
|
for item in activity_qs:
|
|
for item in activity_qs:
|
|
time_qs = ActivityTime.objects.filter(activity_id=item['id']).values('node_content', 'start_time',
|
|
time_qs = ActivityTime.objects.filter(activity_id=item['id']).values('node_content', 'start_time',
|
|
'end_time').order_by('sort')
|
|
'end_time').order_by('sort')
|
|
item['activity_process'] = list(time_qs)
|
|
item['activity_process'] = list(time_qs)
|
|
- return response.json(0, list(activity_qs))
|
|
|
|
|
|
+ return response.json(0, {'list': list(activity_qs), 'count': count})
|
|
except Exception as e:
|
|
except Exception as e:
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|
|
@staticmethod
|
|
@staticmethod
|
|
def get_user_list(request_dict, response):
|
|
def get_user_list(request_dict, response):
|
|
activity_id = request_dict.get('activity_id', None)
|
|
activity_id = request_dict.get('activity_id', None)
|
|
|
|
+ page = request_dict.get('page', None)
|
|
|
|
+ line = request_dict.get('line', None)
|
|
|
|
+ if not all([activity_id, page, line]):
|
|
|
|
+ return response.json(444)
|
|
try:
|
|
try:
|
|
- user_qs = ActivityUser.objects.all()
|
|
|
|
- if activity_id:
|
|
|
|
- user_qs = user_qs.filter(activity_id=activity_id)
|
|
|
|
|
|
+ page = int(page)
|
|
|
|
+ line = int(line)
|
|
|
|
+ user_qs = ActivityUser.objects.filter(activity_id=activity_id)
|
|
|
|
+ count = user_qs.count()
|
|
user_qs = user_qs.values('id', 'user_name', 'phone', 'age', 'address', 'sex', 'is_selected', 'activity_id',
|
|
user_qs = user_qs.values('id', 'user_name', 'phone', 'age', 'address', 'sex', 'is_selected', 'activity_id',
|
|
- 'usage_environment', 'is_reports')
|
|
|
|
- return response.json(0, list(user_qs))
|
|
|
|
|
|
+ 'usage_environment', 'is_reports')[(page - 1) * line:page * line]
|
|
|
|
+ return response.json(0, {'list': list(user_qs), 'count': count})
|
|
except Exception as e:
|
|
except Exception as e:
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
return response.json(500, 'error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e)))
|
|
|
|
|