Skip to content
Snippets Groups Projects
Verified Commit 3aaa17ee authored by Lukas Schauer's avatar Lukas Schauer :unlock:
Browse files

only send admin notifications to selected admins

parent caba56c1
No related branches found
No related tags found
No related merge requests found
# Generated by Django 3.0.5 on 2020-04-29 21:25
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('fhuser', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='user',
name='admin_mails',
field=models.BooleanField(default=False),
),
]
......@@ -16,3 +16,4 @@ def random_key_30():
class User(AbstractUser):
is_activated = models.BooleanField(default=True, null=False, blank=True)
activation_code = models.CharField(max_length=30, default=random_key_30, null=False, blank=True)
admin_mails = models.BooleanField(default=False)
......@@ -27,6 +27,8 @@ def activate_view(request, activation_code):
login(request, user, backend='django.contrib.auth.backends.ModelBackend')
for admin in get_user_model().objects.filter(is_superuser=True, is_active=True):
if not admin.admin_mails:
continue
msg = "Hello %s,\n\na new account has been activated:\n\nUser: %s\nE-Mail: %s" % (admin.first_name, user.username, user.email)
email = EmailMessage('lectures.fslab.de – Admin – Account activated', msg, to=[admin.email])
try:
......
......@@ -35,7 +35,7 @@ def newroom(request):
room.save()
for admin in get_user_model().objects.filter(is_superuser=True, is_active=True):
if admin.username != "lschau2s":
if not admin.admin_mails:
continue
subject = 'created (pattern-approved)' if autoapproved else 'requested'
msg = "Hello %s,\n\na new Jitsi room has been %s:\nhttps://lectures.fslab.de/admin/jitsimod/pattern/%d/change/\nName: %s\nUser: %s\nReason:\n%s" % (admin.first_name, subject, room.id, room.name, request.user.username, room.reason)
......
......@@ -65,6 +65,8 @@ def newcourse(request):
course.save()
for admin in get_user_model().objects.filter(is_superuser=True, is_active=True):
if not admin.admin_mails:
continue
msg = "Hello %s,\n\na new course has been created:\nhttps://lectures.fslab.de/course/%d\nOwner: %s\nTitle: %s\nDescription:\n%s" % (admin.first_name, course.id, request.user.username, course.title, course.description)
email = EmailMessage('lectures.fslab.de – Admin – Course creation', msg, to=[admin.email])
try:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment