Make notifications available to all users and clear database matches on reset

master
Mark Veidemanis 1 year ago
parent 9519c1ac9f
commit 9a8bb9027f
Signed by: m
GPG Key ID: 5ACFCEED46C0904F

@ -5,4 +5,4 @@ register = template.Library()
@register.filter
def splitstr(value, arg):
return value.split(arg)
return value.split(arg)

@ -2,15 +2,16 @@ from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMix
from django.shortcuts import render
from rest_framework.views import APIView
from core.db.storage import db
from core.forms import NotificationRuleForm, NotificationSettingsForm
from core.lib.rules import NotificationRuleData
from core.models import NotificationRule, NotificationSettings
from core.views.helpers import ObjectCreate, ObjectDelete, ObjectList, ObjectUpdate
# Notifications - we create a new notification settings object if there isn't one
# Hence, there is only an update view, not a create view.
class NotificationsUpdate(LoginRequiredMixin, PermissionRequiredMixin, ObjectUpdate):
permission_required = "use_rules"
class NotificationsUpdate(LoginRequiredMixin, ObjectUpdate):
model = NotificationSettings
form_class = NotificationSettingsForm
@ -76,6 +77,9 @@ class RuleClear(LoginRequiredMixin, PermissionRequiredMixin, APIView):
rule.match[index] = None
rule.save()
rule_data = NotificationRuleData(rule.user, rule, db=db)
rule_data.clear_database_matches()
cleared_indices = ", ".join(rule.match)
context = {
"message": f"Cleared match status for indices: {cleared_indices}",

Loading…
Cancel
Save