File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1515)
1616from .utils .rebate_checker import is_student_on_rebate
1717from allauth .socialaccount .models import SocialAccount
18+ from django .contrib .auth .models import User
1819
1920class LogoutView (APIView ):
2021 """
@@ -173,11 +174,15 @@ def post(self, request):
173174 try :
174175 card = MessCard .objects .get (id = card_id )
175176 card_return_data = QRVerifySerializer (card ).data
176- if not card_return_data .get ('student' ).get ('photo' ):
177- socialaccount_obj = SocialAccount .objects .filter (
178- provider = "google" , user_id = card_return_data ['student' ]['id' ]
179- )
180- card_return_data ['student' ]['photo' ] = socialaccount_obj [0 ].extra_data .get ('picture' )
177+ try :
178+ if not card_return_data .get ('student' ).get ('photo' ):
179+ user = User .objects .get (email = card .student .email )
180+ socialaccount_obj = SocialAccount .objects .filter (
181+ provider = "google" , user_id = user .id
182+ )
183+ card_return_data ['student' ]['photo' ] = socialaccount_obj [0 ].extra_data .get ('picture' )
184+ except :
185+ pass
181186 date = timezone .localtime ().date ()
182187 time = timezone .localtime ().time ()
183188 meal , _ = Meal .objects .get_or_create (mess_card = card , date = date )
You can’t perform that action at this time.
0 commit comments