-
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 'main' into fix/update-django-urls-to-re_path
- Loading branch information
Showing
103 changed files
with
4,264 additions
and
173 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[flake8] | ||
ignore=E501,F405,T003,E203,W503 |
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,81 @@ | ||
name: Build and Publish Rapidpro-apps With Poetry in PyPI | ||
on: | ||
push: | ||
tags: | ||
- '*.*.*' | ||
- '*.*.*a*' | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set variables | ||
shell: bash | ||
run: | | ||
TAG="$( echo "${GITHUB_REF}" | cut -d'/' -f3 )" | ||
VERSION="${TAG}" | ||
echo "VERSION=${VERSION}" | tee -a "${GITHUB_ENV}" | ||
- name: Install python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: '3.9' | ||
|
||
- name: Install Poetry | ||
run: | | ||
curl -sSL https://install.python-poetry.org | python3 - | ||
poetry self update 1.5.1 | ||
- name: Verify Poetry installation | ||
run: poetry --version | ||
|
||
- name: Update version in pyproject.toml | ||
shell: bash | ||
run: | | ||
sed -i 's;^version *=.*$;version = "'$VERSION'";g' pyproject.toml | ||
- name: Commit & Push changes in rapidpro-apps | ||
if: ${{ !contains(env.VERSION, 'a') }} | ||
uses: actions-js/push@master | ||
with: | ||
github_token: "${{ secrets.DEVOPS_GITHUB_PERMANENT_TOKEN }}" | ||
repository: weni-ai/rapidpro-apps | ||
directory: . | ||
branch: "refs/heads/update/${{ env.VERSION }}" | ||
message: "Update version of weni-rp-apps to ${{ env.VERSION }}" | ||
|
||
- name: Build package | ||
run: poetry build | ||
|
||
- name: Publish to pypi | ||
shell: bash | ||
run: | | ||
poetry config pypi-token.pypi ${{ secrets.PYPI_TOKEN }} | ||
poetry publish | ||
- name: Checkout Flows repository | ||
uses: actions/checkout@master | ||
with: | ||
ref: main | ||
repository: weni-ai/flows | ||
token: "${{ secrets.DEVOPS_GITHUB_PERMANENT_TOKEN }}" | ||
path: ./rapidpro/ | ||
|
||
- name: Update version on pip-requires.txt | ||
run: | | ||
VERSION="${{ env.VERSION }}" | ||
sed -i 's;^weni-rp-apps@==.*$;weni-rp-apps@=='$VERSION';g' ./rapidpro/docker/pip-requires.txt | ||
- name: Commit & Push changes in Flows | ||
uses: actions-js/push@master | ||
with: | ||
github_token: "${{ secrets.DEVOPS_GITHUB_PERMANENT_TOKEN }}" | ||
repository: weni-ai/flows | ||
directory: ./rapidpro/ | ||
branch: "refs/heads/update/weni-rp-apps-${{ env.VERSION }}" | ||
message: "Update version of weni-rp-apps to ${{ env.VERSION }}" | ||
|
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
Empty file.
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,9 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class ActivitiesConfig(AppConfig): | ||
default_auto_field = "django.db.models.BigAutoField" | ||
name = "weni.activities" | ||
|
||
def ready(self) -> None: | ||
from weni.activities import signals # noqa: F401 |
Empty file.
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,65 @@ | ||
import celery | ||
from django.db import models | ||
from django.db.models.signals import post_save | ||
from django.dispatch import receiver | ||
|
||
from temba.channels.models import Channel | ||
from temba.flows.models import Flow | ||
from temba.triggers.models import Trigger | ||
from temba.campaigns.models import Campaign | ||
|
||
|
||
def create_recent_activity(instance: models.Model, created: bool): | ||
if instance.is_active: | ||
action = "CREATE" if created else "UPDATE" | ||
|
||
celery.execute.send_task( | ||
"create_recent_activity", | ||
kwargs=dict( | ||
action=action, | ||
entity=instance.__class__.__name__.upper(), | ||
entity_name=getattr(instance, "name", None), | ||
user=instance.modified_by.email, | ||
flow_organization=str(instance.org.uuid), | ||
), | ||
) | ||
|
||
|
||
@receiver(post_save, sender=Channel) | ||
def channel_recent_activity_signal(sender, instance: Channel, created: bool, **kwargs): | ||
update_fields = kwargs.get("update_fields") | ||
if instance.channel_type not in ["WA", "WAC"] or update_fields != frozenset( | ||
{ | ||
"config", | ||
} | ||
): | ||
create_recent_activity(instance, created) | ||
|
||
|
||
@receiver(post_save, sender=Flow) | ||
def flow_recent_activity_signal(sender, instance: Flow, created: bool, **kwargs): | ||
update_fields = kwargs.get("update_fields") | ||
if update_fields != frozenset( | ||
{ | ||
"version_number", | ||
"modified_on", | ||
"saved_on", | ||
"modified_by", | ||
"metadata", | ||
"saved_by", | ||
"base_language", | ||
"has_issues", | ||
} | ||
): | ||
# This condition prevents two events from being sent when creating a flow | ||
create_recent_activity(instance, created) | ||
|
||
|
||
@receiver(post_save, sender=Trigger) | ||
def trigger_recent_activity_signal(sender, instance: Trigger, created: bool, **kwargs): | ||
create_recent_activity(instance, created) | ||
|
||
|
||
@receiver(post_save, sender=Campaign) | ||
def campaign_recent_activity_signal(sender, instance: Campaign, created: bool, **kwargs): | ||
create_recent_activity(instance, created) |
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,9 @@ | ||
from celery import shared_task | ||
|
||
from weni.internal.clients import ConnectInternalClient | ||
|
||
|
||
@shared_task(name="create_recent_activity") | ||
def create_recent_activity(action: str, entity: str, entity_name: str, user: str, flow_organization: str): | ||
client = ConnectInternalClient() | ||
client.create_recent_activity(action, entity, entity_name, user, flow_organization) |
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
Oops, something went wrong.