#python venv
py_env
prod.env
+
+README_pilot.rst
\ No newline at end of file
-from optparse import make_option
from django.conf import settings
-from django.core.management.base import BaseCommand, CommandError
+from django.core.management.base import BaseCommand
from django.contrib.auth.models import User
-from django.template.defaultfilters import slugify
from django.utils import translation
from django.conf import settings
from teleforma.exam.models import *
-import logging
-import codecs
-import time, os
class Command(BaseCommand):
site = Site.objects.all()[0]
subject = 'Erreur dans la transmission de votre copie'
scripts = Script.objects.filter(file='scripts/2014/07/22/home')
- print scripts.count()
+ print(scripts.count())
for script in scripts:
script.reject()
context = {'script': script, 'site': site}
text = render_to_string('exam/messages/script_fix.txt', context)
- print text
+ print(text)
mess = Message(sender=sender, recipient=script.author, subject=subject[:119], body=text)
mess.moderation_status = 'a'
mess.save()
--- /dev/null
+# Generated by Django 3.2.3 on 2021-12-10 14:11
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+ dependencies = [
+ ('teleforma', '0014_alter_profile_user'),
+ ]
+
+ operations = [
+ migrations.AddIndex(
+ model_name='conference',
+ index=models.Index(fields=['course', 'course_type', 'period', 'streaming', '-date_begin'], name='teleforma_c_course__5d8618_idx'),
+ ),
+ migrations.AddIndex(
+ model_name='document',
+ index=models.Index(fields=['course', 'is_published', '-date_added'], name='teleforma_d_course__b0ecc5_idx'),
+ ),
+ migrations.AddIndex(
+ model_name='media',
+ index=models.Index(fields=['course', 'course_type', 'period', 'is_published', '-date_modified'], name='teleforma_m_course__19f376_idx'),
+ ),
+ ]
verbose_name = _('conference')
ordering = ['-date_begin']
+ indexes = [
+ models.Index(fields=['course', 'course_type', 'period', 'streaming', '-date_begin' ]),
+ ]
class StreamingServer(models.Model):
class Meta(MetaCore):
db_table = app_label + '_' + 'document'
ordering = ['-date_added']
+ indexes = [
+ models.Index(fields=['course', 'is_published', '-date_added' ]),
+ ]
class DocumentSimple(MediaBase):
class Meta(MetaCore):
db_table = app_label + '_' + 'media'
ordering = ['-date_modified', '-conference__session',]
+ indexes = [
+ models.Index(fields=['course', 'course_type', 'period', 'is_published', '-date_modified' ]),
+ ]
class NamePaginator(object):
{% load teleforma_tags %}
{% load i18n %}
-{% with course.conference.all|from_course_type:type|streaming_only as conferences %}
-{% if conferences|from_period:period %}
+{% course_conferences as conference %}
+
+{% if conferences %}
<div class="course_content content_video">
<div class="course_subtitle">
<h3><img src="/static/teleforma/images/item_title.png" width="10px" alt="" /> {% trans "Live conferences"%}</h3>
</div>
<table class="listing" width="100%">
<tbody>
- {% for conference in conferences|from_period:period %}
+ {% for conference in conferences %}
{% for stream in conference.livestream.all %}
{% if stream.stream_type == 'webm' %}
<tr>
</table>
</div>
{% endif %}
-{% endwith %}
{% load teleforma_tags %}
{% load i18n %}
-{% if course.document.all|from_course_type:type|from_period:period|published %}
+{% course_docs_by_type as documents %}
+
+{% if documents %}
<div class="course_content">
<div class="course_subtitle">
<h3><img src="/static/teleforma/images/item_title.png" width="10px" alt="" /> {% trans "Documents"%}</h3>
</div>
-{% with course.document.all as docs %}
-{% for doc_type in doc_types %}
-{% if docs|from_course_type:type|from_doc_type:doc_type|from_period:period and not type_counter > 2 %}
+{% for doc_type, docs in documents %}
+{% if docs and not type_counter > 2 %}
<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_period:period|published %}
+ {% for doc in docs %}
+ {% url 'teleforma-document-view' doc.id as docurl %}
<tr>
- <td {% if forloop.first %}class="border-top"{% endif %} width="60%">{% if doc.file %}<a href="{% url 'teleforma-document-view' doc.id %}" target="_blank" title="{% trans "View" %}"><img src="/static//teleforma/images/application-msword.png" style="vertical-align:middle" alt="" />{% endif %} {{ doc.title }}{% if doc.file %}</a>{% endif %}</td>
+ <td {% if forloop.first %}class="border-top"{% endif %} width="60%">{% if doc.file %}<a href="{{ docurl }}" target="_blank" title="{% trans "View" %}"><img src="/static//teleforma/images/application-msword.png" style="vertical-align:middle" alt="" />{% endif %} {{ doc.title }}{% if doc.file %}</a>{% endif %}</td>
<td {% if forloop.first %}class="border-top"{% endif %} width="35%">{{ doc.date_added }}</td>
- <td {% if forloop.first %}class="border-top"{% endif %} width="5%" align="center">{% if doc.file %}<a href="{% url 'teleforma-document-download' doc.id %}"><img src="/static/teleforma/images/download.png" style="vertical-align:middle" alt="" title="{% trans "Download" %}" /></a>{% endif %}</td>
+ <td {% if forloop.first %}class="border-top"{% endif %} width="5%" align="center">{% if doc.file %}<a href="{{ docurl }}"><img src="/static/teleforma/images/download.png" style="vertical-align:middle" alt="" title="{% trans "Download" %}" /></a>{% endif %}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
{% endfor %}
-{% endwith %}
</div>
{% load thumbnail %}
{% load i18n %}
-{% if course.media.all|from_course_type:type|from_period:period %}
+{% course_media as all_media %}
+
+{% if all_media %}
<div class="course_content content_video">
<div class="course_subtitle">
<h3><img src="/static/teleforma/images/item_title.png" width="10px" alt="" /> {% trans "Conférences en différé" %}</h3>
</div>
<table class="listing" width="100%">
<tbody>
- {% for media in course.media.all|from_course_type:type|from_period:period %}
- {% if media.is_published or user.is_staff and not list_view %}
+ {% for media in all_media %}
{% if media.type == 'webm' or media.type == 'mp4' %}
<tr>
<td {% if forloop.first %}class="border-top"{% endif %} width="230px" style="vertical-align:middle">
</td>
</tr>
{% endif %}
- {% endif %}
{% endfor %}
</tbody>
</table>
from ..models.crfpa import IEJ, Course, NewsItem, Training
from ..views import get_courses
+from collections import defaultdict
+
register = template.Library()
# more translations for template variables
'user_id': context.request.user.id
}
}
+
+
+@register.simple_tag(takes_context=True)
+def course_docs_by_type(context):
+ course = context['course']
+ docs = course.document.filter(is_published=True,
+ periods__in=(context['period'],),
+ course_type=context['type'])
+ res = []
+ by_types = defaultdict(list)
+ for doc in docs:
+ by_types[doc.type].append(doc)
+ for doc_type in context['doc_types']:
+ docs = by_types[doc_type]
+ if docs:
+ res.append((doc_type, docs))
+ return res
+
+@register.simple_tag(takes_context=True)
+def course_conferences(context):
+ course = context['course']
+ confs = course.conference.filter(streaming=True,
+ period=context['period'],
+ course_type=context['type'])
+ return list(confs)
+
+@register.simple_tag(takes_context=True)
+def course_media(context):
+ course = context['course']
+ media = course.media.filter(period=context['period'],
+ course_type=context['type'])
+ if not context['user'].is_staff or context['list_view']:
+ media = media.filter(is_published = True)
+ return list(media)