Changed date and time representation for tasks

This commit is contained in:
Анатолий Богомолов 2024-02-03 14:51:01 +00:00
parent 8ce11f337a
commit f83a2ae152
2 changed files with 30 additions and 28 deletions

View File

@ -3,34 +3,33 @@
<div class="card">
<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>
<li class="list-group-item">
<label class="form-label">Сессия:</label>
<select
name="session"
hx-put="/api/tasks/{{task.id}}/change"
hx-trigger="change"
hx-confirm="Вы уверены, что хотите поменять сессию?"
hx-swap="none"
class="form-select form-select-lg mb-3"
>
{% for session in sessions %}
{% if task.session.name == session.name %}
<option selected value="{{ session.id }}">{{ session.name }}</option>
{% else %}
<option value="{{ session.id }}">{{ session.name }}</option>
{% endif %}
{% endfor %}
</select>
</li>
</ul>
</div>
<div class="card-footer">
<ul class="list-group list-group-flush">
<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>
<li class="list-group-item">
<label class="form-label">Сессия:</label>
<select
name="session"
hx-put="/api/tasks/{{task.id}}/change"
hx-trigger="change"
hx-confirm="Вы уверены, что хотите поменять сессию?"
hx-swap="none"
class="form-select form-select-lg mb-3"
>
{% for session in sessions %}
{% if task.session.name == session.name %}
<option selected value="{{ session.id }}">{{ session.name }}</option>
{% else %}
<option value="{{ session.id }}">{{ session.name }}</option>
{% endif %}
{% endfor %}
</select>
</li>
</ul>
<div class="card-body">
<div class="btn-group mx-2" role="group">
<button
hx-delete="/api/tasks/{{task.id}}"
@ -49,6 +48,9 @@
</button>
</div>
</div>
<div class="card-footer">
<small class="text-body-secondary">Создано {{ task.datetime.strftime("%d.%m.%y") }} в {{ task.datetime.strftime("%H:%M") }}</small>
</div>
</div>
</div>
{% else %}

View File

@ -13,7 +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"))
datetime: Mapped[DateTime] = Column(DateTime, default=datetime.datetime.utcnow())
status: Mapped[str]
status_message: Mapped[str]
type: Mapped[str]