浏览代码

Orders content revisions by updated date

Adrien Panay 7 年前
父节点
当前提交
2abddec179
共有 1 个文件被更改,包括 9 次插入1 次删除
  1. 9 1
      tracim/tracim/model/data.py

+ 9 - 1
tracim/tracim/model/data.py 查看文件

@@ -735,9 +735,17 @@ class Content(DeclarativeBase):
735 735
     revision_to_serialize = -0  # This flag allow to serialize a given revision if required by the user
736 736
 
737 737
     id = Column(Integer, primary_key=True)
738
+    # TODO - A.P - 2017-09-05 - revisions default sorting
739
+    # The only sorting that makes sens is ordering by "updated" field. But:
740
+    # - its content will soon replace the one of "created",
741
+    # - this "updated" field will then be dropped.
742
+    # So for now, we order by "updated" explicitly, but remember to switch to
743
+    # "created" once "updated" removed.
744
+    # https://github.com/tracim/tracim/issues/336
738 745
     revisions = relationship("ContentRevisionRO",
739 746
                              foreign_keys=[ContentRevisionRO.content_id],
740
-                             back_populates="node")
747
+                             back_populates="node",
748
+                             order_by="ContentRevisionRO.updated")
741 749
     children_revisions = relationship("ContentRevisionRO",
742 750
                                       foreign_keys=[ContentRevisionRO.parent_id],
743 751
                                       back_populates="parent")