Guénaël Muller 6 년 전
부모
커밋
eb36169ec9
3개의 변경된 파일19개의 추가작업 그리고 6개의 파일을 삭제
  1. 2 2
      tracim/tracim/lib/webdav/design.py
  2. 15 2
      tracim/tracim/model/data.py
  3. 2 2
      tracim/tracim/model/serializers.py

+ 2 - 2
tracim/tracim/lib/webdav/design.py 파일 보기

@@ -148,7 +148,7 @@ def create_readable_date(created, delta_from_datetime: datetime = None):
148 148
     return aff
149 149
 
150 150
 def designPage(content: data.Content, content_revision: data.ContentRevisionRO) -> str:
151
-    hist = content.get_history()
151
+    hist = content.get_history(drop_empty_revision=False)
152 152
     histHTML = '<table class="table table-striped table-hover">'
153 153
     for event in hist:
154 154
         if isinstance(event, VirtualEvent):
@@ -237,7 +237,7 @@ def designPage(content: data.Content, content_revision: data.ContentRevisionRO)
237 237
     return page
238 238
 
239 239
 def designThread(content: data.Content, content_revision: data.ContentRevisionRO, comments) -> str:
240
-        hist = content.get_history()
240
+        hist = content.get_history(drop_empty_revision=False)
241 241
 
242 242
         allT = []
243 243
         allT += comments

+ 15 - 2
tracim/tracim/model/data.py 파일 보기

@@ -1234,11 +1234,24 @@ class Content(DeclarativeBase):
1234 1234
 
1235 1235
         return ContentType.sorted(types)
1236 1236
 
1237
-    def get_history(self) -> '[VirtualEvent]':
1237
+    def get_history(self, drop_empty_revision=False) -> '[VirtualEvent]':
1238 1238
         events = []
1239 1239
         for comment in self.get_comments():
1240 1240
             events.append(VirtualEvent.create_from_content(comment))
1241
-        for revision in self.revisions:
1241
+
1242
+        revisions = sorted(self.revisions, key=lambda rev: rev.revision_id)
1243
+        for revision in revisions:
1244
+            # INFO - G.M - 09-03-2018 - Do not show file revision with empty
1245
+            # file to have a more clear view of revision.
1246
+            # Some webdav client create empty file before uploading, we must
1247
+            # have possibility to not show the related revision
1248
+            if drop_empty_revision:
1249
+                if revision.depot_file and revision.depot_file.file.content_length == 0:  # nopep8
1250
+                    # INFO - G.M - 12-03-2018 -Always show the last and
1251
+                    # first revision.
1252
+                    if revision != revisions[-1] and revision != revisions[0]:
1253
+                        continue
1254
+
1242 1255
             events.append(VirtualEvent.create_from_content_revision(revision))
1243 1256
 
1244 1257
         sorted_events = sorted(events,

+ 2 - 2
tracim/tracim/model/serializers.py 파일 보기

@@ -398,7 +398,7 @@ def serialize_node_for_page(content: Content, context: Context):
398 398
             links=[],
399 399
             revision_nb = len(content.revisions),
400 400
             selected_revision='latest' if content.revision_to_serialize<=0 else content.revision_to_serialize,
401
-            history=Context(CTX.CONTENT_HISTORY).toDict(content.get_history()),
401
+            history=Context(CTX.CONTENT_HISTORY).toDict(content.get_history(drop_empty_revision=True)),  # nopep8
402 402
             is_editable=content.is_editable,
403 403
             is_deleted=content.is_deleted,
404 404
             is_archived=content.is_archived,
@@ -475,7 +475,7 @@ def serialize_node_for_thread(item: Content, context: Context):
475 475
             workspace = context.toDict(item.workspace),
476 476
             comments = reversed(context.toDict(item.get_comments())),
477 477
             is_new=item.has_new_information_for(context.get_user()),
478
-            history = Context(CTX.CONTENT_HISTORY).toDict(item.get_history()),
478
+            history = Context(CTX.CONTENT_HISTORY).toDict(item.get_history(drop_empty_revision=True)),  # nopep8
479 479
             is_editable=item.is_editable,
480 480
             is_deleted=item.is_deleted,
481 481
             is_archived=item.is_archived,