Skip to content

Commit

Permalink
Add description column for assets
Browse files Browse the repository at this point in the history
Descriptions and notes serve different purposes
  • Loading branch information
Sanqui committed Jan 6, 2025
1 parent dc857d4 commit fc009a2
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 4 deletions.
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions alembic/versions/52e6ee4f9e72_asset_add_description.py
Original file line number Diff line number Diff line change
@@ -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 ###
3 changes: 2 additions & 1 deletion ops/deploy_with_migration.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
1 change: 1 addition & 0 deletions rhinventory/admin_views/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ class AssetView(CustomModelView):
'condition_new',
# 'functionality',
# 'status',
'description',
'note',
'privacy',
'tags',
Expand Down
3 changes: 3 additions & 0 deletions rhinventory/models/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -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...
Expand Down
4 changes: 4 additions & 0 deletions rhinventory/templates/admin/asset/details.html
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ <h2><small>{{ render_asset_code(model) }}</small> {{ model.name }}</h2>
{% endif %}
{% endfor %}

<p>
{{ model.description }}
</p>

{% macro row(key, title=None, pre_line=False) %}
{% if model[key] %}
<tr>
Expand Down

0 comments on commit fc009a2

Please sign in to comment.