diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-06-06 16:30:51 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-06-06 16:30:51 +0200 |
| commit | 434e53dea597f61ad59e14012f528ceac58ead85 (patch) | |
| tree | f4dc6bae69f4c46dad9cfce1f74684cccfc26388 /cli/app/sql/models | |
| parent | a42008b2d8c051ec2110d866c2da288a66a1d989 (diff) | |
tile list. drag items to sort them
Diffstat (limited to 'cli/app/sql/models')
| -rw-r--r-- | cli/app/sql/models/page.py | 2 | ||||
| -rw-r--r-- | cli/app/sql/models/tile.py | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/cli/app/sql/models/page.py b/cli/app/sql/models/page.py index 2e6bbad..960ffd7 100644 --- a/cli/app/sql/models/page.py +++ b/cli/app/sql/models/page.py @@ -22,7 +22,7 @@ class Page(Base): created_at = Column(UtcDateTime(), default=utcnow()) updated_at = Column(UtcDateTime(), onupdate=utcnow()) - tiles = relationship("Tile", foreign_keys="Tile.page_id", lazy='dynamic') + tiles = relationship("Tile", foreign_keys="Tile.page_id", lazy='dynamic', order_by="asc(Tile.sort_order)") def toJSON(self): return { diff --git a/cli/app/sql/models/tile.py b/cli/app/sql/models/tile.py index 7dfa80b..3f6ce31 100644 --- a/cli/app/sql/models/tile.py +++ b/cli/app/sql/models/tile.py @@ -20,6 +20,7 @@ class Tile(Base): page_id = Column(Integer, ForeignKey('page.id'), nullable=True) target_page_id = Column(Integer, ForeignKey('page.id'), nullable=True) type = Column(String(16, convert_unicode=True), nullable=False) + sort_order = Column(Integer, default=0) settings = Column(JSON, default={}, nullable=True) created_at = Column(UtcDateTime(), default=utcnow()) updated_at = Column(UtcDateTime(), onupdate=utcnow()) @@ -31,6 +32,7 @@ class Tile(Base): 'page_id': self.page_id, 'target_page_id': self.target_page_id, 'type': self.type, + 'sort_order': self.sort_order, 'settings': self.settings, 'created_at': self.created_at, 'updated_at': self.updated_at, |
