Guénaël Muller 6 years ago
parent
commit
eb36169ec9

+ 2 - 2
tracim/tracim/lib/webdav/design.py View File

148
     return aff
148
     return aff
149
 
149
 
150
 def designPage(content: data.Content, content_revision: data.ContentRevisionRO) -> str:
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
     histHTML = '<table class="table table-striped table-hover">'
152
     histHTML = '<table class="table table-striped table-hover">'
153
     for event in hist:
153
     for event in hist:
154
         if isinstance(event, VirtualEvent):
154
         if isinstance(event, VirtualEvent):
237
     return page
237
     return page
238
 
238
 
239
 def designThread(content: data.Content, content_revision: data.ContentRevisionRO, comments) -> str:
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
         allT = []
242
         allT = []
243
         allT += comments
243
         allT += comments

+ 15 - 2
tracim/tracim/model/data.py View File

1234
 
1234
 
1235
         return ContentType.sorted(types)
1235
         return ContentType.sorted(types)
1236
 
1236
 
1237
-    def get_history(self) -> '[VirtualEvent]':
1237
+    def get_history(self, drop_empty_revision=False) -> '[VirtualEvent]':
1238
         events = []
1238
         events = []
1239
         for comment in self.get_comments():
1239
         for comment in self.get_comments():
1240
             events.append(VirtualEvent.create_from_content(comment))
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
             events.append(VirtualEvent.create_from_content_revision(revision))
1255
             events.append(VirtualEvent.create_from_content_revision(revision))
1243
 
1256
 
1244
         sorted_events = sorted(events,
1257
         sorted_events = sorted(events,

+ 2 - 2
tracim/tracim/model/serializers.py View File

398
             links=[],
398
             links=[],
399
             revision_nb = len(content.revisions),
399
             revision_nb = len(content.revisions),
400
             selected_revision='latest' if content.revision_to_serialize<=0 else content.revision_to_serialize,
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
             is_editable=content.is_editable,
402
             is_editable=content.is_editable,
403
             is_deleted=content.is_deleted,
403
             is_deleted=content.is_deleted,
404
             is_archived=content.is_archived,
404
             is_archived=content.is_archived,
475
             workspace = context.toDict(item.workspace),
475
             workspace = context.toDict(item.workspace),
476
             comments = reversed(context.toDict(item.get_comments())),
476
             comments = reversed(context.toDict(item.get_comments())),
477
             is_new=item.has_new_information_for(context.get_user()),
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
             is_editable=item.is_editable,
479
             is_editable=item.is_editable,
480
             is_deleted=item.is_deleted,
480
             is_deleted=item.is_deleted,
481
             is_archived=item.is_archived,
481
             is_archived=item.is_archived,