From 1f4ae1a6907aab3304320943aa4d725ddaea52f1 Mon Sep 17 00:00:00 2001 From: nhertz <nhertz@nrao.edu> Date: Wed, 17 Feb 2021 11:08:39 -0700 Subject: [PATCH] Finished adding enabled column to Capability --- schema/versions/57c38b5f012e_capabilities_init.py | 2 +- services/capability/test/test_capability_placeholder.py | 2 -- shared/workspaces/workspaces/capability/schema.py | 7 +++++-- 3 files changed, 6 insertions(+), 5 deletions(-) delete mode 100644 services/capability/test/test_capability_placeholder.py diff --git a/schema/versions/57c38b5f012e_capabilities_init.py b/schema/versions/57c38b5f012e_capabilities_init.py index 05ea0aab8..bd8ddb4bb 100644 --- a/schema/versions/57c38b5f012e_capabilities_init.py +++ b/schema/versions/57c38b5f012e_capabilities_init.py @@ -22,7 +22,7 @@ def upgrade(): sa.Column("capability_name", sa.String, primary_key=True), sa.Column("capability_steps", sa.String), sa.Column("max_jobs", sa.Integer), - sa.Column("enabled", sa.Boolean, server_default="True"), + sa.Column("enabled", sa.Boolean, default=True, server_default="true"), ) op.create_table( diff --git a/services/capability/test/test_capability_placeholder.py b/services/capability/test/test_capability_placeholder.py deleted file mode 100644 index 45b2bd089..000000000 --- a/services/capability/test/test_capability_placeholder.py +++ /dev/null @@ -1,2 +0,0 @@ -def test_placeholder(): - pass \ No newline at end of file diff --git a/shared/workspaces/workspaces/capability/schema.py b/shared/workspaces/workspaces/capability/schema.py index 2f2c33865..0905ffb10 100644 --- a/shared/workspaces/workspaces/capability/schema.py +++ b/shared/workspaces/workspaces/capability/schema.py @@ -54,7 +54,7 @@ class Capability(Base, CapabilityIF): name = sa.Column("capability_name", sa.String, primary_key=True) steps = sa.Column("capability_steps", sa.String) max_jobs = sa.Column("max_jobs", sa.Integer) - enabled = sa.Column("enabled", sa.Boolean, default=True) + enabled = sa.Column("enabled", sa.Boolean, default=True, server_default="true") requests = relationship("CapabilityRequest", back_populates="capability") @classmethod @@ -82,6 +82,8 @@ class Capability(Base, CapabilityIF): self.name = json_dict["name"] self.max_jobs = json_dict["max_jobs"] self.steps = json_dict["steps"] + self.enabled = json_dict.get("enabled", True) + return self @staticmethod @@ -119,11 +121,12 @@ class Capability(Base, CapabilityIF): "name": self.name, "max_jobs": self.max_jobs, "steps": str(self.steps), + "enabled": self.enabled, } def __str__(self): return ( - f"Capability object with name {self.name} and max simultaneous jobs of {self.max_jobs}" + f"Capability: {self.name}, max concurrent jobs of {self.max_jobs}" f"\nSequence: {self.steps}" ) -- GitLab