1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- from __future__ import division
- from django_logit import logit
- from django_response import response
- from django.db.models import Q
- from paginator import pagination
- from TimeConvert import TimeConvert as tc
- from account.models import LensmanInfo, UserIntegralIncomeExpensesInfo
- from kodo.decorators import check_admin
- @logit
- @check_admin
- def lensman_list(request, administrator):
- page = request.POST.get('page', 1)
- num = request.POST.get('num', 20)
- query = request.POST.get('query', '')
- logs = LensmanInfo.objects.filter(status=True).order_by('-pk')
- if query:
- logs = logs.filter(Q(name__icontains=query) | Q(phone__icontains=query))
- count = logs.count()
- logs, left = pagination(logs, page, num)
- logs = [log.admindata for log in logs]
- return response(data={
- 'logs': logs,
- 'left': left,
- 'count': count,
- })
- @logit
- @check_admin
- def lensman_audit(request, administrator):
- lensman_id = request.POST.get('lensman_id', '')
- start_date = tc.to_date(request.POST.get('start_date', ''))
- end_date = tc.to_date(request.POST.get('end_date', ''))
- try:
- lensman = LensmanInfo.objects.get(lensman_id=lensman_id, status=True)
- except LensmanInfo.DoesNotExist:
- return response(200, 'Lensman Not Found', u'摄影师不存在')
-
- lensman.lensman_status = LensmanInfo.ACTIVATED
- lensman.start_date = start_date
- lensman.end_date = end_date
- lensman.save()
- return response(200, 'Lensman Audit Pass Suceess', u'摄影师审核通过')
- @logit
- @check_admin
- def lensman_update(request, administrator):
- lensman_id = request.POST.get('lensman_id', '')
- start_date = tc.to_date(request.POST.get('start_date', ''))
- end_date = tc.to_date(request.POST.get('end_date', ''))
- name = request.POST.get('name', '')
- phone = request.POST.get('phone', '')
-
- try:
- lensman = LensmanInfo.objects.get(lensman_id=lensman_id, status=True)
- except LensmanInfo.DoesNotExist:
- return response(200, 'Lensman Not Found', u'摄影师不存在')
-
- lensman.start_date = start_date
- lensman.end_date = end_date
- lensman.name = name
- lensman.phone = phone
- lensman.save()
- return response(200, 'Lensman Info Update Suceess', u'摄影师信息更新成功')
- @logit
- @check_admin
- def lensman_integral_list(request, administrator):
- user_id = request.POST.get('user_id', '')
- try:
- lensman = LensmanInfo.objects.get(user_id=user_id, status=True)
- except LensmanInfo.DoesNotExist:
- return response(200, 'Lensman Not Found', u'摄影师不存在')
-
- integrals = UserIntegralIncomeExpensesInfo.objects.filter(user_id=user_id, integral_from=UserIntegralIncomeExpensesInfo.LENSMAN_ACTIVITY, status=True)
- integrals = [integral.lensman_admindata for integral in integrals]
-
- return response(200, 'Get Lensman Integral List Success', u'获取摄影师积分列表成功', data=integrals)
|