]> git.parisson.com Git - teleforma.git/commitdiff
WIP
authortest test <yoanl@pilotsystems.net>
Thu, 15 Jul 2021 08:54:17 +0000 (10:54 +0200)
committerYoan Le Clanche <yoanl@pilotsystems.net>
Thu, 15 Jul 2021 08:54:17 +0000 (10:54 +0200)
teleforma/templates/teleforma/course_detail.html
teleforma/templatetags/webclass.py
teleforma/views/core.py
teleforma/webclass/admin.py
teleforma/webclass/migrations/0005_webclassrecord_category.py [new file with mode: 0644]
teleforma/webclass/models.py
teleforma/webclass/templates/webclass/inc/webclass_corrections_list.html [new file with mode: 0644]
teleforma/webclass/templates/webclass/inc/webclass_list.html
teleforma/webclass/templates/webclass/webclass_record.html [new file with mode: 0644]

index 77ce22841cda936aece893d763935e27b20004cb..aa2fd357c9f2ed304c219238d9c8e8e3e44154eb 100644 (file)
     {% block webclass %}
     {% include "webclass/inc/webclass_list.html" %}
     {% endblock %}
+    
+  </div>
+
+  <div class="course">
+    <div class="course_title">{{ course.title }} - Corrections de copies{% if course.description %} -
+      {{ course.description }}{% endif %}
+    </div>
+    {% block webclass_corrections %}
+    {% include "webclass/inc/webclass_corrections_list.html" %}
+    {% endblock %}
   </div>
   {% endwith %}
   {% endfor %}
index 8bdb649a6caf0ea6230e59f42f68d4ddf9428311..03903ab48d2a3f5a5505ee3ee0711329ee08919b 100644 (file)
@@ -12,3 +12,10 @@ def add_records_links(context):
     return {
         'periods':periods,
     }
+
+
+@register.inclusion_tag('webclass/webclass_record.html', takes_context=True)
+def webclass_record(context, record):
+    return {
+        'record':record
+    }
index 3a3624f0442e5cbed016d721c7b4757ed79e89dc..af1d65eb528f717cfb9b49ad92b578204a824edf 100644 (file)
@@ -492,12 +492,14 @@ class CourseView(CourseAccessMixin, DetailView):
         context['webclass'] = webclass
         context['webclass_slot'] = webclass_slot
 
+        records = {}
         try:
-            context['webclass_records'] = WebclassRecord.get_records(
-                context['period'], course)
+            records = WebclassRecord.get_records(context['period'], course)
         except Exception as e:
             print(e)
             context['webclass_error'] = True
+        context['webclass_records'] = records.get(WebclassRecord.WEBCLASS)
+        context['webclass_corrections_records'] = records.get(WebclassRecord.CORRECTION)
         return context
 
     @method_decorator(access_required)
index f9b5dbdf95a3324c97f3a747a6906597d3e41bec..52bf6a6c8279374b0c0068c446f90c159d9b37ce 100644 (file)
@@ -22,8 +22,8 @@ class WebclassAdmin(admin.ModelAdmin):
     search_fields = ['id', 'course__code', 'course__title']
 
 class WebclassRecordAdmin(admin.ModelAdmin):
-    list_filter = ('course', 'period')
-    list_display = ('course', 'period', 'created')
+    list_filter = ('course', 'period', 'category')
+    list_display = ('course', 'period', 'category', 'created')
     search_fields = ['id', 'course__code', 'course__title']
 
     # def get_form(self, request, obj=None, **kwargs):
diff --git a/teleforma/webclass/migrations/0005_webclassrecord_category.py b/teleforma/webclass/migrations/0005_webclassrecord_category.py
new file mode 100644 (file)
index 0000000..4b91243
--- /dev/null
@@ -0,0 +1,18 @@
+# Generated by Django 3.2.3 on 2021-07-13 16:08
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('webclass', '0004_auto_20210616_1654'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='webclassrecord',
+            name='category',
+            field=models.CharField(choices=[('WC', 'Webclass'), ('CC', 'Correction de copie')], default='WC', max_length=2, verbose_name='Catégorie'),
+        ),
+    ]
index a4f3ba4089582f3232d480534e5318908a24ec2a..d33e43c31a02af6ff845901a0ea2d6aecf12b971 100644 (file)
@@ -380,6 +380,19 @@ class WebclassRecord(models.Model):
         'BBBServer', related_name='webclass_records', verbose_name='Serveur BBB', on_delete=models.CASCADE)
     created = models.DateTimeField("Date de la conférence", auto_now_add=True)
 
+    WEBCLASS = 'WC'
+    CORRECTION = 'CC'
+    CATEGORY_CHOICES = [
+        (WEBCLASS, 'Webclass'),
+        (CORRECTION, 'Correction de copie'),
+    ]
+    category = models.CharField(
+        "Catégorie",
+        max_length=2,
+        choices=CATEGORY_CHOICES,
+        default=WEBCLASS,
+    )
+
     class Meta(MetaCore):
         db_table = app_label + '_' + 'webclass_record'
         verbose_name = 'enregistrement'
@@ -391,9 +404,21 @@ class WebclassRecord(models.Model):
     @staticmethod
     def get_records(period, course):
         record_ids = set()
+        # id : category mapping
+        category_mapping = {}
         for record in WebclassRecord.objects.filter(period=period, course=course):
             record_ids.add(record.record_id)
+            category_mapping[record.record_id] = record.category
         if not record_ids:
             return []
         records = get_records_from_bbb(recording_id=','.join(record_ids))
-        return records
+
+        # group records by category
+        categories = {}
+        for record in records:
+            category = category_mapping[record['id']]
+            if category not in categories:
+                categories[category] = []
+            categories[category].append(record)
+
+        return categories
diff --git a/teleforma/webclass/templates/webclass/inc/webclass_corrections_list.html b/teleforma/webclass/templates/webclass/inc/webclass_corrections_list.html
new file mode 100644 (file)
index 0000000..2007a7d
--- /dev/null
@@ -0,0 +1,19 @@
+{% load teleforma_tags webclass %}
+{% load i18n %}
+
+{% if webclass_corrections_records %}
+<div class="course_content content_video">
+    <table class="listing" width="100%">
+        <tbody>
+           
+            {% for record in webclass_corrections_records %}
+            {% webclass_record record %}
+            {% endfor %}
+        </tbody>
+    </table>
+</div>
+{% else %}
+<div class="course_content">
+    <p>Aucun document</p>
+</div>
+{% endif %}
\ No newline at end of file
index 962b878639943b44d9def2492d90ac93f702e936..f891db3cad93d8ae22a4380a8d50db6185be9824 100644 (file)
@@ -1,4 +1,4 @@
-{% load teleforma_tags %}
+{% load teleforma_tags webclass %}
 {% load i18n %}
 
 {% if webclass_slot or webclass_records %}
             </tr>
             {% endif %}
             {% for record in webclass_records %}
-            <tr>
-                <td {% if forloop.first %}class="border-top" {% endif %} style="width:200px">
-                    <a href="{% url 'teleforma-webclass-record' %}?url={{record.url}}" title="{% trans "View" %}">
-                        <img src="{{ record.preview }}" style="width:176px" alt="{% trans 'Click here' %}" />
-                        <div>Cliquez-ici</div>
-                    </a>
-                </td>
-                <td {% if forloop.first %}class="border-top" {% endif %} style="padding-left: 1em;">
-                    <div>
-                        <dl class="listing" style="font-size: 1.2em;">
-                            {% if record.slot %}
-                                <dt>{% trans "Professor" %}</dt>
-                                <dd>{{ record.slot.professor }}</dd>
-                            {% endif %}
-                            <dt>{% trans "Begin" %}</dt>
-                            <dd>{{ record.start_date }}</dd>
-                        </dl>
-                    </div>
-                </td>
-                <div style="padding-left: 1em;">
-
-                </div>
-            </tr>
+            {% webclass_record record %}
             {% endfor %}
         </tbody>
     </table>
 </div>
+{% else %}
+<div class="course_content">
+    <p>Aucun document</p>
+</div>
 {% endif %}
\ No newline at end of file
diff --git a/teleforma/webclass/templates/webclass/webclass_record.html b/teleforma/webclass/templates/webclass/webclass_record.html
new file mode 100644 (file)
index 0000000..ae78052
--- /dev/null
@@ -0,0 +1,25 @@
+{% load i18n %}
+
+<tr>
+    <td {% if forloop.first %}class="border-top" {% endif %} style="width:200px">
+        <a href="{% url 'teleforma-webclass-record' %}?url={{record.url}}" title="{% trans "View" %}">
+            <img src="{{ record.preview }}" style="width:176px" alt="{% trans 'Click here' %}" />
+            <div>Cliquez-ici</div>
+        </a>
+    </td>
+    <td {% if forloop.first %}class="border-top" {% endif %} style="padding-left: 1em;">
+        <div>
+            <dl class="listing" style="font-size: 1.2em;">
+                {% if record.slot %}
+                <dt>{% trans "Professor" %}</dt>
+                <dd>{{ record.slot.professor }}</dd>
+                {% endif %}
+                <dt>{% trans "Begin" %}</dt>
+                <dd>{{ record.start_date }}</dd>
+            </dl>
+        </div>
+    </td>
+    <div style="padding-left: 1em;">
+
+    </div>
+</tr>
\ No newline at end of file