fix: кнопка на главную после оплаты + исправление отправки SMTP письма

This commit is contained in:
2026-06-21 13:34:37 +03:00
parent dc49bef644
commit c2aa9b6442
3 changed files with 17 additions and 27 deletions
+4 -4
View File
@@ -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
View File
@@ -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);
}); });
}); });
+10 -4
View File
@@ -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:
@@ -464,15 +465,20 @@ def send_email_notification(reg_id, data, paid=False):
else: else:
server = smtplib.SMTP(smtp_server, smtp_port) server = smtplib.SMTP(smtp_server, smtp_port)
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