Before simplifying order creation and editing
This commit is contained in:
@@ -50,7 +50,7 @@
|
||||
<form method="post" class="mt-4">
|
||||
{% csrf_token %}
|
||||
<div class="d-flex justify-content-between">
|
||||
<a href="{% url 'orders:order-detail' order.pk %}" class="btn btn-secondary btn-lg">
|
||||
<a href="{% url 'orders:order-detail' order.order_number %}" class="btn btn-secondary btn-lg">
|
||||
<i class="bi bi-arrow-left"></i> Отмена
|
||||
</a>
|
||||
<button type="submit" class="btn btn-danger btn-lg">
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
<h1>Заказ {{ order.order_number }}</h1>
|
||||
</div>
|
||||
<div class="col-auto">
|
||||
<a href="{% url 'orders:order-update' order.pk %}" class="btn btn-primary">
|
||||
<a href="{% url 'orders:order-update' order.order_number %}" class="btn btn-primary">
|
||||
<i class="bi bi-pencil"></i> Редактировать
|
||||
</a>
|
||||
<a href="{% url 'orders:order-delete' order.pk %}" class="btn btn-danger">
|
||||
<a href="{% url 'orders:order-delete' order.order_number %}" class="btn btn-danger">
|
||||
<i class="bi bi-trash"></i> Удалить
|
||||
</a>
|
||||
<a href="{% url 'orders:order-list' %}" class="btn btn-secondary">
|
||||
@@ -250,7 +250,7 @@
|
||||
<p class="text-muted small">Можно использовать для оплаты этого заказа</p>
|
||||
|
||||
<!-- Кнопка "Применить максимум" -->
|
||||
<form method="post" action="{% url 'orders:apply-wallet' order.pk %}" class="mb-2">
|
||||
<form method="post" action="{% url 'orders:apply-wallet' order.order_number %}" class="mb-2">
|
||||
{% csrf_token %}
|
||||
<input type="hidden" name="wallet_amount" value="{% if order.customer.wallet_balance < order.amount_due %}{{ order.customer.wallet_balance|floatformat:2 }}{% else %}{{ order.amount_due|floatformat:2 }}{% endif %}">
|
||||
<button type="submit" class="btn btn-success w-100">
|
||||
@@ -259,7 +259,7 @@
|
||||
</form>
|
||||
|
||||
<!-- Ручной ввод суммы -->
|
||||
<form method="post" action="{% url 'orders:apply-wallet' order.pk %}">
|
||||
<form method="post" action="{% url 'orders:apply-wallet' order.order_number %}">
|
||||
{% csrf_token %}
|
||||
<div class="input-group">
|
||||
<input
|
||||
|
||||
@@ -104,7 +104,7 @@
|
||||
{% for order in page_obj %}
|
||||
<tr>
|
||||
<td>
|
||||
<a href="{% url 'orders:order-detail' order.pk %}" class="text-decoration-none">
|
||||
<a href="{% url 'orders:order-detail' order.order_number %}" class="text-decoration-none">
|
||||
<strong>{{ order.order_number }}</strong>
|
||||
</a>
|
||||
</td>
|
||||
@@ -130,7 +130,7 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<div class="js-status-container" data-order-id="{{ order.pk }}">
|
||||
<div class="js-status-container" data-order-number="{{ order.order_number }}">
|
||||
<span class="badge badge-lg js-status-badge" style="{% if order.status %}background-color: {{ order.status.color }}; color: #fff;{% else %}background-color: #6c757d; color: #fff;{% endif %} cursor: pointer; font-size: 0.9rem; padding: 0.5rem 0.75rem;" title="Кликните для изменения">
|
||||
{% if order.status %}
|
||||
{{ order.status.label|default:order.status.name }}
|
||||
@@ -165,12 +165,12 @@
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<a href="{% url 'orders:order-detail' order.pk %}"
|
||||
<a href="{% url 'orders:order-detail' order.order_number %}"
|
||||
class="btn btn-sm btn-outline-primary"
|
||||
title="Просмотр">
|
||||
<i class="bi bi-eye"></i>
|
||||
</a>
|
||||
<a href="{% url 'orders:order-update' order.pk %}"
|
||||
<a href="{% url 'orders:order-update' order.order_number %}"
|
||||
class="btn btn-sm btn-outline-secondary"
|
||||
title="Редактировать">
|
||||
<i class="bi bi-pencil"></i>
|
||||
@@ -239,9 +239,9 @@
|
||||
(function() {
|
||||
const csrfToken = '{{ csrf_token }}';
|
||||
|
||||
async function updateStatus(orderId, statusId) {
|
||||
async function updateStatus(orderNumber, statusId) {
|
||||
const body = new URLSearchParams({ status_id: statusId }).toString();
|
||||
const resp = await fetch(`/orders/api/${orderId}/set-status/`, {
|
||||
const resp = await fetch(`/orders/api/${orderNumber}/set-status/`, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8',
|
||||
@@ -255,7 +255,7 @@
|
||||
document.querySelectorAll('.js-status-container').forEach(function(container) {
|
||||
const badge = container.querySelector('.js-status-badge');
|
||||
const select = container.querySelector('.js-status-select');
|
||||
const orderId = container.dataset.orderId;
|
||||
const orderNumber = container.dataset.orderNumber;
|
||||
|
||||
// Click on badge: show select
|
||||
badge.addEventListener('click', function() {
|
||||
@@ -278,7 +278,7 @@
|
||||
select.disabled = true;
|
||||
|
||||
try {
|
||||
const result = await updateStatus(orderId, statusId);
|
||||
const result = await updateStatus(orderNumber, statusId);
|
||||
if (result.success) {
|
||||
// Update badge
|
||||
const newColor = selectedOption.dataset.color || '#6c757d';
|
||||
|
||||
Reference in New Issue
Block a user