changing session
This commit is contained in:
parent
5e1f0c1f56
commit
495812a2a6
|
@ -12,8 +12,9 @@ tasks = Blueprint("tasks", __name__, url_prefix="/tasks", template_folder="templ
|
||||||
@tasks.route("/", methods=["GET"])
|
@tasks.route("/", methods=["GET"])
|
||||||
def get_tasks():
|
def get_tasks():
|
||||||
tasks = Task.query.all()
|
tasks = Task.query.all()
|
||||||
|
sessions = Session.query.all()
|
||||||
|
|
||||||
return render_template("tasks_cards.j2", tasks=tasks)
|
return render_template("tasks_cards.j2", tasks=tasks, sessions=sessions)
|
||||||
|
|
||||||
@tasks.route("/<int:task_id>", methods=["GET"])
|
@tasks.route("/<int:task_id>", methods=["GET"])
|
||||||
def get_task(task_id: int):
|
def get_task(task_id: int):
|
||||||
|
@ -62,7 +63,7 @@ def stop_task(task_id: int):
|
||||||
case 'add':
|
case 'add':
|
||||||
fn = add_to_group_task
|
fn = add_to_group_task
|
||||||
|
|
||||||
if task.task_id:
|
if task.task_id and fn:
|
||||||
task_fn = fn.AsyncResult(task.task_id)
|
task_fn = fn.AsyncResult(task.task_id)
|
||||||
task_fn.abort()
|
task_fn.abort()
|
||||||
|
|
||||||
|
@ -86,3 +87,18 @@ def start_task(task_id: int):
|
||||||
add_to_group_task.delay(task_id=task_id)
|
add_to_group_task.delay(task_id=task_id)
|
||||||
|
|
||||||
return 'Started', 200
|
return 'Started', 200
|
||||||
|
|
||||||
|
@tasks.route("/<int:task_id>/change", methods=["PUT"])
|
||||||
|
def change_settings(task_id: int):
|
||||||
|
task: Task = Task.query.get_or_404(task_id)
|
||||||
|
data = request.form
|
||||||
|
|
||||||
|
if data.get("session"):
|
||||||
|
task.session = Session.query.get(data.get("session"))
|
||||||
|
|
||||||
|
if data.get("name"):
|
||||||
|
task.name = data.get("name")
|
||||||
|
|
||||||
|
db.session.commit()
|
||||||
|
|
||||||
|
return 'Changed', 200
|
|
@ -8,10 +8,29 @@
|
||||||
<li class="list-group-item">Статус: {{ task.status }}</li>
|
<li class="list-group-item">Статус: {{ task.status }}</li>
|
||||||
<li class="list-group-item">Сообщение: {{ task.status_message }}</li>
|
<li class="list-group-item">Сообщение: {{ task.status_message }}</li>
|
||||||
<li class="list-group-item">Действие: {{ task.type }}</li>
|
<li class="list-group-item">Действие: {{ task.type }}</li>
|
||||||
<li class="list-group-item">Сессия: {{ task.session.name }}</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>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-footer">
|
||||||
<button
|
<button
|
||||||
hx-delete="/api/tasks/{{task.id}}"
|
hx-delete="/api/tasks/{{task.id}}"
|
||||||
hx-swap="delete"
|
hx-swap="delete"
|
||||||
|
|
Loading…
Reference in New Issue