Skip to content

Commit

Permalink
introduce 2 rules for flagged todos
Browse files Browse the repository at this point in the history
  • Loading branch information
amdomanska committed Jan 21, 2025
1 parent fed5d1a commit 923ff13
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 3 deletions.
60 changes: 59 additions & 1 deletion portality/bll/services/todo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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():
"""
Expand Down
2 changes: 2 additions & 0 deletions portality/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
11 changes: 9 additions & 2 deletions portality/templates-v2/management/includes/_todo.html
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,17 @@
"feather": "inbox",
"link" : url_for('editor.associate_suggestions')
},
constants.TODO_FLAGGED: {
constants.TODO_REGULAR_FLAGS: {
"text" : "<strong>Flagged to you</strong> <span class='todo-list__status'>Deadline: {DEADLINE} </span>",
"no_deadline_text": "<strong>Flagged to you</strong> <span class='todo-list__status'>No deadline</span>",
"show_status": false,
"colour" : "var(--grapefruit)",
"feather": "flag",
"link" : ""
},
constants.TODO_URGENT_FLAGS: {
"text" : "<strong>Flagged to you (Urgent Deadline)</strong> <span class='todo-list__status'>Deadline: {DEADLINE} </span>",
"show_status": false,
"colour" : "var(--sanguine)",
"feather": "flag",
"link" : ""
Expand Down Expand Up @@ -179,7 +186,7 @@
<a href="{{ app_url }}" target="_blank" title="{{ todo.title }}">
{% 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 %}
Expand Down

0 comments on commit 923ff13

Please sign in to comment.