feat: add email notifications for suffix approval process
Introduced email notifications for the suffix approval process: - Notify prefix owners when a new suffix requires approval - Notify users when their suffix has been approved This helps keep stakeholders informed about the status of their suffix requests, improving transparency and workflow efficiency.
This commit is contained in:
parent
26d46853c4
commit
2a9d093ec6
1 changed files with 16 additions and 0 deletions
|
@ -10,6 +10,7 @@ from django.views.generic import (
|
||||||
)
|
)
|
||||||
from django.shortcuts import get_object_or_404, redirect
|
from django.shortcuts import get_object_or_404, redirect
|
||||||
from django.http import HttpResponseBadRequest, Http404
|
from django.http import HttpResponseBadRequest, Http404
|
||||||
|
from django.core.mail import send_mail
|
||||||
from rest_framework import generics, permissions
|
from rest_framework import generics, permissions
|
||||||
from rest_framework.exceptions import PermissionDenied
|
from rest_framework.exceptions import PermissionDenied
|
||||||
from .serializers import SuffixSerializer, IdentifierSerializer
|
from .serializers import SuffixSerializer, IdentifierSerializer
|
||||||
|
@ -179,6 +180,13 @@ class SuffixCreateView(LoginRequiredMixin, CreateView):
|
||||||
or form.instance.prefix.owner == self.request.user
|
or form.instance.prefix.owner == self.request.user
|
||||||
):
|
):
|
||||||
form.instance.approved = True
|
form.instance.approved = True
|
||||||
|
else:
|
||||||
|
send_mail(
|
||||||
|
"New Suffix Pending Approval",
|
||||||
|
f"A new suffix has been created by {self.request.user.email} and is pending approval.",
|
||||||
|
None,
|
||||||
|
[form.instance.prefix.owner.email],
|
||||||
|
)
|
||||||
|
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
@ -216,6 +224,14 @@ class SuffixApprovalView(LoginRequiredMixin, UpdateView):
|
||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
form.instance.approved = True
|
form.instance.approved = True
|
||||||
|
|
||||||
|
send_mail(
|
||||||
|
"Suffix Approved",
|
||||||
|
f"Your suffix { form.instance.prefix.prefix }.{form.instance.suffix} has been approved.",
|
||||||
|
None,
|
||||||
|
[form.instance.owner.email],
|
||||||
|
)
|
||||||
|
|
||||||
return super().form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue