--- /dev/null
+# -*- coding: utf-8 -*-
+# Copyright (c) 2013 Parisson SARL
+
+# This software is a computer program whose purpose is to backup, analyse,
+# transcode and stream any audio content with its metadata over a web frontend.
+
+# This software is governed by the CeCILL license under French law and
+# abiding by the rules of distribution of free software. You can use,
+# modify and/ or redistribute the software under the terms of the CeCILL
+# license as circulated by CEA, CNRS and INRIA at the following URL
+# "http://www.cecill.info".
+
+# As a counterpart to the access to the source code and rights to copy,
+# modify and redistribute granted by the license, users are provided only
+# with a limited warranty and the software's author, the holder of the
+# economic rights, and the successive licensors have only limited
+# liability.
+
+# In this respect, the user's attention is drawn to the risks associated
+# with loading, using, modifying and/or developing or reproducing the
+# software by the user in light of its specific status of free software,
+# that may mean that it is complicated to manipulate, and that also
+# therefore means that it is reserved for developers and experienced
+# professionals having in-depth computer knowledge. Users are therefore
+# encouraged to load and test the software's suitability as regards their
+# requirements in conditions enabling the security of their systems and/or
+# data to be ensured and, more generally, to use and operate it in the
+# same conditions as regards security.
+
+# The fact that you are presently reading this means that you have had
+# knowledge of the CeCILL license and that you accept its terms.
+#
+# Authors: Guillaume Pellerin <yomguy@parisson.com>
+
+
+from teleforma.views.core import *
+
+
+def periods(request):
+ """return the periods assigned to the user """
+
+ user = request.user
+
+ if not user.is_authenticated():
+ return {'periods': None}
+ else:
+ return {'periods': get_periods(user)}
</div>
<table class="listing" width="100%">
<tbody>
- {% for conference in conferences|from_periods:periods %}
+ {% for conference in conferences|from_period:period %}
{% for stream in conference.livestream.all %}
{% if stream.stream_type == 'webm' %}
<tr>
<span class="doc_type_title">{{ doc_type }}</span>
<table class="listing" width="100%">
<tbody>
- {% for doc in docs|from_course_type:type|from_doc_type:doc_type|from_periods:periods %}
+ {% for doc in docs|from_course_type:type|from_doc_type:doc_type|from_period:period %}
{% if doc.course_type.all|length > 1 and type_counter > 1 %}
{% else %}
<tr>
</div>
<table class="listing" width="100%">
<tbody>
- {% for media in course.media.all|from_course_type:type|from_periods:periods %}
+ {% for media in course.media.all|from_course_type:type|from_period:period %}
{% if media.is_published or user.is_staff %}
{% if media.type == 'webm' %}
<tr>
<ul id="nav">
{% if user.is_authenticated %}
- <li><a href="{% url teleforma-desk %}" class="red">{% trans "Desk" %}</a>
- </li>
+
+ {% if periods|length > 1 %}
+ <li><a href="#desk#" class="red"> {% trans "Desk" %} </a>
+ <ul>
+ {% for period in periods %}
+ <li><a href="{% url teleforma-desk-period period.id %}" class="red">{{ period.name }}</a></li>
+ {% endfor %}
+ </ul>
+ </li>
+ {% else %}
+ <li><a href="{% url teleforma-desk %}" class="red">{% trans "Desk" %}</a></li>
+ {% endif %}
+
{% else %}
<li><a href="{% url teleforma-login %}" class="red">{% trans "Home" %}</a></li>
{% endif %}
{% endblock %}
{% block content %}
+<script>
+$(document).ready(function() {
+ $(this).keydown(function(e) {
+ if (e.keyCode == '13') {
+ $("#_loginForm").submit();
+ }
+ });
+});
+</script>
+
{% if form.errors %}
<p class="login-error">{% trans "Your username and password didn't match. Please try again." %}</p>
{% endif %}
{{ form.password.label_tag }}
{{ form.password }}
</p>
-<span style="align: right; font-weight: bold;"><a href="{% url telemeta-password-reset %}">{% trans "Password forgotten" %} ?</a></span>
-<input class="submit" type="submit" value="{% trans "Sign in" %}" />
+<div style="margin-top: 2em;">
+<span style="align: right; font-weight: bold; margin-right: 2em;"><a href="{% url telemeta-password-reset %}">{% trans "Password forgotten" %} ?</a></span>
+<a href="#" class="component_icon button" id="action_red" onclick="$('#_loginForm').submit();"><img src="{{STATIC_URL}}telemeta/images/password.png" alt="" style="vertical-align:middle" /> {% trans "Sign in" %}</a>
<input type="hidden" name="next" value="{{ next }}" />
+</div>
</form>
{% endblock %}
def from_course_type(contents, type):
if contents:
return contents.filter(course_type=type)
-
+
@register.filter
def from_doc_type(contents, type):
if contents:
return contents.filter(type=type)
-
+
@register.filter
-def from_periods(contents, periods):
+def from_period(contents, period):
if contents:
- return contents.filter(period__in=periods)
-
+ return contents.filter(period=period)
+
@register.assignment_tag
def get_all_professors():
return Professor.objects.all().order_by('user__first_name')
media = MediaView()
urlpatterns = patterns('',
-# url(r'^$', HomeView.as_view(), name='teleforma-home'),
- url(r'^$', 'django.contrib.auth.views.login', {'template_name': 'telemeta/login.html'},
- name="teleforma-login"),
- # Telemeta
- url(r'^', include('telemeta.urls')),
+
+ # login
+ url(r'^login/$', 'django.contrib.auth.views.login', {'template_name': 'telemeta/login.html'},
+ name="teleforma-login"),
# Help
url(r'^help/$', HelpView.as_view(), name="teleforma-help"),
+ # Home
+ url(r'^$', HomeRedirectView.as_view(), name="teleforma-home"),
+
+ # Telemeta
+ url(r'^', include('telemeta.urls')),
+
# Desk
url(r'^desk/$', CoursesView.as_view(), name="teleforma-desk"),
+ url(r'^desk/periods/(?P<period_id>.*)/$', PeriodView.as_view(), name="teleforma-desk-period"),
url(r'^desk/courses/(?P<pk>.*)/$', CourseView.as_view(), name="teleforma-course-detail"),
url(r'^desk/medias/(?P<pk>.*)/detail/$', MediaView.as_view(), name="teleforma-media-detail"),
url(r'^users/by_course/(?P<id>.*)/export/$', user_export.by_course,
name="teleforma-course-users-export"),
-
-# CSS+Images (FIXME: for developement only)
- url(r'^teleforma/css/(?P<path>.*)$', 'django.views.static.serve',
- {'document_root': htdocs_forma+'css'},
- name="teleforma-css"),
- url(r'images/(?P<path>.*)$', 'django.views.static.serve',
- {'document_root': htdocs_forma+'images'},
- name="teleforma-images"),
- url(r'^js/(?P<path>.*)$', 'django.views.static.serve',
- {'document_root': htdocs_forma+'js'},
- name="teleforma-js"),
-
# JSON RPC
url(r'json/$', jsonrpc_site.dispatch, name='jsonrpc_mountpoint'),
return courses
-def get_courses(user, date_order=False, num_order=False, num_courses=False):
+def get_courses(user, date_order=False, num_order=False, num_courses=False, period=None):
if settings.TELEFORMA_E_LEARNING_TYPE == 'CRFPA':
from teleforma.views.crfpa import get_crfpa_courses
- return get_crfpa_courses(user, date_order, num_order)
+ return get_crfpa_courses(user, date_order, num_order, period)
elif settings.TELEFORMA_E_LEARNING_TYPE == 'AE':
from teleforma.views.ae import get_ae_courses
- return get_ae_courses(user, date_order, num_order)
+ return get_ae_courses(user, date_order, num_order, period)
def stream_from_file(__file):
return periods
+class HomeRedirectView(View):
+
+ def get(self, request):
+ if request.user.is_authenticated():
+ periods = get_periods(request.user)
+ if len(periods) > 1:
+ return HttpResponseRedirect(reverse('teleforma-desk-period', kwargs={'period_id': periods[0].id}))
+ else:
+ return HttpResponseRedirect(reverse('teleforma-desk'))
+ else:
+ return HttpResponseRedirect(reverse('teleforma-login'))
+
+
class CourseView(DetailView):
model = Course
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)
+ context['period'] = get_periods(self.request.user)[0]
return context
@method_decorator(login_required)
return super(CoursesView, self).dispatch(*args, **kwargs)
+class PeriodView(CoursesView):
+
+ def get_queryset(self):
+ self.period = Period.objects.get(id=int(self.kwargs['period_id']))
+ self.all_courses = get_courses(self.request.user, date_order=True, period=self.period)
+ return self.all_courses[:5]
+
+ def get_context_data(self, **kwargs):
+ context = super(PeriodView, self).get_context_data(**kwargs)
+ context['period'] = self.period
+ return context
+
+
class MediaView(DetailView):
model = Media
from teleforma.views.core import *
-def get_crfpa_courses(user, date_order=False, num_order=False):
+def get_crfpa_courses(user, date_order=False, num_order=False, period=None):
courses = []
if not user.is_authenticated():