Skip to content
Snippets Groups Projects
Commit c0270e28 authored by Tanner Prestegard's avatar Tanner Prestegard Committed by Alexander Pace
Browse files

small change to internal membership check - using predefined function

parent 2167fcfe
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,8 @@ from subprocess import Popen, PIPE, STDOUT ...@@ -4,7 +4,8 @@ from subprocess import Popen, PIPE, STDOUT
from django.core.mail import EmailMessage from django.core.mail import EmailMessage
from django.conf import settings from django.conf import settings
from django.contrib.auth.models import Group
from permission_utils import is_external
import json import json
...@@ -88,16 +89,13 @@ def make_twilio_calls(event, twilio_recips, alert_type, **kwargs): ...@@ -88,16 +89,13 @@ def make_twilio_calls(event, twilio_recips, alert_type, **kwargs):
# Get "from" phone number. # Get "from" phone number.
from_ = get_twilio_from() from_ = get_twilio_from()
# Get LVC user group for checks made below.
lvc_group = Group.objects.get(name=settings.LVC_GROUP)
# Loop over recipients and make calls. # Loop over recipients and make calls.
for recip in twilio_recips: for recip in twilio_recips:
try: try:
# Only make calls to LVC members. Non-LVC members shouldn't # Only make calls to LVC members. Non-LVC members shouldn't
# even be able to sign up with a phone number, but this is another # even be able to sign up with a phone number, but this is another
# safety measure. # safety measure.
if lvc_group in recip.user.groups.all(): if not is_external(recip.user):
log.info('calling %s', recip.user.username) log.info('calling %s', recip.user.username)
twilio_client.calls.create(recip.phone, from_, twiml_url, method='GET') twilio_client.calls.create(recip.phone, from_, twiml_url, method='GET')
else: else:
......
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