return _('No')
@register.filter
-def from_course_type(docs, type):
- if docs:
- return docs.filter(course_type=type)
- else:
- return False
-
+def from_course_type(contents, type):
+ if contents:
+ return contents.filter(course_type=type)
+
@register.filter
-def from_doc_type(docs, type):
- return docs.filter(type=type)
-
+def from_doc_type(contents, type):
+ if contents:
+ return contents.filter(type=type)
+
+@register.filter
+def from_periods(contents, periods):
+ if contents:
+ return contents.filter(period__in=periods)
+
@register.assignment_tag
def get_all_professors():
return Professor.objects.all().order_by('user__first_name')
hash = random.getrandbits(128)
return "%032x" % hash
+def get_periods(user):
+ professor = user.professor.all()
+ if professor:
+ professor = user.professor.get()
+ periods = Period.objects.all()
+
+ if settings.TELEFORMA_E_LEARNING_TYPE == 'CRFPA':
+ student = user.crfpa_student.all()
+ if student:
+ student = user.crfpa_student.get()
+ periods = student.period.all()
+
+ elif settings.TELEFORMA_E_LEARNING_TYPE == 'AE':
+ student = user.ae_student.all()
+ if student:
+ student = user.ae_student.get()
+ periods = student.period.all()
+
+ return periods
+
class CourseView(DetailView):
context['room'] = get_room(name=course.title, content_type=content_type,
id=course.id)
context['doc_types'] = DocumentType.objects.all()
+ context['periods'] = get_periods(self.request.user)
return context
@method_decorator(login_required)
context['room'] = get_room(name='site')
context['doc_types'] = DocumentType.objects.all()
context['all_courses'] = sorted(self.all_courses, key=lambda k: k['number'])
+ context['periods'] = get_periods(self.request.user)
return context
@method_decorator(login_required)
if not access:
context['access_error'] = access_error
context['message'] = contact_message
+ context['periods'] = get_periods(self.request.user)
return context
@method_decorator(login_required)
if not access:
context['access_error'] = access_error
context['message'] = contact_message
+ context['periods'] = get_periods(self.request.user)
return context
@method_decorator(login_required)
if not access:
context['access_error'] = access_error
context['message'] = contact_message
+ context['periods'] = get_periods(self.request.user)
return context
@jsonrpc_method('teleforma.stop_conference')