diff --git a/portality/bll/services/todo.py b/portality/bll/services/todo.py
index f719df5fc..e89a8af17 100644
--- a/portality/bll/services/todo.py
+++ b/portality/bll/services/todo.py
@@ -182,7 +182,10 @@ def top_todo(self, account, size=25, new_applications=True, update_requests=True
])
# if flagged filter is on than all types of records are displayed and the ownership is not taken into consideration
if flag:
- queries.append(TodoRules.flagged_to_me(account.id, size))
+ queries.extend([
+ TodoRules.urgent_flags(account.id, size),
+ TodoRules.regular_flags(account.id, size)
+ ])
todos = []
for aid, q, sort, boost in queries:
@@ -554,6 +557,33 @@ def flagged_to_me(cls, acc_id, size):
)
return constants.TODO_FLAGGED, all, sort_field, -1
+ @classmethod
+ def urgent_flags(cls, acc_id, size):
+ sort_field = "most_urgent_flag_deadline"
+ all = TodoQuery(
+ musts=[
+ TodoQuery.flagged_to_me(acc_id),
+ TodoQuery.urgent_flags()
+ ],
+ sort=sort_field,
+ size=size
+ )
+ return constants.TODO_URGENT_FLAGS, all, sort_field, -1
+
+ @classmethod
+ def regular_flags(cls, acc_id, size):
+ sort_field = "most_urgent_flag_deadline"
+ all = TodoQuery(
+ musts=[
+ TodoQuery.flagged_to_me(acc_id)
+ ],
+ must_nots=[
+ TodoQuery.urgent_flags()
+ ],
+ sort=sort_field,
+ size=size
+ )
+ return constants.TODO_REGULAR_FLAGS, all, sort_field, -1
class TodoQuery(object):
@@ -684,6 +714,34 @@ def flagged_to_me(cls, acc_id):
}
}
+ @classmethod
+ def urgent_flags(cls):
+ return {
+ "range": {
+ "index.most_urgent_flag_deadline": {
+ "gte": "now",
+ "lte": "now+7d/d"
+ }
+ }
+ }
+
+ @classmethod
+ def flags_with_nonurgent_deadline(cls):
+ return {
+ "range": {
+ "index.most_urgent_flag_deadline": {
+ "gt": "now+7d/d"
+ }
+ }
+ }
+
+ @classmethod
+ def flags_without_deadline(cls):
+ return {
+ "exists": {
+ "field": "index.most_urgent_flag_deadline"
+ }
+ }
class GroupStatsQuery():
"""
diff --git a/portality/constants.py b/portality/constants.py
index 12e55ced5..feebbb6eb 100644
--- a/portality/constants.py
+++ b/portality/constants.py
@@ -62,6 +62,8 @@
TODO_ASSOCIATE_START_PENDING = "todo_associate_start_pending"
TODO_ASSOCIATE_ALL_APPLICATIONS = "todo_associate_all_applications"
TODO_FLAGGED = "todo_flagged"
+TODO_URGENT_FLAGS = "todo_urgent_flags"
+TODO_REGULAR_FLAGS = "todo_regular_flags"
EVENT_ACCOUNT_CREATED = "account:created"
EVENT_ACCOUNT_PASSWORD_RESET = "account:password_reset"
diff --git a/portality/templates-v2/management/includes/_todo.html b/portality/templates-v2/management/includes/_todo.html
index 18200c1c3..03d504300 100644
--- a/portality/templates-v2/management/includes/_todo.html
+++ b/portality/templates-v2/management/includes/_todo.html
@@ -101,10 +101,17 @@
"feather": "inbox",
"link" : url_for('editor.associate_suggestions')
},
- constants.TODO_FLAGGED: {
+ constants.TODO_REGULAR_FLAGS: {
"text" : "Flagged to you Deadline: {DEADLINE} ",
"no_deadline_text": "Flagged to you No deadline",
"show_status": false,
+ "colour" : "var(--grapefruit)",
+ "feather": "flag",
+ "link" : ""
+ },
+ constants.TODO_URGENT_FLAGS: {
+ "text" : "Flagged to you (Urgent Deadline) Deadline: {DEADLINE} ",
+ "show_status": false,
"colour" : "var(--sanguine)",
"feather": "flag",
"link" : ""
@@ -179,7 +186,7 @@
{% set main_action = todo.action_id[0] %}
{% if action.show_status %}[{{ todo.object.application_status }}]{% endif %}
- {% if main_action != constants.TODO_FLAGGED %}
+ {% if main_action != constants.TODO_REGULAR_FLAGS and main_action != constants.TODO_URGENT_FLAGS %}
{{ action.text | safe }}
{% else %}
{% if deadline == "9999-12-31" %} {{ action.no_deadline_text | safe }} {% else %} {{ action.text | replace('{DEADLINE}', deadline) | safe }} {% endif %}