25 lines
1.0 KiB
HTML
25 lines
1.0 KiB
HTML
<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> |