Commit 86f8ca67 authored by Lars Rustand's avatar Lars Rustand
Browse files

Send notification once packages has enough signoffs

parent b1eee27f
......@@ -4,10 +4,12 @@
from django import forms
from django.contrib.auth.decorators import permission_required
from django.contrib.auth.models import User
from django.core.mail import EmailMessage
from django.core.serializers.json import DjangoJSONEncoder
from django.db import transaction
from django.http import HttpResponse, Http404
from django.shortcuts import get_list_or_404, redirect, render
from django.template import loader
from django.utils.timezone import now
from django.views.decorators.cache import never_cache
......@@ -53,6 +55,30 @@ def signoff_package(request, name, repo, arch, revoke=False):
return render(request, '403.html', status=403)
signoff, created = Signoff.objects.get_or_create_from_package(
package, request.user)
signoffs = Signoff.objects.for_package(package).filter(
if signoffs.count() >= spec.required:
packager = package.packager
# TODO: Handle notification when packager does not exist
if packager:
toemail = []
subject = f'{} package ' + \
f'[{package.pkgname} {package.full_version}] approved'
# send notification email to the maintainers
tmpl = loader.get_template('packages/approved.txt')
ctx = {
'signoffs': signoffs,
'pkg': package,
msg = EmailMessage(subject,
'Arch Website Notification <>',
all_signoffs = Signoff.objects.for_package(package)
{% autoescape off %} The {{ }} package {{ pkg.pkgname }} {{ pkg.full_version }} has received the required number of signoffs.
The package was signed off by the following users:{% for s in signoffs %}
- {{ s.user.username }}{% endfor %}{% endautoescape %}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment