From fc009a2513f174109ddd36e72efc6d0af91cd865 Mon Sep 17 00:00:00 2001 From: Sanqui Date: Mon, 6 Jan 2025 22:25:05 +0100 Subject: [PATCH] Add description column for assets Descriptions and notes serve different purposes --- README.md | 4 +-- .../52e6ee4f9e72_asset_add_description.py | 28 +++++++++++++++++++ ops/deploy_with_migration.sh | 3 +- rhinventory/admin_views/asset.py | 1 + rhinventory/models/asset.py | 3 ++ .../templates/admin/asset/details.html | 4 +++ 6 files changed, 39 insertions(+), 4 deletions(-) create mode 100644 alembic/versions/52e6ee4f9e72_asset_add_description.py diff --git a/README.md b/README.md index e34c2c8..dbc2ed6 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,7 @@ fastapi dev rhinventory/api/app.py ## Jak se Alembic? ```bash - # Řeknu si Sankymu aby mi vysvětlil alembic.ini... - - source .venv/bin/activate + poetry shell # Jako git status alembic current diff --git a/alembic/versions/52e6ee4f9e72_asset_add_description.py b/alembic/versions/52e6ee4f9e72_asset_add_description.py new file mode 100644 index 0000000..bcf852d --- /dev/null +++ b/alembic/versions/52e6ee4f9e72_asset_add_description.py @@ -0,0 +1,28 @@ +"""Asset: add description + +Revision ID: 52e6ee4f9e72 +Revises: 67c7642b8ef5 +Create Date: 2025-01-06 22:21:59.571846 + +""" +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import postgresql + +# revision identifiers, used by Alembic. +revision = '52e6ee4f9e72' +down_revision = '67c7642b8ef5' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('assets', sa.Column('description', sa.Text(), nullable=True)) + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.drop_column('assets', 'description') + # ### end Alembic commands ### diff --git a/ops/deploy_with_migration.sh b/ops/deploy_with_migration.sh index 96cc54f..e3ea8fe 100755 --- a/ops/deploy_with_migration.sh +++ b/ops/deploy_with_migration.sh @@ -6,6 +6,7 @@ ssh -t retroherna.org "\ sudo -u flask git pull && \ sudo -u flask poetry install && \ sudo -u flask poetry run alembic upgrade head && \ - sudo systemctl restart www_rhinventory \ + sudo systemctl restart www_rhinventory && \ + sudo systemctl restart www_rhinventory_api \ " echo "https://inventory.herniarchiv.cz/" \ No newline at end of file diff --git a/rhinventory/admin_views/asset.py b/rhinventory/admin_views/asset.py index 9359070..aea4b78 100644 --- a/rhinventory/admin_views/asset.py +++ b/rhinventory/admin_views/asset.py @@ -86,6 +86,7 @@ class AssetView(CustomModelView): 'condition_new', # 'functionality', # 'status', + 'description', 'note', 'privacy', 'tags', diff --git a/rhinventory/models/asset.py b/rhinventory/models/asset.py index 460e49a..4f6d147 100644 --- a/rhinventory/models/asset.py +++ b/rhinventory/models/asset.py @@ -92,6 +92,9 @@ class Asset(db.Model): model = Column(String) custom_code = Column(Integer) note = Column(Text) + ''' Internal notes for this asset ''' + description = Column(Text) + ''' Public description of the asset ''' serial = Column(String) # ARRAY was a great idea... diff --git a/rhinventory/templates/admin/asset/details.html b/rhinventory/templates/admin/asset/details.html index 10f1666..8bca676 100644 --- a/rhinventory/templates/admin/asset/details.html +++ b/rhinventory/templates/admin/asset/details.html @@ -92,6 +92,10 @@

{{ render_asset_code(model) }} {{ model.name }}

{% endif %} {% endfor %} +

+ {{ model.description }} +

+ {% macro row(key, title=None, pre_line=False) %} {% if model[key] %}