return 0
def seminar_validated(user, seminar):
- validated = [False]
+ validated = []
questions = seminar.question.filter(status=3)
if questions:
for question in questions:
- answers = Answer.objects.filter(question=question, user=user)
+ answers = Answer.objects.filter(question=question, user=user,
+ validated=True, treated=True)
if answers:
- if answers[0].validated:
- validated.append(True)
- else:
- validated.append(False)
+ validated.append(True)
+ else:
+ validated.append(False)
return not False in validated
return False
<p>{{ form.intro }}</p>
{% endif %}
- <form action="" id="_Form" method="post"
+ <form action="" id="_Form" method="post"
{% if form_for_form.is_multipart %}enctype="multipart/form-data"{% endif %}>
{% csrf_token %}
{{ form_for_form.as_p }}
-
+
<div class="form-button">
<a href="#" class="component_icon button icon_ok" onclick="$('#_Form').submit(); return false;"> {{ form.button_text }}</a>
</div>
{% for question in questions.all %}
<tr>
<td {% if forloop.first %}class="border-top"{% endif %} width="35%">
- <a href="{% url teleforma-question-answer question.id %}">{{ question.title }}{% if question.rank %} n°{{ question.rank }}{% endif %}</a></td>
+ <a href="{% url teleforma-question-answer seminar.id question.id %}">{{ question.title }}{% if question.rank %} n°{{ question.rank }}{% endif %}</a></td>
<td {% if forloop.first %}class="border-top"{% endif %} width="60%">
{% if question|submitted:user and not question|validated:user %}
{% trans "submitted on" %} {{ question|submitted:user }}
{% for question in questions.all %}
<tr>
<td {% if forloop.first %}class="border-top"{% endif %} width="95%">
- <a href="{% url teleforma-question-answer question.id %}">{{ question.title }}{% if question.rank %} n°{{ question.rank }}{% endif %}</a></td>
+ <a href="{% url teleforma-question-answer seminar.id question.id %}">{{ question.title }}{% if question.rank %} n°{{ question.rank }}{% endif %}</a></td>
<td {% if forloop.first %}class="border-top"{% endif %} width="5%" align="center">
{% if question|submitted:user and not question|validated:user %}
<img src="{{ STATIC_URL }}teleforma/images/chronometer.png" style="vertical-align:middle" alt="" title="{% trans "Waiting for validation" %}" />
<div class="desk_center" id="desk_center">
<div class="course">
-
+
<div class="course_title">
<a href="{% url teleforma-seminar-detail seminar.id %}">{{ seminar.title }}</a>
</div>
{% block course_content %}
-
+
<div class="course_content">
<div class="course_subtitle">
<h3><img src="{{ STATIC_URL }}telemeta/images/item_title.png" width="10px" alt="" /> {% trans "Informations" %}</h3>
</div>
<div class="course_description">
- {% include "teleforma/inc/seminar_description.html" %}
+ {% include "teleforma/inc/seminar_description.html" %}
</div>
{% if messages %}
<div class="messages">
</div>
{% endif %}
</div>
-
+
{% with seminar.docs_1 as docs %}
<div class="course_content">
<div class="course_subtitle">
{% include "teleforma/inc/media_package_list.html" %}
</div>
{% endwith %}
-
+
{% with seminar.docs_2 as docs %}
<div class="course_content">
</div>
{% endwith %}
{% endif %}
-
+
{% if seminar_validated and seminar_progress == 100 %}
<div class="course_content">
<div class="course_subtitle">
{% block course %}
<div class="desk_center">
+ {% if messages %}
+ <div class="messages">
+ {% for message in messages %}
+ <div{% if message.tags %} class="{{ message.tags }}"{% endif %}>{{ message }}</div>
+ {% endfor %}
+ </div>
+ {% endif %}
+
{% for seminar in object_list %}
-
+
<div class="course">
<div class="course_title">
<a href="{% url teleforma-seminar-detail seminar.id %}">{{ seminar.title }}</a>
<div class="course_description">
<a href="{% url teleforma-seminar-detail seminar.id %}">
<table>
- <tr><td width="97%">
- {% include "teleforma/inc/seminar_description.html" %}
+ <tr><td width="97%">
+ {% include "teleforma/inc/seminar_description.html" %}
</td>
<td>
<a href="{% url teleforma-seminar-detail seminar.id %}" class="component_icon button icon_next"> {% trans "Access" %}</a>
url(r'^desk/medias/(?P<pk>.*)/detail/$', MediaView.as_view(), name="teleforma-media-detail"),
url(r'^desk/medias/(?P<pk>.*)/download/$', media.download, name="teleforma-media-download"),
- url(r'^desk/seminars/(?P<id>.*)/media/(?P<pk>.*)/video/$',
- SeminarMediaView.as_view(template_name='teleforma/seminar_media_video.html'),
+ url(r'^desk/seminars/(?P<id>.*)/media/(?P<pk>.*)/video/$',
+ SeminarMediaView.as_view(template_name='teleforma/seminar_media_video.html'),
name="teleforma-media-video"),
- url(r'^desk/seminars/(?P<id>.*)/media/(?P<pk>.*)/audio/$',
+ url(r'^desk/seminars/(?P<id>.*)/media/(?P<pk>.*)/audio/$',
SeminarMediaView.as_view(template_name='teleforma/seminar_media_audio.html'),
name="teleforma-media-audio"),
- url(r'^desk/seminars/(?P<pk>.*)/preview/$',
- SeminarMediaPreviewView.as_view(),
+ url(r'^desk/seminars/(?P<pk>.*)/preview/$',
+ SeminarMediaPreviewView.as_view(),
name="teleforma-media-preview-video"),
url(r'^desk/documents/(?P<pk>.*)/detail/$', DocumentView.as_view(),
name="teleforma-conference-record"),
# Questions
- url(r'^desk/questions/(?P<pk>.*)/$', AnswerView.as_view(),
+ url(r'^desk/seminars/(?P<id>.*)/questions/(?P<pk>.*)/$', AnswerView.as_view(),
name="teleforma-question-answer"),
url(r'^desk/answers/$', AnswersView.as_view(), name="teleforma-answers"),
url(r'^desk/answers/(?P<pk>.*)/$', AnswerDetailView.as_view(), name="teleforma-answer-detail"),
url(r'^desk/seminars/(?P<pk>.*)/form/$', evaluation_form_detail, name="teleforma-seminar-form"),
# Testimonial
- url(r'^desk/seminars/(?P<pk>.*)/testimonial/$', TestimonialView.as_view(),
+ url(r'^desk/seminars/(?P<pk>.*)/testimonial/$', TestimonialView.as_view(),
name="teleforma-seminar-testimonial"),
- url(r'^desk/seminars/(?P<pk>.*)/testimonial/download/$', TestimonialDownloadView.as_view(),
+ url(r'^desk/seminars/(?P<pk>.*)/testimonial/download/$', TestimonialDownloadView.as_view(),
name="teleforma-seminar-testimonial-download"),
- url(r'^desk/testimonials/$', TestimonialListView.as_view(),
+ url(r'^desk/testimonials/$', TestimonialListView.as_view(),
name="teleforma-testimonials"),
# Postman
else:
SeminarRevision.objects.create(seminar=seminar, user=user)
-class SeminarView(DetailView):
+
+class SeminarAccessMixin(object):
+
+ def render_to_response(self, context):
+ seminar = context['seminar']
+ if not seminar in all_seminars(self.request)['all_seminars']:
+ messages.warning(self.request, _("You do NOT have access to this resource and then have been redirected to your desk."))
+ return redirect('teleforma-desk')
+ return super(SeminarAccessMixin, self).render_to_response(context)
+
+
+class SeminarView(SeminarAccessMixin, DetailView):
model = Seminar
template_name='teleforma/seminar_detail.html'
@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
+ # self.pk = kwargs.get('pk')
+ # seminar = self.get_object()
return super(SeminarView, self).dispatch(*args, **kwargs)
+ # def get_object(self, queryset=None):
+ # return Media.objects.get(id=self.pk)
+
def get_context_data(self, **kwargs):
context = super(SeminarView, self).get_context_data(**kwargs)
seminar = self.get_object()
user = self.request.user
progress = seminar_progress(user, seminar)
validated = seminar_validated(user, seminar)
+ context['seminar'] = seminar
context['seminar_progress'] = progress
context['seminar_validated'] = validated
if progress == 100 and not validated:
model = Seminar
template_name='teleforma/seminars.html'
- def get_queryset(self):
- return all_seminars(self.request, date_order=True)['all_seminars']
-
@method_decorator(login_required)
def dispatch(self, *args, **kwargs):
return super(SeminarsView, self).dispatch(*args, **kwargs)
+ def get_queryset(self):
+ return all_seminars(self.request, date_order=True)['all_seminars']
-class AnswerView(FormView):
+class AnswerView(SeminarAccessMixin, FormView):
model = Answer
form_class = AnswerForm
return reverse('teleforma-seminar-detail', kwargs={'pk':self.question.seminar.id})
-class SeminarMediaView(MediaView):
+class SeminarMediaView(SeminarAccessMixin, MediaView):
template_name = 'teleforma/seminar_media_video.html'