Site/programmer/templates/programmer/includes/notification_settings.html

25 lines
1.0 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<h3>🔔 Настройки уведомлений</h3>
<form id="notif-form">
{% csrf_token %}
<label>
<input type="checkbox" name="notify_new_articles" {% if profile.notify_new_articles %}checked{% endif %}>
Уведомлять о новых статьях
</label><br>
<label>
<input type="checkbox" name="notify_new_products" {% if profile.notify_new_products %}checked{% endif %}>
Уведомлять о новых продуктах
</label><br>
<button type="submit" class="btn btn-primary">Сохранить</button>
</form>
<script>
document.getElementById('notif-form').addEventListener('submit', function(e) {
e.preventDefault();
fetch('{% url "notification_settings" %}', {
method: 'POST',
body: new FormData(this),
headers: { 'X-CSRFToken': document.querySelector('[name=csrfmiddlewaretoken]').value }
})
.then(response => response.json())
.then(data => { if (data.status === 'ok') alert('Настройки сохранены!'); });
});
</script>