-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'feature/update-project-model' of https://github.com/wen…
…i-ai/rapidpro-apps into develop
- Loading branch information
Showing
5 changed files
with
47 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
from django.db import models | ||
from temba.event_driven.publisher.rabbitmq_publisher import RabbitmqPublisher | ||
|
||
|
||
def create_recent_activity(instance: models.Model, created: bool, delete=None): | ||
if instance.is_active: | ||
rabbitmq_publisher = RabbitmqPublisher() | ||
if delete: | ||
action = "DELETE" | ||
rabbitmq_publisher.send_message( | ||
body=dict( | ||
action=action, | ||
entity=instance.__class__.__name__.upper(), | ||
entity_name=getattr(instance, "name", None), | ||
entity_uuid=str(instance.uuid), | ||
project_uuid=str(instance.org.project.project_uuid), | ||
user=instance.modified_by.email, | ||
flow_organization=str(instance.org.uuid), | ||
), | ||
exchange="recent-activities.topic", | ||
routing_key="flow-delete", | ||
) | ||
else: | ||
action = "CREATE" if created else "UPDATE" | ||
rabbitmq_publisher.send_message( | ||
body=dict( | ||
action=action, | ||
entity=instance.__class__.__name__.upper(), | ||
entity_name=getattr(instance, "name", None), | ||
project_uuid=str(instance.org.project.project_uuid), | ||
user=instance.modified_by.email, | ||
flow_organization=str(instance.org.uuid), | ||
), | ||
exchange="recent-activities.topic", | ||
routing_key="", | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters