Skip to content

Commit

Permalink
Merge pull request #135 from eoyilmaz/118-flexible-statuslists
Browse files Browse the repository at this point in the history
118 flexible statuslists
  • Loading branch information
eoyilmaz authored Dec 12, 2024
2 parents 4f4924c + 25f182d commit 3578999
Show file tree
Hide file tree
Showing 13 changed files with 428 additions and 408 deletions.
36 changes: 23 additions & 13 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,43 @@ Stalker Changes
1.0.0
=====

* `Version.take_name` has been renamed to `Version.variant_name` to follow the industry
standard (and then removed it completely as we now have `Variant` class for this).
* `Version.take_name` has been renamed to `Version.variant_name` to follow the
industry standard (and then removed it completely as we now have `Variant`
class for this).
* `Task.depends` renamed to `Task.depends_on`.
* `TaskDependency.task_depends_to` renamed to `TaskDependency.task_depends_on`.
* Modernised Stalker as a Python project. It is now fully PEP 517 compliant.
* Stalker now supports Python versions from 3.8 to 3.13.
* Stalker is now SQLAlchemy 2.x compliant.
* Stalker is now fully type hinted.
* Added GitHub actions for CI/CD practices.
* Updated validation messages to make them more consistently displaying the current
type and the value of the validated attribute.
* Added Makefile workflow to help creating a virtualenv, building, installing, releasing
etc. actions much more easier.
* Updated validation messages to make them more consistently displaying the
current type and the value of the validated attribute.
* Added Makefile workflow to help creating a virtualenv, building, installing,
releasing etc. actions much more easier.
* Added `tox` config to run the test with Python 3.8 to 3.13.
* Increased test coverage to 99.71%.
* Updated documentation theme to `furo`.
* Renamed OSX to macOS anywhere it is mentioned.
* `Scene` is now deriving from `Task`.
* `Shot.sequences` is now `Shot.sequences` and it is many-to-one.
* `Shot.scenes` is now `Shot.scene` and it is many-to-one.
* Added the `Variant` class to allow variants to be approved and managed individually.
* Added `Review.version` attribute to relate a `Version` instance to the review.
* Removed the `Version.variant_name` attribute. The migration alembic script will create
`Variant` instances for each `Version.variant_name` under the container `Task` to hold
the information.
* `Version._template_variables()` now finds the related `Asset`, `Shot` and `Sequence`
values and passes them in the returned dictionary.
* Added the `Variant` class to allow variants to be approved and managed
individually.
* Added `Review.version` attribute to relate a `Version` instance to the
review.
* Removed the `Version.variant_name` attribute. The migration alembic script
will create `Variant` instances for each `Version.variant_name` under the
container `Task` to hold the information.
* `Version._template_variables()` now finds the related `Asset`, `Shot` and
`Sequence` values and passes them in the returned dictionary.
* All the enum values handled with arbitrary string lists are now enum classes.
As a result we now have `ScheduleConstraint`, `TimeUnit`, `ScheduleModel`,
`DependencyTarget` enum classes which are removing the need of using fiddly
strings as enum values.
* `StatusList`s that are created for super classes can now be used with the
derived classes, i.e. a status list created specifically for Task can now be
used with Asset, Shot Sequence and Scenes and any future Task derivatives.

0.2.27
======
Expand Down
4 changes: 2 additions & 2 deletions src/stalker/db/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ def save(self, data: Union[None, List[Any], "SimpleEntity"] = None) -> None:
data (Union[list, stalker.models.entity.SimpleEntity]): Either a single or
a list of :class:`stalker.models.entity.SimpleEntity` or derivatives.
"""
if data:
if hasattr(data, "__getitem__"):
if data is not None:
if isinstance(data, list):
self.add_all(data)
else:
self.add(data)
Expand Down
30 changes: 0 additions & 30 deletions src/stalker/db/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,36 +182,6 @@ def init() -> None:
status_codes=defaults.task_status_codes,
user=admin,
)
create_entity_statuses(
entity_type="Asset",
status_names=defaults.task_status_names,
status_codes=defaults.task_status_codes,
user=admin,
)
create_entity_statuses(
entity_type="Shot",
status_names=defaults.task_status_names,
status_codes=defaults.task_status_codes,
user=admin,
)
create_entity_statuses(
entity_type="Sequence",
status_names=defaults.task_status_names,
status_codes=defaults.task_status_codes,
user=admin,
)
create_entity_statuses(
entity_type="Scene",
status_names=defaults.task_status_names,
status_codes=defaults.task_status_codes,
user=admin,
)
create_entity_statuses(
entity_type="Variant",
status_names=defaults.task_status_names,
status_codes=defaults.task_status_codes,
user=admin,
)
create_entity_statuses(
entity_type="Review",
status_names=defaults.review_status_names,
Expand Down
4 changes: 3 additions & 1 deletion src/stalker/models/enum.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ def __repr__(self) -> str:
__str__ = __repr__

@classmethod
def to_constraint(cls, constraint: Union[int, str, "ScheduleConstraint"]) -> "ScheduleConstraint":
def to_constraint(
cls, constraint: Union[int, str, "ScheduleConstraint"]
) -> "ScheduleConstraint":
"""Validate and return type enum from an input int or str value.
Args:
Expand Down
8 changes: 5 additions & 3 deletions src/stalker/models/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,8 @@ def _validate_status_list(
"""
from stalker.models.status import StatusList

super_names = [mro.__name__ for mro in self.__class__.__mro__]

if status_list is None:
# check if there is a db setup and try to get the appropriate
# StatusList from the database
Expand All @@ -440,8 +442,8 @@ def _validate_status_list(
try:
# try to get a StatusList with the target_entity_type is
# matching the class name
status_list = StatusList.query.filter_by(
target_entity_type=self.__class__.__name__
status_list = StatusList.query.filter(
StatusList.target_entity_type.in_(super_names)
).first()
except (UnboundExecutionError, OperationalError):
# it is not mapped just skip it
Expand Down Expand Up @@ -469,7 +471,7 @@ def _validate_status_list(

# check if the entity_type matches to the
# StatusList.target_entity_type
if self.__class__.__name__ != status_list.target_entity_type:
if status_list.target_entity_type not in super_names:
raise TypeError(
"The given StatusLists' target_entity_type is "
f"{status_list.target_entity_type}, "
Expand Down
Loading

0 comments on commit 3578999

Please sign in to comment.