Parcourir la source

fix 202 : authors display and last modifications done display

Alexis CLEMENT il y a 8 ans
Parent
révision
b6d1018df8

+ 8 - 0
tracim/tracim/lib/helpers.py Voir le fichier

@@ -82,6 +82,14 @@ def time(datetime_object):
82 82
     current_locale = tg.i18n.get_lang()[0]
83 83
     return format_time(datetime_object, locale=current_locale)
84 84
 
85
+def update_date(datetime_object):
86
+    current_locale = tg.i18n.get_lang()[0]
87
+    return format_date(datetime_object, locale=current_locale)
88
+
89
+def update_time(datetime_object):
90
+    current_locale = tg.i18n.get_lang()[0]
91
+    return format_time(datetime_object, locale=current_locale)
92
+
85 93
 def format_short(datetime_object):
86 94
     return datetime_object.strftime(format = plag.Globals.SHORT_DATE_FORMAT.__str__())
87 95
 

+ 4 - 0
tracim/tracim/model/data.py Voir le fichier

@@ -1039,6 +1039,10 @@ class Content(DeclarativeBase):
1039 1039
         return self.get_current_revision()
1040 1040
 
1041 1041
     @property
1042
+    def first_revision(self) -> ContentRevisionRO:
1043
+        return self.revisions[0]  # FIXME
1044
+
1045
+    @property
1042 1046
     def is_editable(self) -> bool:
1043 1047
         return not self.is_archived and not self.is_deleted
1044 1048
 

+ 6 - 3
tracim/tracim/model/serializers.py Voir le fichier

@@ -388,12 +388,13 @@ def serialize_node_for_page(content: Content, context: Context):
388 388
             is_new=content.has_new_information_for(context.get_user()),
389 389
             content=data_container.description,
390 390
             created=data_container.created,
391
+            updated=data_container.updated,
391 392
             label=data_container.label,
392 393
             icon=ContentType.get_icon(content.type),
393
-            owner=context.toDict(data_container.owner),
394
+            owner=context.toDict(content.first_revision.owner),
394 395
             status=context.toDict(data_container.get_status()),
395 396
             links=[],
396
-            revisions=context.toDict(sorted(content.revisions, key=lambda v: v.created, reverse=True)),
397
+            revision_nb = len(content.revisions),
397 398
             selected_revision='latest' if content.revision_to_serialize<=0 else content.revision_to_serialize,
398 399
             history=Context(CTX.CONTENT_HISTORY).toDict(content.get_history()),
399 400
             is_editable=content.is_editable,
@@ -450,11 +451,13 @@ def serialize_content_for_history(event: VirtualEvent, context: Context):
450 451
     )
451 452
 
452 453
 @pod_serializer(Content, CTX.THREAD)
453
-def serialize_node_for_page(item: Content, context: Context):
454
+def serialize_node_for_thread(item: Content, context: Context):
454 455
     if item.type==ContentType.Thread:
455 456
         return DictLikeClass(
456 457
             content = item.description,
457 458
             created = item.created,
459
+            updated = item.updated,
460
+            revision_nb = len(item.revisions),
458 461
             icon = ContentType.get_icon(item.type),
459 462
             id = item.content_id,
460 463
             label = item.label,

+ 4 - 0
tracim/tracim/templates/file/getone.mak Voir le fichier

@@ -51,7 +51,11 @@
51 51
 
52 52
             <div style="margin: -1.5em auto -1.5em auto;" class="tracim-less-visible">
53 53
                 <% created_localized = h.get_with_timezone(result.file.created) %>
54
+                <% updated_localized = h.get_with_timezone(result.file.updated) %>
54 55
               <p>${_('file created on {date} at {time} by <b>{author}</b>').format(date=h.date(created_localized), time=h.time(created_localized), author=result.file.owner.name)|n}</p>
56
+              % if result.file.revision_nb > 1:
57
+                  <p>${_(' (last modification on {update_date} at {update_time})').format(update_date=h.update_date(updated_localized), update_time=h.update_time(updated_localized))|n}</p>
58
+              % endif
55 59
             </div>
56 60
         </div>
57 61
     </div>

+ 5 - 1
tracim/tracim/templates/page/getone.mak Voir le fichier

@@ -49,7 +49,11 @@
49 49
 
50 50
             <div style="margin: -1.5em auto -1.5em auto;" class="tracim-less-visible">
51 51
                 <% created_localized = h.get_with_timezone(result.page.created) %>
52
-              <p>${_('page created on {date} at {time} by <b>{author}</b>').format(date=h.date(created_localized), time=h.time(created_localized), author=result.page.owner.name)|n}</p>
52
+                <% updated_localized = h.get_with_timezone(result.page.updated) %>
53
+                <p>${_('page created on {date} at {time} by <b>{author}</b> ').format(date=h.date(created_localized), time=h.time(created_localized), author=result.page.owner.name)|n}</p>
54
+              % if result.page.revision_nb > 1:
55
+                  <p>${_(' (last modification on {update_date} at {update_time})').format(update_date=h.update_date(updated_localized), update_time=h.update_time(updated_localized))|n}</p>
56
+              % endif
53 57
             </div>
54 58
         </div>
55 59
     </div>

+ 5 - 2
tracim/tracim/templates/thread/getone.mak Voir le fichier

@@ -51,8 +51,11 @@
51 51
 
52 52
             <div style="margin: -1.5em auto -1.5em auto;" class="tracim-less-visible">
53 53
                 <% created_localized = h.get_with_timezone(result.thread.created) %>
54
-              <p>${_('page created on {date} at {time} by <b>{author}</b>').format(date=h.date(created_localized), time=h.time(created_localized), author=result.thread.owner.name)|n}</p>
55
-            </div>
54
+                <% updated_localized = h.get_with_timezone(result.thread.updated) %>
55
+                <p>${_('page created on {date} at {time} by <b>{author}</b>').format(date=h.date(created_localized), time=h.time(created_localized), author=result.thread.owner.name)|n}</p>
56
+                % if result.thread.revision_nb > 1:
57
+                  <p>${_(' (last modification on {update_date} at {update_time})').format(update_date=h.update_date(updated_localized), update_time=h.update_time(updated_localized))|n}</p>
58
+              % endif
56 59
         </div>
57 60
     </div>
58 61