diff --git a/alembic/versions/392e49db40fc_add_sample_concentration_min_max.py b/alembic/versions/392e49db40fc_add_sample_concentration_min_max.py new file mode 100644 index 0000000000..724a3c8b16 --- /dev/null +++ b/alembic/versions/392e49db40fc_add_sample_concentration_min_max.py @@ -0,0 +1,38 @@ +"""Add sample concentration min max + +Revision ID: 392e49db40fc +Revises: db61c62d9bc0 +Create Date: 2023-10-25 09:50:16.779186 + +""" +import sqlalchemy as sa + +from alembic import op + +# revision identifiers, used by Alembic. +revision = "392e49db40fc" +down_revision = "db61c62d9bc0" +branch_labels = None +depends_on = None + + +def upgrade(): + op.add_column( + table_name="application", + column=sa.Column( + "sample_concentration_minimum", + sa.DECIMAL(6, 2), + ), + ) + op.add_column( + table_name="application", + column=sa.Column( + "sample_concentration_maximum", + sa.DECIMAL(6, 2), + ), + ) + + +def downgrade(): + op.drop_column(table_name="application", column_name="sample_concentration_maximum") + op.drop_column(table_name="application", column_name="sample_concentration_minimum") diff --git a/cg/server/admin.py b/cg/server/admin.py index 1aaa046861..3e2af25f97 100644 --- a/cg/server/admin.py +++ b/cg/server/admin.py @@ -50,6 +50,26 @@ def is_external_application(unused1, unused2, model, unused3): return model.application_version.application.is_external if model.application_version else "" +def view_sample_concentration_minimum(unused1, unused2, model, unused3): + """Column formatter to append unit""" + del unused1, unused2, unused3 + return ( + str(model.sample_concentration_minimum) + " ng/uL" + if model.sample_concentration_minimum + else None + ) + + +def view_sample_concentration_maximum(unused1, unused2, model, unused3): + """Column formatter to append unit""" + del unused1, unused2, unused3 + return ( + str(model.sample_concentration_maximum) + " ng/uL" + if model.sample_concentration_maximum + else None + ) + + class ApplicationView(BaseView): """Admin view for Model.Application""" @@ -78,6 +98,10 @@ class ApplicationView(BaseView): "updated_at", "category", ] + column_formatters = { + "sample_concentration_minimum": view_sample_concentration_minimum, + "sample_concentration_maximum": view_sample_concentration_maximum, + } column_filters = ["prep_category", "is_accredited"] column_searchable_list = ["tag", "prep_category"] form_excluded_columns = ["category", "versions"] diff --git a/cg/store/models.py b/cg/store/models.py index 25a297de51..8a687a0f9e 100644 --- a/cg/store/models.py +++ b/cg/store/models.py @@ -105,6 +105,8 @@ class Application(Model): sample_amount = Column(types.Integer) sample_volume = Column(types.Text) sample_concentration = Column(types.Text) + sample_concentration_minimum = Column(types.DECIMAL) + sample_concentration_maximum = Column(types.DECIMAL) priority_processing = Column(types.Boolean, default=False) details = Column(types.Text) limitations = Column(types.Text)