Geen omschrijving

lensman_admin_views.py 2.9KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. # -*- coding: utf-8 -*-
  2. from __future__ import division
  3. from django_logit import logit
  4. from django_response import response
  5. from django.db.models import Q
  6. from paginator import pagination
  7. from TimeConvert import TimeConvert as tc
  8. from account.models import LensmanInfo, UserIntegralIncomeExpensesInfo
  9. from kodo.decorators import check_admin
  10. @logit
  11. @check_admin
  12. def lensman_list(request, administrator):
  13. page = request.POST.get('page', 1)
  14. num = request.POST.get('num', 20)
  15. query = request.POST.get('query', '')
  16. logs = LensmanInfo.objects.filter(status=True).order_by('-pk')
  17. if query:
  18. logs = logs.filter(Q(name__icontains=query) | Q(phone__icontains=query))
  19. count = logs.count()
  20. logs, left = pagination(logs, page, num)
  21. logs = [log.admindata for log in logs]
  22. return response(data={
  23. 'logs': logs,
  24. 'left': left,
  25. 'count': count,
  26. })
  27. @logit
  28. @check_admin
  29. def lensman_audit(request, administrator):
  30. lensman_id = request.POST.get('lensman_id', '')
  31. start_date = tc.to_date(request.POST.get('start_date', ''))
  32. end_date = tc.to_date(request.POST.get('end_date', ''))
  33. try:
  34. lensman = LensmanInfo.objects.get(lensman_id=lensman_id, status=True)
  35. except LensmanInfo.DoesNotExist:
  36. return response(200, 'Lensman Not Found', u'摄影师不存在')
  37. lensman.lensman_status = LensmanInfo.ACTIVATED
  38. lensman.start_date = start_date
  39. lensman.end_date = end_date
  40. lensman.save()
  41. return response(200, 'Lensman Audit Pass Suceess', u'摄影师审核通过')
  42. @logit
  43. @check_admin
  44. def lensman_update(request, administrator):
  45. lensman_id = request.POST.get('lensman_id', '')
  46. start_date = tc.to_date(request.POST.get('start_date', ''))
  47. end_date = tc.to_date(request.POST.get('end_date', ''))
  48. name = request.POST.get('name', '')
  49. phone = request.POST.get('phone', '')
  50. try:
  51. lensman = LensmanInfo.objects.get(lensman_id=lensman_id, status=True)
  52. except LensmanInfo.DoesNotExist:
  53. return response(200, 'Lensman Not Found', u'摄影师不存在')
  54. lensman.start_date = start_date
  55. lensman.end_date = end_date
  56. lensman.name = name
  57. lensman.phone = phone
  58. lensman.save()
  59. return response(200, 'Lensman Info Update Suceess', u'摄影师信息更新成功')
  60. @logit
  61. @check_admin
  62. def lensman_integral_list(request, administrator):
  63. user_id = request.POST.get('user_id', '')
  64. try:
  65. lensman = LensmanInfo.objects.get(user_id=user_id, status=True)
  66. except LensmanInfo.DoesNotExist:
  67. return response(200, 'Lensman Not Found', u'摄影师不存在')
  68. integrals = UserIntegralIncomeExpensesInfo.objects.filter(user_id=user_id, integral_from=UserIntegralIncomeExpensesInfo.LENSMAN_ACTIVITY, status=True)
  69. integrals = [integral.lensman_admindata for integral in integrals]
  70. return response(200, 'Get Lensman Integral List Success', u'获取摄影师积分列表成功', data=integrals)