Исправил ошибку с заполнением формы с прайса
This commit is contained in:
parent
2a93cd8a8f
commit
7ca185407b
@ -1,5 +1,8 @@
|
|||||||
{% extends "programmer/base.html" %}
|
{% extends "programmer/base.html" %}
|
||||||
|
{% load django_bootstrap5 %}
|
||||||
{% load static %}
|
{% load static %}
|
||||||
|
{% load seo_tags %}
|
||||||
|
{% block body_attrs %}data-show-floating-button="false"{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
@ -31,6 +34,9 @@
|
|||||||
<td>{{ forloop.counter }}</td>
|
<td>{{ forloop.counter }}</td>
|
||||||
<td>{{ item.name }}</td>
|
<td>{{ item.name }}</td>
|
||||||
<td>{{ item.price|floatformat:0 }}</td>
|
<td>{{ item.price|floatformat:0 }}</td>
|
||||||
|
<td>
|
||||||
|
<a href="#" onclick="CallbackModal.open('{{ item.name }}'); return false;" class="btn btn-sm btn-outline-primary">уточнить</a>
|
||||||
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
{% empty %}
|
{% empty %}
|
||||||
<tr>
|
<tr>
|
||||||
@ -51,4 +57,10 @@
|
|||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block extra_js %}
|
||||||
|
<script src="{% static 'programmer/js/infinite_scroll.js' %}" defer></script>
|
||||||
|
<script src="{% static 'programmer/js/floating-button.js' %}" defer></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
@ -9,6 +9,9 @@ from django.shortcuts import redirect
|
|||||||
from django.views.generic import ListView
|
from django.views.generic import ListView
|
||||||
from programmer.mixins import MenuContextMixin, BreadcrumbMixin
|
from programmer.mixins import MenuContextMixin, BreadcrumbMixin
|
||||||
from .models import PriceItem
|
from .models import PriceItem
|
||||||
|
from programmer.forms import CallbackForm
|
||||||
|
from typing import Any, Dict
|
||||||
|
|
||||||
|
|
||||||
def update_prices_from_api(request):
|
def update_prices_from_api(request):
|
||||||
"""Загружает прайс из API с Basic Auth и обновляет таблицу PriceItem."""
|
"""Загружает прайс из API с Basic Auth и обновляет таблицу PriceItem."""
|
||||||
@ -66,8 +69,16 @@ class PriceListView(MenuContextMixin, BreadcrumbMixin, ListView):
|
|||||||
def get_breadcrumbs(self):
|
def get_breadcrumbs(self):
|
||||||
return [{'title': 'Прайс-лист', 'url_name': None}]
|
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)
|
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({
|
context.update({
|
||||||
'title': 'Прайс-лист на услуги 1С | С.Н.А. Технологии',
|
'title': 'Прайс-лист на услуги 1С | С.Н.А. Технологии',
|
||||||
'meta_description': 'Актуальные цены на услуги программиста 1С: аудит, обновление, разработка, интеграция и другие.',
|
'meta_description': 'Актуальные цены на услуги программиста 1С: аудит, обновление, разработка, интеграция и другие.',
|
||||||
|
|||||||
@ -5,6 +5,17 @@ const CallbackModal = {
|
|||||||
floatingBtnId: 'floatingButton',
|
floatingBtnId: 'floatingButton',
|
||||||
|
|
||||||
init() {
|
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(() => {
|
setTimeout(() => {
|
||||||
const btn = document.getElementById(this.floatingBtnId);
|
const btn = document.getElementById(this.floatingBtnId);
|
||||||
if (btn) {
|
if (btn) {
|
||||||
@ -13,7 +24,7 @@ const CallbackModal = {
|
|||||||
const button = btn.querySelector('.btn');
|
const button = btn.querySelector('.btn');
|
||||||
if (button) button.classList.add('pulse');
|
if (button) button.classList.add('pulse');
|
||||||
}
|
}
|
||||||
}, 5000);
|
}, delay);
|
||||||
},
|
},
|
||||||
|
|
||||||
open(productTitle) {
|
open(productTitle) {
|
||||||
|
|||||||
@ -132,7 +132,7 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body {% block body_attrs %}{% endblock %}>
|
||||||
<!-- Header -->
|
<!-- Header -->
|
||||||
{% block mainmenu %}
|
{% block mainmenu %}
|
||||||
<header class="header">
|
<header class="header">
|
||||||
@ -438,7 +438,7 @@
|
|||||||
{{ callback_form.question }}
|
{{ callback_form.question }}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% if form.captcha %}
|
{% if callback_form.captcha %}
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="id_captcha">Защитный код *</label>
|
<label for="id_captcha">Защитный код *</label>
|
||||||
{{ callback_form.captcha }}
|
{{ callback_form.captcha }}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user