]> git.parisson.com Git - teleforma.git/commitdiff
"New" badge on not read items : https://trackers.pilotsystems.net/prebarreau/0952 master
authorYoan Le Clanche <yoanl@pilotsystems.net>
Tue, 16 Dec 2025 14:14:22 +0000 (15:14 +0100)
committerYoan Le Clanche <yoanl@pilotsystems.net>
Tue, 16 Dec 2025 14:14:22 +0000 (15:14 +0100)
teleforma/static/teleforma/css/teleforma.css
teleforma/templates/teleforma/inc/document_list.html
teleforma/templates/teleforma/inc/media_list.html
teleforma/templatetags/teleforma_tags.py
teleforma/views/core.py

index 8deb42336665a931bd6bd5e0ce04cdc1f107b547..3c077182e8d677a58965181c56de720971a6d8ba 100644 (file)
@@ -3412,4 +3412,14 @@ button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra pad
 
 #flex-container > .raw-item {
   width: 5rem;
+}
+
+/* New resource indicator */
+.new-resource {
+    background-color: #e74c3c;
+    color: white;
+    padding: 2px 8px;
+    border-radius: 3px;
+    font-size: 0.85em;
+    font-weight: bold;
 }
\ No newline at end of file
index 345424130e86c5669d552f0a1904abd446bc97b0..cc31f5fafa9a08ab73d810c8ef459ba188c57148 100644 (file)
     <tbody>
       {% for doc in docs %}
         <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="35%">{{ doc.date_added }}</td>
+        <td {% if forloop.first %}class="border-top"{% endif %} width="55%">{% 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="30%">{{ 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="10%" align="center">
+          {% if not doc|document_read:user %}
+            <span class="new-resource">Nouveau</span>
+          {% endif %}
+        </td>
         </tr>
     {% endfor %}
     </tbody>
index 720994b79e982649f073902d50d0fc43ff31d311..3738c884e5f5dc0528fa3f80d56fbd732a9132d3 100644 (file)
@@ -60,6 +60,9 @@
                     <img src="/static/teleforma/images/delete.png" style="vertical-align:middle" alt="" title="{% trans ' rejected' %}" />
                 {% endif %}
             {% endif %}
+            {% if not conference.video|media_read:user %}
+                <span class="new-resource">Nouveau</span>
+            {% endif %}
             {% if conference.video.file %}
                 {% if not "video" in conference.video.mime_type or request.user_agent.os.family == 'iOS' %}
                     <a href="{% url 'teleforma-media-download' period.id conference.video.id %}">
index f77232a0885f7d82f1f40b76659e7753540d9023..3732c18329624eeb393805b1a685bc4a81f1749c 100644 (file)
@@ -52,7 +52,7 @@ from docutils.core import publish_parts
 from teleforma.views.core import get_course_conferences
 
 from ..exam.models import Quota, Script
-from ..models.core import Document, Professor
+from ..models.core import Document, MediaRead, Professor
 from ..models.crfpa import IEJ, Course, NewsItem, Training, QuizValidation
 from ..views import get_courses
 from ..utils import generate_hash
@@ -537,3 +537,11 @@ def quiz_validated(quiz, user):
         return validations[0].date_validated
     else:
         return ''
+
+@register.filter
+def document_read(document, user):
+    return document.readers.filter(id=user.id).exists()
+
+@register.filter
+def media_read(media, user):
+    return MediaRead.objects.filter(media=media, user=user).exists()
index 436ca5f1a4b2216934adbd084dee619f5cc2fe0f..c609141a230bbb16dfeb334056c241cef588a39d 100644 (file)
@@ -823,6 +823,9 @@ class DocumentView(CourseAccessMixin, DetailView):
         bucket = False
 
         if get_access(document, courses):
+            # Track document read
+            document.readers.add(request.user)
+
             if settings.TELEFORMA_PRIVATE_DOCUMENTS_MODE:
                 file = document.private_file(request.user)
                 if settings.TELEFORMA_PRIVATE_MEDIA_USE_S3: