Исправил ошибку с заполнением формы с прайса
This commit is contained in:
parent
2a93cd8a8f
commit
7ca185407b
@ -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 %}
|
||||
<div class="page-header">
|
||||
@ -31,6 +34,9 @@
|
||||
<td>{{ forloop.counter }}</td>
|
||||
<td>{{ item.name }}</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>
|
||||
{% empty %}
|
||||
<tr>
|
||||
@ -51,4 +57,10 @@
|
||||
</div>
|
||||
{% endif %}
|
||||
</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 %}
|
||||
@ -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С: аудит, обновление, разработка, интеграция и другие.',
|
||||
|
||||
@ -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}"`;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -132,7 +132,7 @@
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
<body {% block body_attrs %}{% endblock %}>
|
||||
<!-- Header -->
|
||||
{% block mainmenu %}
|
||||
<header class="header">
|
||||
@ -438,7 +438,7 @@
|
||||
{{ callback_form.question }}
|
||||
</div>
|
||||
|
||||
{% if form.captcha %}
|
||||
{% if callback_form.captcha %}
|
||||
<div class="form-group">
|
||||
<label for="id_captcha">Защитный код *</label>
|
||||
{{ callback_form.captcha }}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user