|
@@ -94,11 +94,7 @@ class File(NamedBaseModel):
|
|
|
|
|
|
:return: another file or None
|
|
|
"""
|
|
|
- # return self.project.files.filter(*query)\
|
|
|
- return File.query.filter_by(project_id=self.project_id)\
|
|
|
- .filter(*query)\
|
|
|
- .order_by(File.id.desc())\
|
|
|
- .first()
|
|
|
+ return File.query.filter_by(project_id=self.project_id).filter(*query)
|
|
|
|
|
|
def next(self) -> T.Optional[File]:
|
|
|
"""
|
|
@@ -106,7 +102,8 @@ class File(NamedBaseModel):
|
|
|
|
|
|
:return: another file or None
|
|
|
"""
|
|
|
- return self._get_another_file(File.id > self.id)
|
|
|
+ return self._get_another_file(File.id > self.id)\
|
|
|
+ .order_by(File.id).first()
|
|
|
|
|
|
|
|
|
def previous(self) -> T.Optional[File]:
|
|
@@ -115,7 +112,8 @@ class File(NamedBaseModel):
|
|
|
|
|
|
:return: another file or None
|
|
|
"""
|
|
|
- return self._get_another_file(File.id < self.id)
|
|
|
+ return self._get_another_file(File.id < self.id)\
|
|
|
+ .order_by(File.id.desc()).first()
|
|
|
|
|
|
|
|
|
def next_in_collection(self) -> T.Optional[File]:
|
|
@@ -124,7 +122,8 @@ class File(NamedBaseModel):
|
|
|
|
|
|
:return: another file or None
|
|
|
"""
|
|
|
- return self._get_another_file(File.id > self.id, Collection.id == self.collection_id)
|
|
|
+ return self._get_another_file(File.id > self.id, Collection.id == self.collection_id)\
|
|
|
+ .order_by(File.id).first()
|
|
|
|
|
|
|
|
|
def previous_in_collection(self) -> T.Optional[File]:
|
|
@@ -133,7 +132,8 @@ class File(NamedBaseModel):
|
|
|
|
|
|
:return: another file or None
|
|
|
"""
|
|
|
- return self._get_another_file(File.id < self.id, Collection.id == self.collection_id)
|
|
|
+ return self._get_another_file(File.id < self.id, Collection.id == self.collection_id)\
|
|
|
+ .order_by(File.id.desc()).first()
|
|
|
|
|
|
|
|
|
def result(self, id: int) -> T.Optional[Result]:
|