349 lines
17 KiB
HTML
349 lines
17 KiB
HTML
{% extends "base.html" %}
|
||
{% import "/components/header.html" as header %}
|
||
{% import "/components/footer.html" as footer %}
|
||
{% import "components/profile_card.html" as profile_card %}
|
||
{% import "components/profile_nav.html" as profile_nav %}
|
||
{% import "competition/list.html" as competition %}
|
||
{% import "components/label.html" as label %}
|
||
|
||
{% block title %}Отобранные картины | Выставка {{exhibition.title}}{% endblock %}
|
||
|
||
|
||
{% block content %}
|
||
{{ header.section(user) }}
|
||
<section class="c_dg3k4">
|
||
<div class="c_gtoe9">
|
||
{{ profile_card.profile_card(user) }}
|
||
<div class="c_ru432">
|
||
{{ profile_nav.profile_nav(user, 'exhibitions') }}
|
||
<div class="c_3ihvi" id="main">
|
||
{% if now < exhibition.date_finish %}
|
||
<a class="b_289i1 ba" href="/profile/partner/exhibition/{{exhibition._id}}/catalog#main">
|
||
<span class="c_d2l0b b_al8e7">Каталог картин</span>
|
||
</a>
|
||
{% endif %}
|
||
{% set ids = posts
|
||
| selectattr('status', 'equalto', 'В каталоге')
|
||
| map(attribute='user._id')
|
||
| list
|
||
%}
|
||
{% set uniq_count = ids | unique | list | length %}
|
||
{% if uniq_count > 0 %}
|
||
<button class="b_289i1 ba" onclick="sendInvitations('{{exhibition._id}}')" href="/profile/partner/exhibition/{{exhibition._id}}/catalog#main">
|
||
<span class="c_d2l0b b_al8e7">Отправить приглашени{% if uniq_count > 1 %}я{% else %}е{% endif %}</span>
|
||
</button>
|
||
{% endif %}
|
||
</div>
|
||
<div class="c_tihtk">
|
||
<article class="c_9fgdh b_ax8vz">
|
||
<div class="b_ornr9">
|
||
<picture>
|
||
<img src="/b/exhibition/{{exhibition.poster_file_id}}" data-src="/b/exhibition/{{exhibition.poster_orig_id}}" id="preview_poster" crossorigin="anonymous" fetchpriority="high" loading="eager" alt="Выставка {{exhibition.title}}" class="b_ornr9">
|
||
</picture>
|
||
</div>
|
||
<div class="c_z3dpx b_73p10">
|
||
<div class="c_c4wam b_vabj9">
|
||
{% if now > exhibition.date_finish %}
|
||
<span class="c_95csi b_0jst1">Закончилась</span>
|
||
{% elif now > exhibition.datetime_start %}
|
||
<span class="c_95csi b_0jst1">Началась</span>
|
||
{% else %}
|
||
<span class="c_95csi b_0jst1">Формируется</span>
|
||
{% endif %}
|
||
</div>
|
||
<header class="c_m876y b_9xtz9">
|
||
<h3 class="c_hysjg b_8f3uh" id="preview_title">Выставка {{exhibition.title}}</h3>
|
||
</header>
|
||
<p class="c_2fr39 b_tfnz2" id="preview_topic">{{exhibition.topic}}</p>
|
||
<p>Место проведения: {{ exhibition.get('place') }}</p>
|
||
<p >Отобрано картин: <span id="lenPosts">{{ posts | length }}</span></p>
|
||
|
||
<div class="b_otttb">
|
||
<span class="c_2fr39 b_tfnz2">С {{ ( exhibition.datetime_start.strftime('%d.%m.%Y')) if exhibition.datetime_start else ''}}</span>
|
||
<span class="c_2fr39 b_tfnz2">По {{ ( exhibition.date_finish.strftime('%d.%m.%Y')) if exhibition.date_finish else ''}}</span>
|
||
</div>
|
||
</div>
|
||
</article>
|
||
{% for post in posts %}
|
||
<article class="c_9fgdh b_ax8vz">
|
||
<div class="b_ornr9">
|
||
<picture>
|
||
<img src="/b/posts/{{post.medias[0]}}" data-src="/b/posts/{{ post.medias_original[0] }}" crossorigin="anonymous" fetchpriority="high" loading="eager" alt="{{post.title}}" class="b_ornr9">
|
||
</picture>
|
||
</div>
|
||
<div class="c_z3dpx b_73p10">
|
||
<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">
|
||
<input type="checkbox"
|
||
onchange="saledPaintings('{{post._id}}')"
|
||
class="offer-checkbox"
|
||
{% if post.status == 'Продано' %}checked{%endif%}>
|
||
<span>Продано</span>
|
||
</label>
|
||
{% endif %}
|
||
{% if post.status=='В каталоге' %}
|
||
<div class="l_green" id="SC"><span>{{post.status}}</span></div>
|
||
{% else %}
|
||
<div class="l_purple"><span>{{post.status}}</span></div>
|
||
{% endif %}
|
||
<p class="c_2fr39 b_tfnz2" id="preview_topic">Размер: {{post.size}}</p>
|
||
<p class="c_2fr39 b_tfnz2" id="preview_topic">Материал: {{post.material}}</p>
|
||
<p class="c_2fr39 b_tfnz2" id="preview_topic">Жанр: {{post.genre}}</p>
|
||
<div class="c_dbbe4 b_otttb">
|
||
{% if post.user %}
|
||
<img crossorigin="anonymous" fetchpriority="high" loading="eager" class="c_pm80w b_a68fq" src="/a/{{post.user._id}}" alt="{{ post.user.username | e }}">
|
||
<div class="c_4402p b_ntazj">
|
||
<p class="c_kvah4 b_ghosy">{{ post.user.username }}</p>
|
||
<!-- <p class="c_kvah4 b_ghosy">{{ post.grade }}</p> -->
|
||
</div>
|
||
{% endif %}
|
||
</div>
|
||
<details style="margin-bottom: 1.25rem;">
|
||
<summary>Показать контакты</summary>
|
||
<div class="menua">
|
||
<a class="icona" href="/artists/{{post.user._id}}">
|
||
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="#5F1798">
|
||
<path
|
||
d="M234-276q51-39 114-61.5T480-360q69 0 132 22.5T726-276q35-41 54.5-93T800-480q0-133-93.5-226.5T480-800q-133 0-226.5 93.5T160-480q0 59 19.5 111t54.5 93Zm146.5-204.5Q340-521 340-580t40.5-99.5Q421-720 480-720t99.5 40.5Q620-639 620-580t-40.5 99.5Q539-440 480-440t-99.5-40.5ZM480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480q0 83-31.5 156T763-197q-54 54-127 85.5T480-80Zm100-95.5q47-15.5 86-44.5-39-29-86-44.5T480-280q-53 0-100 15.5T294-220q39 29 86 44.5T480-160q53 0 100-15.5ZM523-537q17-17 17-43t-17-43q-17-17-43-17t-43 17q-17 17-17 43t17 43q17 17 43 17t43-17Zm-43-43Zm0 360Z" />
|
||
</svg>
|
||
<span>Профиль</span>
|
||
</a>
|
||
<a class="icona" href="tel:{{post.user.phone.split(',')[-1].strip()}}"><svg xmlns="http://www.w3.org/2000/svg" height="24px"
|
||
viewBox="0 -960 960 960" width="24px" fill="#5F1798">
|
||
<path
|
||
d="M162-120q-18 0-30-12t-12-30v-162q0-13 9-23.5t23-14.5l138-28q14-2 28.5 2.5T342-374l94 94q38-22 72-48.5t65-57.5q33-32 60.5-66.5T681-524l-97-98q-8-8-11-19t-1-27l26-140q2-13 13-22.5t25-9.5h162q18 0 30 12t12 30q0 125-54.5 247T631-329Q531-229 409-174.5T162-120Zm556-480q17-39 26-79t14-81h-88l-18 94 66 66ZM360-244l-66-66-94 20v88q41-3 81-14t79-28Zm358-356ZM360-244Z" />
|
||
</svg>
|
||
<span>{{ post.user.phone.split(',')[-1].strip() }}</span>
|
||
</a>
|
||
<a class="icona" href="mailto:{{post.user.email}}"> <svg xmlns="http://www.w3.org/2000/svg" height="24px"
|
||
viewBox="0 -960 960 960" width="24px" fill="#5F1798">
|
||
<path
|
||
d="M480-80q-83 0-156-31.5T197-197q-54-54-85.5-127T80-480q0-83 31.5-156T197-763q54-54 127-85.5T480-880q83 0 156 31.5T763-763q54 54 85.5 127T880-480v58q0 59-40.5 100.5T740-280q-35 0-66-15t-52-43q-29 29-65.5 43.5T480-280q-83 0-141.5-58.5T280-480q0-83 58.5-141.5T480-680q83 0 141.5 58.5T680-480v58q0 26 17 44t43 18q26 0 43-18t17-44v-58q0-134-93-227t-227-93q-134 0-227 93t-93 227q0 134 93 227t227 93h200v80H480Zm85-315q35-35 35-85t-35-85q-35-35-85-35t-85 35q-35 35-35 85t35 85q35 35 85 35t85-35Z" />
|
||
</svg>
|
||
<span>{{post.user.email}}</span>
|
||
</a>
|
||
<div class="icona"><span>Написать</span></div>
|
||
<div class="icona">
|
||
|
||
<a class="icona" href="{% if post.user.vk_id %}https://vk.ru/im?sel={{post.user.vk_id}}{%else%}#{%endif%}"
|
||
{% if not post.user.vk_id %}onclick="showToast({message: 'У пользователя не привязан ВК'})"{%endif%}>
|
||
<img src="/static/icons/vk.svg" height="40">
|
||
</a>
|
||
|
||
<a class="icona" href="https://telegram.me/{{post.user.phone.split(',')[-1].strip()}}">
|
||
<img src="/static/icons/tg.svg" height="40">
|
||
<!-- <span>Написать в ТГ</span> -->
|
||
</a>
|
||
<a class="icona" href="https://max.ru/{{post.user.phone.split(',')[-1].strip()}}">
|
||
<img src="/static/icons/max.svg" height="40" style="border-radius: 50% 50% 50% 30%;">
|
||
<!-- <span>Написать в MAX</span> -->
|
||
</a>
|
||
<a class="icona" href="https://wa.me/{{post.user.phone.split(',')[-1].strip()}}">
|
||
<img src="/static/icons/wapp.svg" height="40">
|
||
<!-- <span>Написать в WA</span> -->
|
||
</a>
|
||
</div>
|
||
|
||
|
||
</div>
|
||
</details>
|
||
{% if post.status=='В каталоге' %}
|
||
<button onclick="selectPost(this, '{{post._id}}')" class="c_ctfod b_289i1">
|
||
<span class="c_d2l0b b_al8e7">Убрать с выставки</span>
|
||
</button>
|
||
{% endif %}
|
||
{% if post.status == 'Ожидает получения' %}
|
||
{# <button class="b_289i1" onclick="btnAccept(this, '{{post.d_id}}')"><span class="b_al8e7">Получить</span></button> #}
|
||
<a class="b_289i1" href="/profile/delivery/exhibition/{{exhibition._id}}#main">
|
||
<span class="b_al8e7">Получить</span>
|
||
</a>
|
||
{% endif %}
|
||
{% if post.status in ['Возврат художнику']%}
|
||
<a class="b_289i1" href="/profile/delivery/exhibition/{{exhibition._id}}#main">
|
||
<span class="b_al8e7">Отправить</span>
|
||
</a>
|
||
{% endif %}
|
||
</div>
|
||
</article>
|
||
{% endfor %}
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</section>
|
||
<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>
|
||
async function btnAccept(btn, itemId){
|
||
const figcaption = btn.parentElement;
|
||
const statusDiv = figcaption.querySelectorAll('div')[0];
|
||
const statusSpan = statusDiv.querySelector('span')
|
||
|
||
try {
|
||
const res = await fetch('/api/delivery/accept', {
|
||
method: 'POST',
|
||
headers: { 'Content-Type': 'application/json' },
|
||
body: JSON.stringify({
|
||
item: itemId,
|
||
})
|
||
});
|
||
|
||
if (!res.ok) {
|
||
let errorMessage = 'Ошибка сохранения';
|
||
try {
|
||
const errorData = await res.json();
|
||
errorMessage = errorData.detail || errorMessage;
|
||
} catch (e) {
|
||
try {
|
||
const errorText = await res.text();
|
||
errorMessage = errorText || errorMessage;
|
||
} catch (e) {
|
||
}
|
||
}
|
||
showToast({ message: errorMessage, duration: 2500 });
|
||
return;
|
||
}
|
||
statusDiv.className = 'b_thlt1';
|
||
statusSpan.className = 'b_5dr47';
|
||
statusSpan.textContent = 'Получено';
|
||
btn.style.display = 'none'
|
||
} catch (error) {
|
||
console.error('Network error:', error);
|
||
showToast({ message: 'Не удалось подключиться к серверу', duration: 2500 });
|
||
}
|
||
};
|
||
</script>
|
||
#}
|
||
<script>
|
||
async function sendInvitations(exhibition_id) {
|
||
const data = new FormData();
|
||
data.set('exhibition_id', exhibition_id);
|
||
document.querySelectorAll('#SC').forEach(el=>{
|
||
el.className = 'l_purple';
|
||
el.querySelector('span').textContent = 'Ожидает принятия условий';
|
||
})
|
||
try {
|
||
const res = await fetch('/api/exhibition/send/invitations', {
|
||
method: 'POST',
|
||
body: data
|
||
});
|
||
|
||
if (res.ok) {
|
||
showToast({ message: 'Приглашени{% if uniq_count > 1 %}я{% else %}е{% endif %} отправлен{% if uniq_count > 1 %}ы{% else %}о{% endif %}' });
|
||
}
|
||
else {
|
||
showToast({ message: 'Ошибка сохранения', status: "error", duration: 2500 });
|
||
}
|
||
} catch (err) {
|
||
console.error(err);
|
||
showToast({ message: 'Ошибка соединения', status: "error", duration: 2500 });
|
||
}
|
||
}
|
||
async function selectPost(select, postId) {
|
||
const data = new FormData();
|
||
data.set('post_id', postId);
|
||
data.set('exhibition_id', '{{exhibition._id}}');
|
||
try {
|
||
const res = await fetch('/api/exhibition/post/select', {
|
||
method: 'POST',
|
||
body: data
|
||
});
|
||
|
||
if (res.ok) {
|
||
document.getElementById('lenPosts').textContent = parseInt(document.getElementById('lenPosts').textContent) - 1
|
||
select.parentElement.parentElement.style.display = 'none'
|
||
}
|
||
else {
|
||
showToast({ message: 'Ошибка сохранения', status: "error", duration: 2500 });
|
||
select.checked = false
|
||
}
|
||
} catch (err) {
|
||
console.error(err);
|
||
showToast({ message: 'Ошибка соединения', status: "error", duration: 2500 });
|
||
select.checked = false
|
||
}
|
||
}
|
||
</script>
|
||
{{ footer.section(user) }}
|
||
{% endblock %}
|
||
|
||
{% block head %}
|
||
{{ header.style() }}
|
||
{{ profile_nav.style() }}
|
||
{{ competition.style() }}
|
||
<style>
|
||
.menua{width: 100%;
|
||
display: flex;
|
||
flex-direction: column;
|
||
gap: 7px;
|
||
margin: 10px 20px;}
|
||
.icona{display: flex;
|
||
gap: 10px;
|
||
align-items: center;}
|
||
.icona>span{color: #5F1798;}
|
||
{{label.green()}}
|
||
{{label.purple()}}
|
||
.b_0jst1 { color: #0ED646; font-family: Inter; font-size: 12px; font-style: normal; font-weight: 700; line-height: normal; }
|
||
.b_vabj9 { align-items: center; background: rgba(14, 214, 70, 0.20); border-radius: 30px; display: flex; justify-content: center; padding: 1.5px 10px; }
|
||
.b_0jst1_2 { color: #5F1798; font-family: Inter; font-size: 12px; font-style: normal; font-weight: 700; line-height: normal; }
|
||
.b_vabj9_2 { align-items: center; background: #5e17982f; border-radius: 30px; display: flex; justify-content: center; padding: 1.5px 10px; }
|
||
#preview_poster{min-height: 456px;}
|
||
body{background: #F6EBFF;}
|
||
.c_3ihvi{ position: sticky; top: 0; z-index: 2; background: white; }
|
||
.b_289i1{ width: 100%; padding: 15px; box-sizing: border-box; }
|
||
.c_ctfod{ width: 100%; padding: 13px 0; }
|
||
/* Mobile */
|
||
@media (max-width: 699px) {
|
||
.c_mrl59 { align-items: center; background: #5F1798; border-radius: 25px; bottom: -15px; display: flex; height: 50px; justify-content: center; position: absolute; right: -15px; width: 50px; }
|
||
}
|
||
|
||
/* Tablet */
|
||
@media (min-width: 700px) and (max-width: 900px) {
|
||
.c_iiehk { align-items: center; border-radius: 5px; display: flex; flex-direction: column; gap: 20px; width: 335px; }
|
||
.c_nnsh6>a>img{display: none;}
|
||
|
||
}
|
||
|
||
/* Desktop */
|
||
@media (min-width: 901px) {
|
||
.c_iiehk { align-items: flex-end; border-radius: 5px; display: flex; flex-direction: column; gap: 20px; width: 310px; }
|
||
.c_nnsh6>a>img{display: none;}
|
||
|
||
}
|
||
</style>
|
||
|
||
{{ footer.style() }}
|
||
{% endblock %} |