浏览代码

fix 202 : authors display and last modifications done display

Alexis CLEMENT 8 年前
父节点
当前提交
b6d1018df8

+ 8 - 0
tracim/tracim/lib/helpers.py 查看文件

82
     current_locale = tg.i18n.get_lang()[0]
82
     current_locale = tg.i18n.get_lang()[0]
83
     return format_time(datetime_object, locale=current_locale)
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
 def format_short(datetime_object):
93
 def format_short(datetime_object):
86
     return datetime_object.strftime(format = plag.Globals.SHORT_DATE_FORMAT.__str__())
94
     return datetime_object.strftime(format = plag.Globals.SHORT_DATE_FORMAT.__str__())
87
 
95
 

+ 4 - 0
tracim/tracim/model/data.py 查看文件

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

+ 6 - 3
tracim/tracim/model/serializers.py 查看文件

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

+ 4 - 0
tracim/tracim/templates/file/getone.mak 查看文件

51
 
51
 
52
             <div style="margin: -1.5em auto -1.5em auto;" class="tracim-less-visible">
52
             <div style="margin: -1.5em auto -1.5em auto;" class="tracim-less-visible">
53
                 <% created_localized = h.get_with_timezone(result.file.created) %>
53
                 <% created_localized = h.get_with_timezone(result.file.created) %>
54
+                <% updated_localized = h.get_with_timezone(result.file.updated) %>
54
               <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>
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
             </div>
59
             </div>
56
         </div>
60
         </div>
57
     </div>
61
     </div>

+ 5 - 1
tracim/tracim/templates/page/getone.mak 查看文件

49
 
49
 
50
             <div style="margin: -1.5em auto -1.5em auto;" class="tracim-less-visible">
50
             <div style="margin: -1.5em auto -1.5em auto;" class="tracim-less-visible">
51
                 <% created_localized = h.get_with_timezone(result.page.created) %>
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
             </div>
57
             </div>
54
         </div>
58
         </div>
55
     </div>
59
     </div>

+ 5 - 2
tracim/tracim/templates/thread/getone.mak 查看文件

51
 
51
 
52
             <div style="margin: -1.5em auto -1.5em auto;" class="tracim-less-visible">
52
             <div style="margin: -1.5em auto -1.5em auto;" class="tracim-less-visible">
53
                 <% created_localized = h.get_with_timezone(result.thread.created) %>
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
         </div>
59
         </div>
57
     </div>
60
     </div>
58
 
61