Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
1311 Разработка системы заявок для 3д печати
project_1311
Commits
d241bc3e
Commit
d241bc3e
authored
6 months ago
by
“Mikkelando”
Browse files
Options
Download
Patches
Plain Diff
added cancelation of order on wait_confiramation stage
parent
320e2941
develop
crossserver
main
profile
revert-7060de16
withBot
xserver
1 merge request
!16
Profile
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
movere_local/mainapp/templates/mainapp/view_orders.html
+27
-3
movere_local/mainapp/templates/mainapp/view_orders.html
movere_local/mainapp/urls.py
+1
-1
movere_local/mainapp/urls.py
movere_local/mainapp/views.py
+17
-1
movere_local/mainapp/views.py
with
45 additions
and
5 deletions
+45
-5
movere_local/mainapp/templates/mainapp/view_orders.html
+
27
−
3
View file @
d241bc3e
...
...
@@ -21,18 +21,36 @@
width
:
20%
;
}
</style>
<script>
function
confirmCancel
(
orderId
)
{
if
(
confirm
(
'
Вы уверены, что хотите отменить этот заказ?
'
))
{
document
.
getElementById
(
'
cancel-form-
'
+
orderId
).
submit
();
}
}
</script>
</head>
<body>
<h1>
Список заказов
</h1>
<a
href=
"{% url 'create_order' %}"
style=
"display: inline-block; padding: 10px 20px; background-color: #4CAF50; color: white; text-decoration: none; border-radius: 5px;"
>
Создать новый заказ
</a>
<button
onclick=
"location.href='{% url 'home' %}'"
>
Домой
</button>
<table>
<thead>
<tr>
{% for status, _ in orders_status_list %}
<th
class=
"status-column"
>
{% if status == 'wait_confirmation' %}Ожидает подтверждения{% elif status == 'in_work' %}Отправлен на печать{% elif status == 'ready' %}Готов{% elif status == 'done' %}Выполнен{% elif status == 'canceled' %}Отменен{% endif %}
{% if status == 'wait_confirmation' %}
Ожидает подтверждения
{% elif status == 'in_work' %}
Отправлен на печать
{% elif status == 'ready' %}
Готов
{% elif status == 'done' %}
Выполнен
{% elif status == 'canceled' %}
Отменен
{% endif %}
</th>
{% endfor %}
</tr>
...
...
@@ -48,9 +66,15 @@
Заказ ID: {{ order.id }}
<br>
Дата: {{ order.order_datetime }}
<br>
Параметры: {{ order.order_parameters }}
<br>
Файл: {% if order.file_basename %}{{ order.file_basename }}{% else %}Нет файла{% endif %}
Файл: {% if order.file_basename %}{{ order.file_basename }}{% else %}Нет файла{% endif %}
<br>
{% if order.order_state == 'done' or order.order_state == 'canceled' %}
{% if order.order_state == 'wait_confirmation' %}
<!-- Кнопка для отмены заказа с подтверждением -->
<button
onclick=
"confirmCancel({{ order.id }})"
>
Отменить заказ
</button>
<form
id=
"cancel-form-{{ order.id }}"
method=
"post"
action=
"{% url 'cancel_order' order.id %}"
style=
"display: none;"
>
{% csrf_token %}
</form>
{% elif order.order_state == 'done' or order.order_state == 'canceled' %}
<form
method=
"post"
action=
"{% url 'archive_order' order.id %}"
>
{% csrf_token %}
<button
type=
"submit"
>
В архив
</button>
...
...
This diff is collapsed.
Click to expand it.
movere_local/mainapp/urls.py
+
1
−
1
View file @
d241bc3e
...
...
@@ -22,7 +22,7 @@ urlpatterns = [
path
(
'api/orders/'
,
views
.
order_list_api
,
name
=
'order_list_api'
),
path
(
'download-file/<path:file_name>/'
,
views
.
download_file
,
name
=
'download_file'
),
path
(
'api/mark-order-processed/<int:order_id>/'
,
views
.
mark_order_as_processed
,
name
=
'mark_order_as_processed'
),
path
(
'cancel_order/<int:order_id>/'
,
views
.
cancel_order
,
name
=
'cancel_order'
),
# path('serve-file/<str:file_name>/', views.serve_file, name='serve_file'),
# re_path(r'^download-file/(?P<path>.*)$', views.download_file, name='download_file'),
# re_path(r'^serve-file/(?P<path>.*)$', views.download_file, name='download_file')
...
...
This diff is collapsed.
Click to expand it.
movere_local/mainapp/views.py
+
17
−
1
View file @
d241bc3e
...
...
@@ -374,4 +374,20 @@ def serve_file(request, file_name):
print
(
file_path
)
if
not
os
.
path
.
exists
(
file_path
):
raise
Http404
(
"File not found"
)
return
FileResponse
(
open
(
file_path
,
'rb'
))
\ No newline at end of file
return
FileResponse
(
open
(
file_path
,
'rb'
))
@login_required
# @require_POST
def
cancel_order
(
request
,
order_id
):
# Получаем заказ или возвращаем 404, если не найден
order
=
get_object_or_404
(
Order
,
id
=
order_id
,
user
=
request
.
user
)
# Проверяем, что заказ находится в состоянии "ожидания подтверждения"
if
order
.
order_state
==
'wait_confirmation'
:
# Меняем статус на "отменен"
order
.
order_state
=
'canceled'
order
.
save
()
# Возвращаем пользователя на страницу заказов
return
redirect
(
'view_orders'
)
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets