diff --git a/fhuser/migrations/0002_user_admin_mails.py b/fhuser/migrations/0002_user_admin_mails.py new file mode 100644 index 0000000000000000000000000000000000000000..f62eb58e15d857844fe0057a4793fd14c694adca --- /dev/null +++ b/fhuser/migrations/0002_user_admin_mails.py @@ -0,0 +1,18 @@ +# 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), + ), + ] diff --git a/fhuser/models.py b/fhuser/models.py index 1571e7ab8dad1aba35dc08d36f3df8edf558e20d..166492b2c15039f0098b713e8121b982b4fa8b2c 100755 --- a/fhuser/models.py +++ b/fhuser/models.py @@ -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) diff --git a/fhuser/views.py b/fhuser/views.py index 57473538a08b6569b2af32eeb31912f459221db2..2fc6c73961c7825a5710227de8dcc3860eceddb4 100755 --- a/fhuser/views.py +++ b/fhuser/views.py @@ -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: diff --git a/jitsimod/views.py b/jitsimod/views.py index efc095bd73d77e4f6ee966e5a40aa3cbd3fe966f..db2256021471d88913f02b7723fcdda8303cf9ba 100644 --- a/jitsimod/views.py +++ b/jitsimod/views.py @@ -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) diff --git a/videos/views.py b/videos/views.py index c904c85f1b45860109fffb8c93198a51cca3add5..1bd49fda5b5c3922c0f6534d0a518e8361655967 100755 --- a/videos/views.py +++ b/videos/views.py @@ -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: