@@ -84,20 +84,6 @@ def rules(request):
8484 return render (request , "rules.html" , params )
8585
8686
87- # def caterer(request, name):
88- # """
89- # Display the Caterer Page :model:`home.models.caterer`.
90-
91- # *Template:*
92-
93- # :template:`home/caterer.html`
94-
95- # """
96- # caterer = Caterer.objects.get(name=name, visible=True)
97- # context = {"caterer": caterer}
98- # return render(request, "caterer.html", context)
99-
100-
10187def menu (request ):
10288 """
10389 Display the menu along with caterer information on a single page.
@@ -186,7 +172,7 @@ def rebate(request):
186172 try :
187173 period_obj = next (
188174 period
189- for period in Period .objects .all ()
175+ for period in Period .objects .all (). order_by ( "start_date" )
190176 if period .end_date > date .today () + timedelta (1 )
191177 )
192178 allocation = Allocation .objects .filter (email = student , period = period_obj ).first ()
@@ -213,7 +199,7 @@ def rebate(request):
213199 message = "Form needs to be filled atleast 2 days prior the comencement of leave."
214200 elif not is_not_duplicate (student , start_date , end_date ):
215201 message = "You have already applied for rebate during this duration"
216- elif 0 < rebate_days < 2 :
202+ elif rebate_days < 2 :
217203 message = "Min no of days for rebate is 2"
218204 else :
219205 additional_message = ""
@@ -494,7 +480,8 @@ def profile(request):
494480 socialaccount_obj = SocialAccount .objects .filter (
495481 provider = "google" , user_id = request .user .id
496482 )
497- picture = student .photo .url if student .photo else None
483+ if student :
484+ picture = student .photo .url if student .photo else None
498485 allocation : Allocation | None = Allocation .objects .filter (email = student ).last ()
499486 show_allocated_enabled = False
500487 if allocation and allocation .period :
@@ -516,6 +503,8 @@ def profile(request):
516503 if not picture and socialaccount_obj :
517504 picture = socialaccount_obj [0 ].extra_data ["picture" ]
518505 except (IndexError , KeyError ):
506+ logger .warning (socialaccount_obj [0 ])
507+ logger .warning (socialaccount_obj [0 ].extra_data )
519508 logger .error ("No picture found" )
520509 semesters = Semester .objects .all ()
521510 context = {
0 commit comments