23
23
THE SOFTWARE.
24
24
"""
25
25
26
+
26
27
from collections .abc import Collection
27
28
from dataclasses import dataclass
28
29
from typing import TYPE_CHECKING , cast
40
41
)
41
42
from django .db import transaction
42
43
from django .db .models import Q
44
+ from django .http .request import HttpRequest
43
45
from django .shortcuts import get_object_or_404 , redirect , render # noqa
44
46
from django .urls import reverse
45
47
from django .utils .html import escape
@@ -695,15 +697,19 @@ def check_in_for_exam(request: http.HttpRequest) -> http.HttpResponse:
695
697
# }}}
696
698
697
699
698
- def is_from_exams_only_facility (request ):
700
+ def is_from_exams_only_facility (request : HttpRequest ) -> bool :
701
+ request = cast (RelateHttpRequest , request )
702
+
699
703
from course .utils import get_facilities_config
700
- for name , props in get_facilities_config (request ).items ():
701
- if not props .get ("exams_only" , False ):
702
- continue
704
+ facilities_config = get_facilities_config (request )
705
+ if facilities_config :
706
+ for name , props in facilities_config .items ():
707
+ if not props .get ("exams_only" , False ):
708
+ continue
703
709
704
- # By now we know that this facility is exams-only
705
- if name in request .relate_facilities :
706
- return True
710
+ # By now we know that this facility is exams-only
711
+ if name in request .relate_facilities :
712
+ return True
707
713
708
714
return False
709
715
@@ -723,7 +729,7 @@ class ExamFacilityMiddleware:
723
729
def __init__ (self , get_response ):
724
730
self .get_response = get_response
725
731
726
- def __call__ (self , request ) :
732
+ def __call__ (self , request : http . HttpRequest ) -> http . HttpResponse :
727
733
exams_only = is_from_exams_only_facility (request )
728
734
729
735
if not exams_only :
0 commit comments