|
|
|
@ -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}",
|
|
|
|
|