This repository has been archived by the owner on Nov 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
197 additions
and
13 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
56 changes: 56 additions & 0 deletions
56
backoffice/backoffice/workflows/migrations/0009_decision.py
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,56 @@ | ||
# Generated by Django 4.2.6 on 2024-08-13 08:38 | ||
|
||
import django.db.models.deletion | ||
from django.conf import settings | ||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
migrations.swappable_dependency(settings.AUTH_USER_MODEL), | ||
("workflows", "0008_alter_workflow_status_alter_workflow_workflow_type"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="Decision", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
( | ||
"action", | ||
models.CharField( | ||
choices=[ | ||
("accept", "author_create_approved_dag"), | ||
("reject", "author_create_rejected_dag"), | ||
("accept_curate", "author_create_approved_dag"), | ||
], | ||
max_length=30, | ||
), | ||
), | ||
("_created_at", models.DateTimeField(auto_now_add=True)), | ||
("_updated_at", models.DateTimeField(auto_now=True)), | ||
( | ||
"user_id", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to=settings.AUTH_USER_MODEL, | ||
), | ||
), | ||
( | ||
"workflow_id", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, | ||
to="workflows.workflow", | ||
), | ||
), | ||
], | ||
), | ||
] |
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
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
File renamed without changes.
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,16 @@ | ||
from airflow.decorators import task | ||
from hooks.backoffice.base import BackofficeHook | ||
|
||
|
||
@task() | ||
def create_decision_on_curation_choice(**context): | ||
print("create_decision_on_curation_choice") | ||
print(context["params"]) | ||
|
||
data = { | ||
"user_id": context["params"]["workflow_id"], | ||
"action": context["params"]["workflow_id"], | ||
"workflow_id": context["params"]["workflow_id"], | ||
} | ||
|
||
BackofficeHook().request(method="POST", data=data, endpoint="api/decisions/") |
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
38 changes: 38 additions & 0 deletions
38
workflows/plugins/hooks/backoffice/decision_management_hook.py
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,38 @@ | ||
from hooks.backoffice.base import BackofficeHook | ||
from requests import Response | ||
|
||
|
||
class WorkflowTicketManagementHook(BackofficeHook): | ||
""" | ||
A hook to update the status of a workflow in the backoffice system. | ||
:param method: The HTTP method to use for the request (default: "GET"). | ||
:type method: str | ||
:param http_conn_id: The ID of the HTTP connection to use ( | ||
default: "backoffice_conn"). | ||
:type http_conn_id: str | ||
""" | ||
|
||
def __init__( | ||
self, | ||
method: str = "GET", | ||
http_conn_id: str = "backoffice_conn", | ||
headers: dict = None, | ||
) -> None: | ||
super().__init__(method, http_conn_id, headers) | ||
self.endpoint = "api/decision/" | ||
|
||
def create_decision_entry( | ||
self, workflow_id: str, user_id: str, action: str | ||
) -> Response: | ||
data = { | ||
"user_id": user_id, | ||
"action": action, | ||
"workflow_id": workflow_id, | ||
} | ||
return self.run_with_advanced_retry( | ||
_retry_args=self.tenacity_retry_kwargs, | ||
method="POST", | ||
data=data, | ||
endpoint=self.endpoint, | ||
) |