Skip to content

Commit

Permalink
Add sample_concentration min/max (#2629) (minor)
Browse files Browse the repository at this point in the history
### Added

- sample_concentration_minimum and sample_concentration_maximum to Application table.
  • Loading branch information
islean authored Oct 26, 2023
1 parent 61e69bd commit 33dda40
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
38 changes: 38 additions & 0 deletions alembic/versions/392e49db40fc_add_sample_concentration_min_max.py
Original file line number Diff line number Diff line change
@@ -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")
24 changes: 24 additions & 0 deletions cg/server/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""

Expand Down Expand Up @@ -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"]
Expand Down
2 changes: 2 additions & 0 deletions cg/store/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 33dda40

Please sign in to comment.