3737from plugins .validator import PLUGIN_REQUIRED_METADATA
3838from django .contrib .gis .geoip2 import GeoIP2
3939from plugins .utils import parse_remote_addr
40+ from django .conf import settings
4041
4142from django .template .response import TemplateResponse
4243
5556staff_required = user_passes_test (lambda u : u .is_staff )
5657from plugins .tasks .generate_plugins_xml import generate_plugins_xml
5758
59+ # Plugin Notification Recipients Group Name
60+ NOTIFICATION_RECIPIENTS_GROUP_NAME = settings .NOTIFICATION_RECIPIENTS_GROUP_NAME
61+
5862
5963def send_mail_wrapper (subject , message , mail_from , recipients , fail_silently = True ):
6064 if settings .DEBUG :
@@ -65,13 +69,16 @@ def send_mail_wrapper(subject, message, mail_from, recipients, fail_silently=Tru
6569
6670def plugin_notify (plugin ):
6771 """
68- Sends a message to staff on new plugins
72+ Sends a message to staff that are in
73+ the notification recipients group on new plugins
6974 """
7075 recipients = [
7176 u .email
72- for u in User .objects .filter (is_staff = True , email__isnull = False ).exclude (
73- email = ""
74- )
77+ for u in User .objects .filter (
78+ groups__name = NOTIFICATION_RECIPIENTS_GROUP_NAME ,
79+ is_staff = True ,
80+ email__isnull = False
81+ ).exclude (email = "" )
7582 ]
7683
7784 if recipients :
@@ -98,15 +105,18 @@ def plugin_notify(plugin):
98105
99106def version_notify (plugin_version ):
100107 """
101- Sends a message to staff on new plugin versions
108+ Sends a message to staff that are in
109+ the notification recipients group on new plugin versions
102110 """
103111 plugin = plugin_version .plugin
104112
105113 recipients = [
106114 u .email
107- for u in User .objects .filter (is_staff = True , email__isnull = False ).exclude (
108- email = ""
109- )
115+ for u in User .objects .filter (
116+ groups__name = NOTIFICATION_RECIPIENTS_GROUP_NAME ,
117+ is_staff = True ,
118+ email__isnull = False
119+ ).exclude (email = "" )
110120 ]
111121
112122 if recipients :
0 commit comments