fix: кнопка на главную после оплаты + исправление отправки SMTP письма
This commit is contained in:
+4
-4
@@ -151,13 +151,13 @@
|
|||||||
<div class="success-icon-wrapper">
|
<div class="success-icon-wrapper">
|
||||||
<div class="success-icon">✓</div>
|
<div class="success-icon">✓</div>
|
||||||
</div>
|
</div>
|
||||||
<h2 class="success-title">Заявка отправлена!</h2>
|
<h2 class="success-title">Оплата прошла успешно!</h2>
|
||||||
<p class="success-text">
|
<p class="success-text">
|
||||||
Спасибо за ваше обращение!<br>
|
Спасибо за оплату!<br>
|
||||||
Наш киберспортивный координатор свяжется с вами в ближайшее время, чтобы открыть доступ к тестовым
|
Наш киберспортивный координатор свяжется с вами в ближайшее время, чтобы открыть доступ к тестовым
|
||||||
материалам и записать на бесплатный урок.
|
материалам и записать на занятие.
|
||||||
</p>
|
</p>
|
||||||
<button id="resetBtn" class="reset-btn">Вернуться к форме</button>
|
<button id="resetBtn" class="reset-btn">На главную</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
+3
-19
@@ -353,32 +353,16 @@ document.addEventListener('DOMContentLoaded', () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* ====================================================
|
/* ====================================================
|
||||||
Reset / Back to Form Handler
|
"На главную" Button Handler
|
||||||
==================================================== */
|
==================================================== */
|
||||||
resetBtn.addEventListener('click', () => {
|
resetBtn.addEventListener('click', () => {
|
||||||
successContainer.style.transition = 'opacity 0.3s ease, transform 0.3s ease';
|
successContainer.style.transition = 'opacity 0.3s ease, transform 0.3s ease';
|
||||||
successContainer.style.opacity = '0';
|
successContainer.style.opacity = '0';
|
||||||
successContainer.style.transform = 'translateY(10px)';
|
successContainer.style.transform = 'translateY(10px)';
|
||||||
|
|
||||||
// Remove parameters from URL to prevent showing success container on reload
|
|
||||||
const newUrl = window.location.protocol + "//" + window.location.host + window.location.pathname + "?service_id=" + serviceIdInput.value;
|
|
||||||
window.history.replaceState({ path: newUrl }, '', newUrl);
|
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
successContainer.style.display = 'none';
|
// Редиректим на главную страницу сайта
|
||||||
formContainer.style.display = 'block';
|
window.location.href = '/';
|
||||||
formContainer.style.opacity = '0';
|
|
||||||
formContainer.style.transform = 'translateY(-10px)';
|
|
||||||
|
|
||||||
formContainer.offsetHeight;
|
|
||||||
|
|
||||||
formContainer.style.transition = 'opacity 0.4s ease, transform 0.4s ease';
|
|
||||||
formContainer.style.opacity = '1';
|
|
||||||
formContainer.style.transform = 'translateY(0)';
|
|
||||||
|
|
||||||
if (serviceIdInput.value && services[serviceIdInput.value]) {
|
|
||||||
serviceDisplay.style.display = 'block';
|
|
||||||
}
|
|
||||||
}, 300);
|
}, 300);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -452,11 +452,12 @@ def send_email_notification(reg_id, data, paid=False):
|
|||||||
</html>
|
</html>
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
server = None
|
||||||
try:
|
try:
|
||||||
msg = MIMEMultipart('alternative')
|
msg = MIMEMultipart('alternative')
|
||||||
msg['Subject'] = subject
|
msg['Subject'] = subject
|
||||||
msg['From'] = smtp_from
|
msg['From'] = smtp_from
|
||||||
msg['To'] = smtp_to
|
msg['To'] = ', '.join(smtp_to) # заголовок — строка
|
||||||
msg.attach(MIMEText(html_content, 'html', 'utf-8'))
|
msg.attach(MIMEText(html_content, 'html', 'utf-8'))
|
||||||
|
|
||||||
if smtp_port == 465:
|
if smtp_port == 465:
|
||||||
@@ -466,13 +467,18 @@ def send_email_notification(reg_id, data, paid=False):
|
|||||||
server.starttls()
|
server.starttls()
|
||||||
|
|
||||||
server.login(smtp_user, smtp_password)
|
server.login(smtp_user, smtp_password)
|
||||||
server.sendmail(smtp_from, [smtp_to], msg.as_string())
|
server.sendmail(smtp_from, smtp_to, msg.as_string()) # smtp_to — список
|
||||||
server.quit()
|
|
||||||
print(f"[SMTP] Письмо о заказе {reg_id} отправлено на {smtp_to}")
|
print(f"[SMTP] Письмо о заказе {reg_id} отправлено на {smtp_to}")
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print(f"[SMTP] Ошибка отправки письма: {e}")
|
print(f"[SMTP] Ошибка отправки письма: {e}")
|
||||||
return False
|
return False
|
||||||
|
finally:
|
||||||
|
if server:
|
||||||
|
try:
|
||||||
|
server.quit()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
|
||||||
# ====================================================
|
# ====================================================
|
||||||
# Flask Web App Routes
|
# Flask Web App Routes
|
||||||
|
|||||||
Reference in New Issue
Block a user