You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

18 lines
427 B

from apps.course.models import Participant
def user_has_course_access(user, course):
if not user or not getattr(user, 'is_authenticated', False):
return False
if user.is_staff or user.is_superuser:
return True
if course.professor_id == user.id:
return True
return Participant.objects.filter(
student_id=user.id,
course=course,
is_active=True,
).exists()