拍爱

oauth_views.py 1.4KB

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