|
@@ -66,6 +66,7 @@ class File(NamedBaseModel):
|
|
|
"created",
|
|
|
"path",
|
|
|
"frames",
|
|
|
+ "has_annotations",
|
|
|
"fps",
|
|
|
"project_id",
|
|
|
"collection_id",
|
|
@@ -76,6 +77,11 @@ class File(NamedBaseModel):
|
|
|
""" filename consisting of a name and an extension """
|
|
|
return f"{self.name}{self.extension}"
|
|
|
|
|
|
+ @property
|
|
|
+ def has_annotations(self):
|
|
|
+ """ check if there are any referenced results """
|
|
|
+ return self.results.count() != 0
|
|
|
+
|
|
|
@property
|
|
|
def absolute_path(self) -> str:
|
|
|
""" returns an absolute of the file """
|
|
@@ -143,8 +149,9 @@ class File(NamedBaseModel):
|
|
|
:return: another file or None
|
|
|
"""
|
|
|
|
|
|
- return self._get_another_file(File.id > self.id)\
|
|
|
- .order_by(File.id).first()
|
|
|
+ res = self._get_another_file(File.path > self.path)\
|
|
|
+ .order_by(File.path)
|
|
|
+ return res.first()
|
|
|
|
|
|
|
|
|
def previous(self) -> T.Optional[File]:
|
|
@@ -155,8 +162,9 @@ class File(NamedBaseModel):
|
|
|
"""
|
|
|
|
|
|
# pylint: disable=no-member
|
|
|
- return self._get_another_file(File.id < self.id)\
|
|
|
- .order_by(File.id.desc()).first()
|
|
|
+ res = self._get_another_file(File.path < self.path)\
|
|
|
+ .order_by(File.path.desc())
|
|
|
+ return res.first()
|
|
|
|
|
|
|
|
|
def next_in_collection(self) -> T.Optional[File]:
|
|
@@ -166,8 +174,8 @@ class File(NamedBaseModel):
|
|
|
:return: another file or None
|
|
|
"""
|
|
|
return self._get_another_file(
|
|
|
- File.id > self.id, File.collection_id == self.collection_id)\
|
|
|
- .order_by(File.id).first()
|
|
|
+ File.path > self.path, File.collection_id == self.collection_id)\
|
|
|
+ .order_by(File.path).first()
|
|
|
|
|
|
|
|
|
def previous_in_collection(self) -> T.Optional[File]:
|
|
@@ -179,8 +187,8 @@ class File(NamedBaseModel):
|
|
|
|
|
|
# pylint: disable=no-member
|
|
|
return self._get_another_file(
|
|
|
- File.id < self.id, File.collection_id == self.collection_id)\
|
|
|
- .order_by(File.id.desc()).first()
|
|
|
+ File.path < self.path, File.collection_id == self.collection_id)\
|
|
|
+ .order_by(File.path.desc()).first()
|
|
|
|
|
|
|
|
|
def result(self, identifier: int) -> T.Optional[Result]:
|