|
@@ -20,7 +20,7 @@ class Project(NamedBaseModel):
|
|
description = db.Column(db.String)
|
|
description = db.Column(db.String)
|
|
|
|
|
|
created = db.Column(db.DateTime, default=datetime.utcnow,
|
|
created = db.Column(db.DateTime, default=datetime.utcnow,
|
|
- index=True, nullable=False)
|
|
+ index=True, nullable=False)
|
|
|
|
|
|
model_id = db.Column(
|
|
model_id = db.Column(
|
|
db.Integer,
|
|
db.Integer,
|
|
@@ -61,7 +61,6 @@ class Project(NamedBaseModel):
|
|
passive_deletes=True,
|
|
passive_deletes=True,
|
|
)
|
|
)
|
|
|
|
|
|
-
|
|
|
|
serialize_only = NamedBaseModel.serialize_only + (
|
|
serialize_only = NamedBaseModel.serialize_only + (
|
|
"created",
|
|
"created",
|
|
"description",
|
|
"description",
|
|
@@ -88,7 +87,6 @@ class Project(NamedBaseModel):
|
|
|
|
|
|
return dump, model_dump
|
|
return dump, model_dump
|
|
|
|
|
|
-
|
|
|
|
def label(self, identifier: int) -> T.Optional[Label]:
|
|
def label(self, identifier: int) -> T.Optional[Label]:
|
|
"""
|
|
"""
|
|
get a label using its unique identifier
|
|
get a label using its unique identifier
|
|
@@ -98,7 +96,6 @@ class Project(NamedBaseModel):
|
|
"""
|
|
"""
|
|
return self.labels.filter(Label.id == identifier).one_or_none()
|
|
return self.labels.filter(Label.id == identifier).one_or_none()
|
|
|
|
|
|
-
|
|
|
|
def label_by_reference(self, reference: str) -> T.Optional[Label]:
|
|
def label_by_reference(self, reference: str) -> T.Optional[Label]:
|
|
"""
|
|
"""
|
|
get a label using its reference string
|
|
get a label using its reference string
|
|
@@ -108,7 +105,6 @@ class Project(NamedBaseModel):
|
|
"""
|
|
"""
|
|
return self.labels.filter(Label.reference == reference).one_or_none()
|
|
return self.labels.filter(Label.reference == reference).one_or_none()
|
|
|
|
|
|
-
|
|
|
|
def file(self, identifier: int) -> T.Optional[Label]:
|
|
def file(self, identifier: int) -> T.Optional[Label]:
|
|
"""
|
|
"""
|
|
get a file using its unique identifier
|
|
get a file using its unique identifier
|
|
@@ -118,7 +114,6 @@ class Project(NamedBaseModel):
|
|
"""
|
|
"""
|
|
return self.files.filter(File.id == identifier).one_or_none()
|
|
return self.files.filter(File.id == identifier).one_or_none()
|
|
|
|
|
|
-
|
|
|
|
def collection(self, identifier: int) -> T.Optional[Collection]:
|
|
def collection(self, identifier: int) -> T.Optional[Collection]:
|
|
"""
|
|
"""
|
|
get a collection using its unique identifier
|
|
get a collection using its unique identifier
|
|
@@ -128,7 +123,6 @@ class Project(NamedBaseModel):
|
|
"""
|
|
"""
|
|
return self.collections.filter(Collection.id == identifier).one_or_none()
|
|
return self.collections.filter(Collection.id == identifier).one_or_none()
|
|
|
|
|
|
-
|
|
|
|
def collection_by_reference(self, reference: str) -> T.Optional[Collection]:
|
|
def collection_by_reference(self, reference: str) -> T.Optional[Collection]:
|
|
"""
|
|
"""
|
|
get a collection using its unique identifier
|
|
get a collection using its unique identifier
|
|
@@ -138,7 +132,6 @@ class Project(NamedBaseModel):
|
|
"""
|
|
"""
|
|
return self.collections.filter(Collection.reference == reference).one_or_none()
|
|
return self.collections.filter(Collection.reference == reference).one_or_none()
|
|
|
|
|
|
-
|
|
|
|
@commit_on_return
|
|
@commit_on_return
|
|
def create_label(self, name: str,
|
|
def create_label(self, name: str,
|
|
reference: str = None,
|
|
reference: str = None,
|
|
@@ -220,8 +213,6 @@ class Project(NamedBaseModel):
|
|
|
|
|
|
unique_keys[key] = label
|
|
unique_keys[key] = label
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
@commit_on_return
|
|
@commit_on_return
|
|
def create_collection(self,
|
|
def create_collection(self,
|
|
@@ -242,7 +233,6 @@ class Project(NamedBaseModel):
|
|
:return: collection object, insert
|
|
:return: collection object, insert
|
|
"""
|
|
"""
|
|
|
|
|
|
-
|
|
|
|
collection, is_new = Collection.get_or_create(
|
|
collection, is_new = Collection.get_or_create(
|
|
project_id=self.id, reference=reference)
|
|
project_id=self.id, reference=reference)
|
|
|
|
|
|
@@ -253,7 +243,6 @@ class Project(NamedBaseModel):
|
|
|
|
|
|
return collection, is_new
|
|
return collection, is_new
|
|
|
|
|
|
-
|
|
|
|
|
|
|
|
@commit_on_return
|
|
@commit_on_return
|
|
def add_file(self,
|
|
def add_file(self,
|
|
@@ -293,7 +282,6 @@ class Project(NamedBaseModel):
|
|
|
|
|
|
return file, is_new
|
|
return file, is_new
|
|
|
|
|
|
-
|
|
|
|
def get_files(self, *filters, offset: int = 0, limit: int = -1) -> T.List[File]:
|
|
def get_files(self, *filters, offset: int = 0, limit: int = -1) -> T.List[File]:
|
|
"""
|
|
"""
|
|
get an iterator of files associated with this project
|
|
get an iterator of files associated with this project
|
|
@@ -305,7 +293,6 @@ class Project(NamedBaseModel):
|
|
|
|
|
|
return self.files.filter(*filters).order_by(File.id).offset(offset).limit(limit)
|
|
return self.files.filter(*filters).order_by(File.id).offset(offset).limit(limit)
|
|
|
|
|
|
-
|
|
|
|
def _files_without_results(self):
|
|
def _files_without_results(self):
|
|
"""
|
|
"""
|
|
get files without any results
|
|
get files without any results
|
|
@@ -315,7 +302,6 @@ class Project(NamedBaseModel):
|
|
|
|
|
|
return self.files.filter(~File.results.any())
|
|
return self.files.filter(~File.results.any())
|
|
|
|
|
|
-
|
|
|
|
def count_files_without_results(self) -> int:
|
|
def count_files_without_results(self) -> int:
|
|
"""
|
|
"""
|
|
count files without associated results
|
|
count files without associated results
|
|
@@ -325,7 +311,6 @@ class Project(NamedBaseModel):
|
|
|
|
|
|
return self._files_without_results().count()
|
|
return self._files_without_results().count()
|
|
|
|
|
|
-
|
|
|
|
def files_without_results(self) -> T.List[File]:
|
|
def files_without_results(self) -> T.List[File]:
|
|
"""
|
|
"""
|
|
get a list of files without associated results
|
|
get a list of files without associated results
|
|
@@ -334,7 +319,6 @@ class Project(NamedBaseModel):
|
|
"""
|
|
"""
|
|
return self._files_without_results().all()
|
|
return self._files_without_results().all()
|
|
|
|
|
|
-
|
|
|
|
def _files_without_collection(self, offset: int = 0, limit: int = -1):
|
|
def _files_without_collection(self, offset: int = 0, limit: int = -1):
|
|
"""
|
|
"""
|
|
get files without a collection
|
|
get files without a collection
|
|
@@ -352,7 +336,6 @@ class Project(NamedBaseModel):
|
|
"""
|
|
"""
|
|
return self._files_without_collection(offset=offset, limit=limit).all()
|
|
return self._files_without_collection(offset=offset, limit=limit).all()
|
|
|
|
|
|
-
|
|
|
|
def count_files_without_collection(self) -> int:
|
|
def count_files_without_collection(self) -> int:
|
|
"""
|
|
"""
|
|
count files associated with this project but without a collection
|
|
count files associated with this project but without a collection
|