From b9213b060745af1518713100f6541da2f300b214 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 27 Nov 2018 11:56:52 +0100 Subject: [PATCH] working on https://trackers.pilotsystems.net/probarreau/0358 --- .../exam/templates/exam/script_detail.html | 42 +++- teleforma/fields.py | 49 +++- teleforma/forms.py | 19 +- teleforma/static/teleforma/css/teleforma.css | 93 +++++++ teleforma/templates/postman/base_write.html | 227 +++++++++++++----- teleforma/templatetags/teleforma_tags.py | 33 ++- teleforma/urls.py | 2 + teleforma/views/crfpa.py | 46 ++++ 8 files changed, 413 insertions(+), 98 deletions(-) diff --git a/teleforma/exam/templates/exam/script_detail.html b/teleforma/exam/templates/exam/script_detail.html index a51087e7..4843e622 100644 --- a/teleforma/exam/templates/exam/script_detail.html +++ b/teleforma/exam/templates/exam/script_detail.html @@ -3,16 +3,16 @@ {% load teleforma_tags %} {% load i18n %} {% load static %} -{% load webviewer %} +{% load pdfannotator %} {% load thumbnail %} {% block extra_javascript %} - - - +{# #} +{# #} +{# #} - - +{# #} +{# #} - -
-

{% block pm_write_title %}{% endblock %}

- -{% if user.student.all or user.is_staff or user.quotas.all %} -
- -{% trans "Vous pouvez ici échanger des messages avec les professeurs et les administrateurs." %} -
-{% trans "Pour les questions concernant l'organisation des cours, le planning, les documents de cours ou les copies, adressez-vous à Admin-CRFPA." %} -
-{% trans "Pour les questions concernant uniquement l'accès à la plateforme et aux médias vidéo ou audio, lire d'abord" %} la page d'aide {% trans "puis adressez-vous à Support technique." %} -

- - - - - -
-{% endif %} - -
-
{% csrf_token %} - -{% block pm_write_recipient %}{% endblock %} -{{ form.as_table }} -
-
-{% trans "Send" %} -
-
- - + +
+

{% block pm_write_title %}{% endblock %}

+ + {% if user.student.all or user.is_staff or user.quotas.all %} +
+ + {% trans "Vous pouvez ici échanger des messages avec les professeurs et les administrateurs." %} +
+ {% trans "Pour les questions concernant l'organisation des cours, le planning, les documents de cours ou les copies, adressez-vous à Admin-CRFPA." %} +
+ {% trans "Pour les questions concernant uniquement l'accès à la plateforme et aux médias vidéo ou audio, lire d'abord" %} + la page + d'aide {% trans "puis adressez-vous à Support technique." %} +

+ +
+ {% endif %} +
+ +
{% csrf_token %} + + + {{ form.errors.recipients }} + + + + +
+ +
+ + +
+ + + + +
+ + + + {% block pm_write_recipient %}{% endblock %} + {% for field in form.visible_fields %} + {% if field.name != 'course' %} + + + + + {% endif %} + {% endfor %} +
{{ field.label_tag }} + {{ field.errors }} + {{ field }} + {{ field.help_text }} +
+
+ {% trans "Send" %} +
+
+ + + {% endblock %} diff --git a/teleforma/templatetags/teleforma_tags.py b/teleforma/templatetags/teleforma_tags.py index 304feb45..63188599 100644 --- a/teleforma/templatetags/teleforma_tags.py +++ b/teleforma/templatetags/teleforma_tags.py @@ -33,23 +33,8 @@ # Authors: Guillaume Pellerin from django import template -from django.utils.http import urlquote -from django.core.urlresolvers import reverse -from django.utils import html -from django import template -from django.utils.text import capfirst -from django.utils.translation import ungettext -from docutils.core import publish_parts -from django.utils.encoding import smart_str, force_unicode -from django.utils.safestring import mark_safe -from django import db from django.shortcuts import get_object_or_404 -import re -import os -import datetime -from django.conf import settings -from django.template.defaultfilters import stringfilter -import django.utils.timezone as timezone +import json from timezones.utils import localtime_for_timezone from django.utils.translation import ugettext_lazy as _ from urlparse import urlparse @@ -57,7 +42,6 @@ from urlparse import urlparse from teleforma.models.core import Document from teleforma.models.crfpa import Course, NewsItem from teleforma.views import get_courses -from teleforma.models import * from teleforma.exam.models import * register = template.Library() @@ -160,6 +144,21 @@ def from_period(contents, period): def get_all_professors(): return Professor.objects.all() +@register.assignment_tag +def get_all_professors_with_courses(): + professors = [] + for professor in Professor.objects.order_by('user__last_name').all(): + name = professor.user.last_name + professor.user.first_name + if name: + professors.append({ + 'username':professor.user.username, + 'name':professor.user.last_name + professor.user.first_name, + 'courses':json.dumps([course.id for course in professor.courses.all()]) + }) + return professors + + + @register.assignment_tag def get_all_admins(): return User.objects.filter(is_superuser=True).order_by('last_name') diff --git a/teleforma/urls.py b/teleforma/urls.py index 42030dab..ba9a2733 100644 --- a/teleforma/urls.py +++ b/teleforma/urls.py @@ -111,8 +111,10 @@ urlpatterns = patterns('', name="teleforma-appointment-cancel"), # Postman + url(r'^messages/write/(?:(?P[^/#]+)/)?$', WriteView.as_view(), name='postman_write'), url(r'^messages/', include('postman.urls')), + # Users url(r'^users/training/(?P.*)/iej/(?P.*)/course/(?P.*)/list/$', UsersView.as_view(), name="teleforma-users"), diff --git a/teleforma/views/crfpa.py b/teleforma/views/crfpa.py index 0b5da871..aa2d3e75 100644 --- a/teleforma/views/crfpa.py +++ b/teleforma/views/crfpa.py @@ -33,8 +33,11 @@ # Authors: Guillaume Pellerin from teleforma.models.core import Period from teleforma.views.core import * +from teleforma.forms import WriteForm from registration.views import * from extra_views import CreateWithInlinesView, UpdateWithInlinesView, InlineFormSet +from postman.views import WriteView as PostmanWriteView +from postman.forms import AnonymousWriteForm from django.utils.translation import ugettext_lazy as _ from django.views.decorators.csrf import csrf_exempt from django.db.models import Q @@ -592,3 +595,46 @@ class NewsItemList(ListView): if course_id: query = query.filter(course__id=self.request.GET.get('course_id')) return query + + +class WriteView(PostmanWriteView): + """ + Display a form to compose a message. + + Optional URLconf name-based argument: + ``recipients``: a colon-separated list of usernames + Optional attributes: + ``form_classes``: a 2-tuple of form classes + ``autocomplete_channels``: a channel name or a 2-tuple of names + ``template_name``: the name of the template to use + + those of ComposeMixin + + """ + form_classes = (WriteForm, AnonymousWriteForm) + + # def get_initial(self): + # initial = super(WriteView, self).get_initial() + # if self.request.method == 'GET': + # initial.update(self.request.GET.items()) # allow optional initializations by query string + # recipients = self.kwargs.get('recipients') + # if recipients: + # # order_by() is not mandatory, but: a) it doesn't hurt; b) it eases the test suite + # # and anyway the original ordering cannot be respected. + # user_model = get_user_model() + # usernames = list(user_model.objects.values_list(user_model.USERNAME_FIELD, flat=True).filter( + # is_active=True, + # **{'{0}__in'.format(user_model.USERNAME_FIELD): [r.strip() for r in recipients.split(':') if r and not r.isspace()]} + # ).order_by(user_model.USERNAME_FIELD)) + # if usernames: + # initial['recipients'] = ', '.join(usernames) + # return initial + + # def get_form_kwargs(self): + # import pdb;pdb.set_trace() + # kwargs = super(WriteView, self).get_form_kwargs() + # if isinstance(self.autocomplete_channels, tuple) and len(self.autocomplete_channels) == 2: + # channel = self.autocomplete_channels[self.request.user.is_anonymous()] + # else: + # channel = self.autocomplete_channels + # kwargs['channel'] = channel + # return kwargs \ No newline at end of file -- 2.39.5