diff --git a/opentech/apply/activity/messaging.py b/opentech/apply/activity/messaging.py index 77a92b8a16b2f443a484d2983477f9ff8ef38e0a..43b5b0c66043658a14144639a3a342da8a2d9ef3 100644 --- a/opentech/apply/activity/messaging.py +++ b/opentech/apply/activity/messaging.py @@ -144,6 +144,12 @@ class AdapterBase: self.process_send(message_type, recipients, [event], request, user, source, related=related, **kwargs) def process_send(self, message_type, recipients, events, request, user, source, sources=list(), related=None, **kwargs): + try: + # If this was a batch action we want to pull out the submission + source = sources[0] + except IndexError: + pass + kwargs = { 'request': request, 'user': user, @@ -335,12 +341,6 @@ class ActivityAdapter(AdapterBase): from .models import Activity visibility = kwargs.get('visibility', ALL) - try: - # If this was a batch action we want to pull out the submission - source = sources[0] - except IndexError: - pass - related = kwargs['related'] if isinstance(related, dict): try: @@ -773,11 +773,11 @@ class EmailAdapter(AdapterBase): def send_message(self, message, source, subject, recipient, logs, **kwargs): try: - from_email = source.page.specific.from_address - except AttributeError: # we're dealing with a project - from_email = source.submission.page.specific.from_address + try: + from_email = source.page.specific.from_address + except AttributeError: # we're dealing with a project + from_email = source.submission.page.specific.from_address - try: send_mail( subject, message,