6
6
7
7
from hypha .apply .activity .models import ALL , APPLICANT , TEAM
8
8
from hypha .apply .activity .options import MESSAGES
9
+ from hypha .apply .funds .workflow import PHASE_BG_COLORS
9
10
from hypha .apply .projects .utils import (
10
11
get_invoice_public_status ,
11
12
get_invoice_status_display_value ,
@@ -26,12 +27,12 @@ class ActivityAdapter(AdapterBase):
26
27
MESSAGES .NEW_SUBMISSION : _ (
27
28
"Submitted {source.title_text_display} for {source.page.title}"
28
29
),
29
- MESSAGES .EDIT_SUBMISSION : _ ("Edited " ),
30
- MESSAGES .APPLICANT_EDIT : _ ("Edited " ),
31
- MESSAGES .UPDATE_LEAD : _ ("Lead changed from {old_lead} to {source.lead}" ),
32
- MESSAGES .BATCH_UPDATE_LEAD : _ ("Batch Lead changed to {new_lead}" ),
30
+ MESSAGES .EDIT_SUBMISSION : _ ("edited the submission " ),
31
+ MESSAGES .APPLICANT_EDIT : _ ("edited the submission " ),
32
+ MESSAGES .UPDATE_LEAD : _ ("updated Lead from {old_lead} to {source.lead}" ),
33
+ MESSAGES .BATCH_UPDATE_LEAD : _ ("batch updated Lead to {new_lead}" ),
33
34
MESSAGES .DETERMINATION_OUTCOME : _ (
34
- "Sent a determination. Outcome: {determination.clean_outcome}"
35
+ "sent a determination. Outcome: {determination.clean_outcome}"
35
36
),
36
37
MESSAGES .BATCH_DETERMINATION_OUTCOME : "batch_determination" ,
37
38
MESSAGES .INVITED_TO_PROPOSAL : _ ("Invited to submit a proposal" ),
@@ -42,24 +43,22 @@ class ActivityAdapter(AdapterBase):
42
43
MESSAGES .OPENED_SEALED : _ ("Opened the submission while still sealed" ),
43
44
MESSAGES .SCREENING : "handle_screening_statuses" ,
44
45
MESSAGES .REVIEW_OPINION : _ (
45
- "{user} { opinion.opinion_display}s with {opinion.review.author}s review of {source}"
46
+ "{opinion.opinion_display}s with {opinion.review.author}s review of {source}"
46
47
),
47
48
MESSAGES .DELETE_REVIEW_OPINION : _ (
48
- "{user} deleted the opinion for review: {review_opinion.review}"
49
+ "deleted the opinion for review: {review_opinion.review}"
49
50
),
50
51
MESSAGES .CREATED_PROJECT : _ ("Created project" ),
51
52
MESSAGES .PROJECT_TRANSITION : "handle_project_transition" ,
52
53
MESSAGES .UPDATE_PROJECT_TITLE : _ (
53
- "{user} has updated the project title from {old_title} to {source.title}"
54
- ),
55
- MESSAGES .UPDATE_PROJECT_LEAD : _ (
56
- "Lead changed from {old_lead} to {source.lead}"
54
+ "updated the project title from {old_title} to {source.title}"
57
55
),
56
+ MESSAGES .UPDATE_PROJECT_LEAD : _ ("update Lead from {old_lead} to {source.lead}" ),
58
57
MESSAGES .SEND_FOR_APPROVAL : _ ("Requested approval" ),
59
58
MESSAGES .APPROVE_PAF : "handle_paf_assignment" ,
60
59
MESSAGES .APPROVE_PROJECT : _ ("Approved" ),
61
60
MESSAGES .REQUEST_PROJECT_CHANGE : _ (
62
- 'Requested changes for acceptance: "{comment}"'
61
+ 'requested changes for acceptance: "{comment}"'
63
62
),
64
63
MESSAGES .SUBMIT_CONTRACT_DOCUMENTS : _ ("Submitted Contract Documents" ),
65
64
MESSAGES .UPLOAD_CONTRACT : _ ("Uploaded a {contract.state} contract" ),
@@ -69,17 +68,13 @@ class ActivityAdapter(AdapterBase):
69
68
MESSAGES .SUBMIT_REPORT : _ ("Submitted a report" ),
70
69
MESSAGES .SKIPPED_REPORT : "handle_skipped_report" ,
71
70
MESSAGES .REPORT_FREQUENCY_CHANGED : "handle_report_frequency" ,
72
- MESSAGES .DISABLED_REPORTING : _ ("Reporting disabled" ),
71
+ MESSAGES .DISABLED_REPORTING : _ ("disabled reporting " ),
73
72
MESSAGES .BATCH_DELETE_SUBMISSION : "handle_batch_delete_submission" ,
74
73
MESSAGES .BATCH_ARCHIVE_SUBMISSION : "handle_batch_archive_submission" ,
75
74
MESSAGES .BATCH_UPDATE_INVOICE_STATUS : "handle_batch_update_invoice_status" ,
76
- MESSAGES .ARCHIVE_SUBMISSION : _ (
77
- "{user} has archived the submission: {source.title_text_display}"
78
- ),
79
- MESSAGES .UNARCHIVE_SUBMISSION : _ (
80
- "{user} has unarchived the submission: {source.title_text_display}"
81
- ),
82
- MESSAGES .DELETE_INVOICE : _ ("Deleted an invoice" ),
75
+ MESSAGES .ARCHIVE_SUBMISSION : _ ("archived this submission" ),
76
+ MESSAGES .UNARCHIVE_SUBMISSION : _ ("un-archived this submission" ),
77
+ MESSAGES .DELETE_INVOICE : _ ("deleted an invoice" ),
83
78
MESSAGES .REMOVE_TASK : "handle_task_removal" ,
84
79
}
85
80
@@ -214,28 +209,31 @@ def handle_paf_assignment(self, source, paf_approvals, **kwargs):
214
209
def handle_task_removal (self , source , task , ** kwargs ):
215
210
if task .user :
216
211
return _ (
217
- "{user} has removed the task {task.code} for {source} from the task list" .format (
218
- user = kwargs . get ( "user" ), task = task , source = source
212
+ "removed the task {task.code} for {source} from the task list" .format (
213
+ task = task , source = source
219
214
)
220
215
)
221
216
return _ (
222
- "{user} has removed the task {task.code} for {source} from whole team's{user_groups} task list." .format (
223
- user = kwargs .get ("user" ),
217
+ "removed the task {task.code} for {source} from whole team's{user_groups} task list." .format (
224
218
task = task ,
225
219
source = source ,
226
220
user_groups = list (task .user_group .all ().values_list ("name" , flat = True )),
227
221
)
228
222
)
229
223
230
224
def handle_transition (self , old_phase , source , ** kwargs ):
225
+ def wrap_in_color_class (text ):
226
+ color_class = PHASE_BG_COLORS .get (text , "" )
227
+ return f'<span class="rounded-full inline-block px-2 py-0.5 font-medium text-gray-800 { color_class } ">{ text } </span>'
228
+
231
229
submission = source
232
230
base_message = _ ("Progressed from {old_display} to {new_display}" )
233
231
234
232
new_phase = submission .phase
235
233
236
234
staff_message = base_message .format (
237
- old_display = old_phase .display_name ,
238
- new_display = new_phase .display_name ,
235
+ old_display = wrap_in_color_class ( old_phase .display_name ) ,
236
+ new_display = wrap_in_color_class ( new_phase .display_name ) ,
239
237
)
240
238
241
239
if new_phase .permissions .can_view (submission .user ):
@@ -246,8 +244,8 @@ def handle_transition(self, old_phase, source, **kwargs):
246
244
)
247
245
248
246
applicant_message = base_message .format (
249
- old_display = old_phase .public_name ,
250
- new_display = new_phase .public_name ,
247
+ old_display = wrap_in_color_class ( old_phase .public_name ) ,
248
+ new_display = wrap_in_color_class ( new_phase .public_name ) ,
251
249
)
252
250
253
251
return json .dumps (
@@ -363,10 +361,10 @@ def handle_screening_statuses(self, source, old_status, **kwargs):
363
361
364
362
if new_status and old_status != "-" :
365
363
return _ (
366
- 'Updated screening decision from "{old_status}" to "{new_status}". '
364
+ 'Updated screening decision from "{old_status}" to "{new_status}"'
367
365
).format (old_status = old_status , new_status = new_status )
368
366
elif new_status :
369
- return _ ('Added screening decision to "{new_status}". ' ).format (
367
+ return _ ('Added screening decision to "{new_status}"' ).format (
370
368
new_status = new_status
371
369
)
372
370
elif old_status != "-" :
0 commit comments