拍爱

oauth_views.py 1.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. # -*- coding: utf-8 -*-
  2. from django.shortcuts import render
  3. from json_render import json_render
  4. from account.models import LensmanInfo, TourGuideInfo
  5. from utils.redis.connect import r
  6. def lensman_oauth(request):
  7. lensman_type = int(request.GET.get('lt') or 0)
  8. unionid = request.GET.get('unionid', '')
  9. try:
  10. lensman = LensmanInfo.objects.get(unionid=unionid)
  11. except LensmanInfo.DoesNotExist:
  12. lensman = None
  13. return render(request, 'page/lensman_oauth.html', {
  14. 'lensman_type': lensman_type,
  15. 'lensman_info': lensman and lensman.data(lensman_type),
  16. 'modified': bool((not lensman) or (lensman and lensman.modified(lensman_type))), # 是否可以更改信息
  17. })
  18. def tourguide_oauth(request):
  19. unionid = request.GET.get('unionid', '')
  20. try:
  21. tourguide = TourGuideInfo.objects.get(unionid=unionid)
  22. except TourGuideInfo.DoesNotExist:
  23. tourguide = None
  24. return render(request, 'page/tourguide_oauth.html', {
  25. 'tourguide_info': tourguide and tourguide.data,
  26. 'modified': bool((not tourguide) or (tourguide and tourguide.modified)), # 是否可以更改信息
  27. })
  28. def login_qrcode(request):
  29. lensman_type = int(request.GET.get('lt') or 0)
  30. unionid = request.GET.get('unionid', '')
  31. data = {
  32. 'lensman_type': lensman_type,
  33. 'unionid': unionid,
  34. 'token': r.token(unionid)
  35. }
  36. return json_render(request, 'page/login_qrcode.html', data)