diff --git a/prices/templates/prices/price_list.html b/prices/templates/prices/price_list.html index c5bb97b..f4d0c75 100644 --- a/prices/templates/prices/price_list.html +++ b/prices/templates/prices/price_list.html @@ -1,5 +1,8 @@ {% extends "programmer/base.html" %} +{% load django_bootstrap5 %} {% load static %} +{% load seo_tags %} +{% block body_attrs %}data-show-floating-button="false"{% endblock %} {% block content %} {% endif %} + +{% endblock %} + +{% block extra_js %} + + {% endblock %} \ No newline at end of file diff --git a/prices/views.py b/prices/views.py index 5f223d6..61c4f14 100644 --- a/prices/views.py +++ b/prices/views.py @@ -9,6 +9,9 @@ from django.shortcuts import redirect from django.views.generic import ListView from programmer.mixins import MenuContextMixin, BreadcrumbMixin from .models import PriceItem +from programmer.forms import CallbackForm +from typing import Any, Dict + def update_prices_from_api(request): """Загружает прайс из API с Basic Auth и обновляет таблицу PriceItem.""" @@ -66,8 +69,16 @@ class PriceListView(MenuContextMixin, BreadcrumbMixin, ListView): def get_breadcrumbs(self): return [{'title': 'Прайс-лист', 'url_name': None}] - def get_context_data(self, **kwargs): + def get_context_data(self, **kwargs: Any) -> Dict[str, Any]: context = super().get_context_data(**kwargs) + form = CallbackForm() + + if self.request.user.is_authenticated: + if 'captcha' in form.fields: + del form.fields['captcha'] + + context['form'] = form + context.update({ 'title': 'Прайс-лист на услуги 1С | С.Н.А. Технологии', 'meta_description': 'Актуальные цены на услуги программиста 1С: аудит, обновление, разработка, интеграция и другие.', diff --git a/programmer/static/programmer/js/floating-button.js b/programmer/static/programmer/js/floating-button.js index b2b3268..728132d 100644 --- a/programmer/static/programmer/js/floating-button.js +++ b/programmer/static/programmer/js/floating-button.js @@ -5,6 +5,17 @@ const CallbackModal = { floatingBtnId: 'floatingButton', init() { + const body = document.body; + const showButton = body.dataset.showFloatingButton !== 'false' && body.dataset.showFloatingButton !== '0'; + const delay = parseInt(body.dataset.floatingDelay, 10) || 5000; + + if (!showButton) { + // Кнопка отключена – скрываем навсегда + const btn = document.getElementById(this.floatingBtnId); + if (btn) btn.style.display = 'none'; + return; + } + setTimeout(() => { const btn = document.getElementById(this.floatingBtnId); if (btn) { @@ -13,7 +24,7 @@ const CallbackModal = { const button = btn.querySelector('.btn'); if (button) button.classList.add('pulse'); } - }, 5000); + }, delay); }, open(productTitle) { @@ -21,9 +32,9 @@ const CallbackModal = { if (modal) { if (productTitle) { - const questionField = modal.querySelector('#id_question'); - if (questionField) { - questionField.value = `Запрос цены по ПП "${productTitle}"`; + const questionField = modal.querySelector('#id_question'); + if (questionField) { + questionField.value = `Запрос цены по ПП "${productTitle}"`; } } diff --git a/programmer/templates/programmer/base.html b/programmer/templates/programmer/base.html index 6fbe985..e9df5bc 100644 --- a/programmer/templates/programmer/base.html +++ b/programmer/templates/programmer/base.html @@ -132,7 +132,7 @@ - + {% block mainmenu %}
@@ -438,7 +438,7 @@ {{ callback_form.question }} - {% if form.captcha %} + {% if callback_form.captcha %}
{{ callback_form.captcha }}