diff --git a/onadata/apps/messaging/backends/base.py b/onadata/apps/messaging/backends/base.py index 32989ce3e0..932b5ddab7 100644 --- a/onadata/apps/messaging/backends/base.py +++ b/onadata/apps/messaging/backends/base.py @@ -4,9 +4,8 @@ """ from __future__ import unicode_literals -from django.utils.module_loading import import_string - from actstream.models import Action +from django.utils.module_loading import import_string from multidb.pinning import use_master diff --git a/onadata/apps/messaging/backends/mqtt.py b/onadata/apps/messaging/backends/mqtt.py index 8161663161..d645e5671e 100644 --- a/onadata/apps/messaging/backends/mqtt.py +++ b/onadata/apps/messaging/backends/mqtt.py @@ -118,7 +118,8 @@ def get_topic(self, instance): } if kwargs['target_name'] == XFORM: xform = XForm.objects.get(id=instance.target_object_id) - kwargs['organization_username'] = xform.project.organization.id + kwargs[ + 'organization_username'] = xform.project.organization.username kwargs['verb'] = VERB_TOPIC_DICT[instance.verb] kwargs['project_id'] = xform.project.id return ('/{topic_base}/organization/{organization_username}/' diff --git a/onadata/apps/messaging/signals.py b/onadata/apps/messaging/signals.py index 3c20f72978..219bb67355 100644 --- a/onadata/apps/messaging/signals.py +++ b/onadata/apps/messaging/signals.py @@ -23,6 +23,7 @@ def messaging_backends_handler(sender, **kwargs): # pylint: disable=W0613 created = kwargs.get('created') instance = kwargs.get('instance') if instance and created: + instance = instance.save() for name in backends: backend = backends[name]['BACKEND'] backend_options = backends[name].get('OPTIONS') diff --git a/onadata/libs/utils/logger_tools.py b/onadata/libs/utils/logger_tools.py index 27ba73dae1..76b10c3158 100644 --- a/onadata/libs/utils/logger_tools.py +++ b/onadata/libs/utils/logger_tools.py @@ -107,7 +107,7 @@ def _get_instance(xml, new_uuid, submitted_by, status, xform, checksum): # send notification on submission creation send_message( instance_id=instance.id, target_id=instance.xform.id, - target_type=XFORM, user=instance.user, + target_type=XFORM, user=instance.user or instance.xform.user, message_verb=message_verb) return instance