This commit is contained in:
vladislav 2026-09-01 22:19:40 -04:00
parent 18aa1774b6
commit 41c99e21b1
Signed by: Vladislav
GPG Key ID: D97C9E5E4860EE45
2 changed files with 41 additions and 0 deletions

View File

@ -186,6 +186,13 @@
</div>
<p class="c_zlnpy b_7efyd">{{paint.description or ''}}</p>
<p class="c_sbnel b_frv5u">{{ (paint._id.generation_time.strftime('%d.%m.%Y')) if paint._id else ''}}</p>
<label class="offer-label delivery-checkbox-label">
<input type="checkbox"
onchange="saledPaintings('{{paint._id}}')"
class="offer-checkbox delivery-checkbox send-checkbox"
{% if paint.status == 'Продано' %}checked{%endif%}>
<span>Продано</span>
</label>
{% if user and user._id == paint.user._id %}
<div class="c_ybfp2 b_gagrr" style="max-width: 320px;">
<a class="c_eiyz0 b_rhbo8" href="/form/post/{{paint._id}}">Редактировать</a>
@ -199,6 +206,38 @@
</div>
</section>
</div>
<script>
function saledPaintings(postId) {
fetch(`/api/post/${postId}/sale`, {
method: 'PUT'
})
.then(response => {
if (response.ok) {
// Find and delete the parent figure
const postElement = document.querySelector(`figure[data-postId='${postId}']`);
showToast({
message: 'Сохранено!',
status: 'info',
duration: 1200
});
} else {
showToast({
message: 'Ошибка соединения с сервером!',
status: 'error',
duration: 2500
});
}
})
.catch(error => {
// Handle network errors
showToast({
message: 'Ошибка соединения с сервером!',
status: 'error',
duration: 2500
});
});
}
</script>
<script>
const images = [
{% for media in paint.medias_original %}

View File

@ -75,6 +75,7 @@
<header class="c_m876y b_9xtz9">
<h3 class="c_hysjg b_8f3uh" id="preview_title">{{post.title}}</h3>
</header>
{% if post.status == 'На выставке' %}
<label class="offer-label delivery-checkbox-label">
<input type="checkbox"
onchange="saledPaintings('{{post._id}}')"
@ -82,6 +83,7 @@
{% if post.status == 'Продано' %}checked{%endif%}>
<span>Продано</span>
</label>
{% endif %}
{% if post.status=='В каталоге' %}
<div class="l_green"><span>{{post.status}}</span></div>
{% else %}