Allow more people to be notified about tasks
This commit is contained in:
parent
477b980541
commit
068a37d451
28
project.py
28
project.py
|
@ -891,9 +891,16 @@ class Project(ModelSQL, ModelView):
|
|||
# posted in addition to the comment
|
||||
task_changes = {}
|
||||
for attr in updatable_attrs:
|
||||
if getattr(task, attr) != request.form[attr]:
|
||||
if getattr(task, attr) != request.form.get(attr, None):
|
||||
task_changes[attr] = request.form[attr]
|
||||
|
||||
new_assignee = request.form.get('assigned_to', None, int)
|
||||
if new_assignee and \
|
||||
(not task.assigned_to or new_assignee != task.assigned_to.id):
|
||||
history_data['previous_assigned_to'] = task.assigned_to and task.assigned_to.id or None
|
||||
history_data['new_assigned_to'] = new_assignee
|
||||
task_changes['assigned_to'] = new_assignee
|
||||
|
||||
if task_changes:
|
||||
# Only write change if anything has really changed
|
||||
self.write(task.id, task_changes)
|
||||
|
@ -907,14 +914,27 @@ class Project(ModelSQL, ModelView):
|
|||
else:
|
||||
# Just comment, no update to task
|
||||
comment_id = history_obj.create(history_data)
|
||||
history_obj.send_mail(comment_id)
|
||||
|
||||
if request.nereid_user.id not in (p.id for p in task.participants):
|
||||
current_participants = [p.id for p in task.participants]
|
||||
new_participants = []
|
||||
|
||||
if request.nereid_user.id not in current_participants:
|
||||
# Add the user to the participants if not already in the list
|
||||
new_participants.append(request.nereid_user.id)
|
||||
|
||||
for nereid_user in request.form.getlist('notify[]', int):
|
||||
# Notify more people if there are people who havent been added as participants
|
||||
if nereid_user not in current_participants:
|
||||
new_participants.append(nereid_user)
|
||||
|
||||
if new_participants:
|
||||
self.write(
|
||||
task.id, {'participants': [('add', [request.nereid_user.id])]}
|
||||
task.id, {'participants': [('add', new_participants)]}
|
||||
)
|
||||
|
||||
# Send the email since all thats required is done
|
||||
history_obj.send_mail(comment_id)
|
||||
|
||||
if request.is_xhr:
|
||||
comment_record = history_obj.browse(comment_id)
|
||||
html = render_template('project/comment.jinja', comment=comment_record)
|
||||
|
|
Loading…
Reference in New Issue