Skip to content

Commit 2f15eec

Browse files
Merge branch 'main' into develop
2 parents 4e5473e + e91f3a1 commit 2f15eec

2 files changed

Lines changed: 30 additions & 12 deletions

File tree

recoco/apps/conversations/migrations/0007_auto_20251230_1707.py

Lines changed: 29 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Generated by Django 5.1.15 on 2025-12-30 16:07
22

33
from django.db import migrations
4-
from notifications.signals import notify
4+
from django.utils import timezone
55
from tqdm import tqdm
66

77
from recoco import verbs
@@ -13,6 +13,8 @@ def convert_public_note_notifications(apps, schema_editor):
1313
Notification = apps.get_model("notifications", "Notification")
1414
ContentType = apps.get_model("contenttypes", "ContentType")
1515
Note = apps.get_model("projects", "Note")
16+
User = apps.get_model("auth", "User")
17+
Project = apps.get_model("projects", "Project")
1618
public_note_verb = "a envoyé un message dans l'espace conversation"
1719
content_type = ContentType.objects.get_for_model(Note)
1820
for notif in tqdm(
@@ -37,20 +39,36 @@ def convert_public_note_notifications(apps, schema_editor):
3739
try:
3840
# get corresponding message to create its own notification
3941
message = Message.objects.get(
40-
created=note.created_on, modified=note.updated_on, project=note.project
42+
created=note.created_on,
43+
modified=note.updated_on,
44+
project_id=note.project.pk,
4145
)
42-
notification = {
43-
"sender": notif.actor,
44-
"verb": verbs.Conversation.POST_MESSAGE,
45-
"action_object": message,
46-
"target": notif.target,
47-
"annotations": gather_annotations_for_message_notification(message),
48-
"emailed": notif.emailed,
49-
}
5046

51-
notify.send(recipient=notif.recipient, site=notif.site, **notification)
47+
Notification(
48+
recipient=notif.recipient,
49+
actor_content_type=ContentType.objects.get_for_model(User),
50+
actor_object_id=notif.actor_object_id,
51+
target_object_id=notif.target_object_id,
52+
target_content_type=ContentType.objects.get_for_model(Project),
53+
action_object_object_id=message.id,
54+
action_object_content_type=ContentType.objects.get_for_model(Message),
55+
verb=verbs.Conversation.POST_MESSAGE,
56+
public=True,
57+
description=None,
58+
data={
59+
"annotations": gather_annotations_for_message_notification(message)
60+
},
61+
emailed=notif.emailed,
62+
timestamp=timezone.now(),
63+
level="info",
64+
site_id=notif.site_id,
65+
)
66+
67+
# notify.send(recipient=notif.recipient, site_id=notif.site.id, **notification)
5268
except Message.DoesNotExist:
5369
print(f"no message found for {note}. skipped")
70+
except User.DoesNotExist:
71+
print(f"sender not found for {note}. skipped")
5472

5573

5674
class Migration(migrations.Migration):

recoco/apps/tasks/tests/test_tasks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def test_task_recommendation_list_available_for_staff(client):
5959
@pytest.mark.django_db
6060
def test_task_recommendation_list(client, current_site):
6161
tr = baker.make(models.TaskRecommendation, site=current_site)
62-
tr.condition_tags_taggit.add("test")
62+
tr.condition_tags.add("test")
6363

6464
url = reverse("projects-task-recommendation-list")
6565
with login(client, groups=["example_com_staff"]):

0 commit comments

Comments
 (0)