Added saving creation date of the task

This commit is contained in:
Анатолий Богомолов 2024-02-03 12:02:10 +00:00
parent 39c0cfe659
commit da81df4028
3 changed files with 37 additions and 1 deletions

View File

@ -4,6 +4,7 @@
<div class="card-body">
<h3 class="card-title">{{ task.name }}</h3>
<ul class="list-group list-group-flush">
<li class="list-group-item">Дата и время: {{ task.datetime }}</li>
<li class="list-group-item">Статус: {{ task.status }}</li>
<li class="list-group-item">Сообщение: {{ task.status_message }}</li>
<li class="list-group-item">Действие: {{ task.type }}</li>

View File

@ -1,4 +1,6 @@
from sqlalchemy import Integer
import datetime
from sqlalchemy import Integer, DateTime
from sqlalchemy.schema import Column, ForeignKey
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.extensions import db
@ -11,6 +13,7 @@ class Task(db.Model):
session_id = Column(Integer, ForeignKey("session.id"))
session: Mapped['Session'] = relationship("Session", back_populates="tasks")
datetime: Mapped[DateTime] = Column(DateTime, default=datetime.datetime.utcnow().strftime("%d.%m.%y %H:%M"))
status: Mapped[str]
status_message: Mapped[str]
type: Mapped[str]

View File

@ -0,0 +1,32 @@
"""Added datetime to task
Revision ID: cdd471f48b0d
Revises: af22ea98e0da
Create Date: 2024-02-03 11:36:03.826063
"""
from alembic import op
import sqlalchemy as sa
# revision identifiers, used by Alembic.
revision = 'cdd471f48b0d'
down_revision = 'af22ea98e0da'
branch_labels = None
depends_on = None
def upgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('task', schema=None) as batch_op:
batch_op.add_column(sa.Column('datetime', sa.DateTime(), nullable=True))
# ### end Alembic commands ###
def downgrade():
# ### commands auto generated by Alembic - please adjust! ###
with op.batch_alter_table('task', schema=None) as batch_op:
batch_op.drop_column('datetime')
# ### end Alembic commands ###