@@ -0,0 +1,759 @@
+from django import template%0Afrom django.core.exceptions import ObjectDoesNotExist%0A%0A%0Aregister = template.Library()%0A%0A%0A@register.assignment_tag(takes_context=True)%0Adef get_current_class(context, course):%0A%0A    current_user = context.get('user')%0A    if current_user.is_anonymous():%0A        return None%0A    current_class = None%0A%0A    try:%0A        current_class = course.class_set.get(students=current_user)%0A    except ObjectDoesNotExist:%0A        pass%0A%0A    # If user is not student in any class in this course, verify if it is professor%0A    # import ipdb;ipdb.set_trace()%0A    if not current_class:%0A        try:%0A            current_class = current_user.professor_classes.get(course=course)%0A        except ObjectDoesNotExist:%0A            pass%0A%0A    return current_class%0A

create get_current_class template tag