Skip to content

Commit

Permalink
RDISCROWD-5091 Audit log for coowner updates (#760)
Browse files Browse the repository at this point in the history
* Added audit log when adding coowner to a project.

* Fix for additional routes.

* Cleanup.
  • Loading branch information
kbecker42 committed Aug 15, 2022
1 parent 908d03a commit ed37c4e
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pybossa/view/projects.py
Original file line number Diff line number Diff line change
Expand Up @@ -3215,8 +3215,11 @@ def add_coowner(short_name, user_name=None):
if user.id in project.owners_ids:
flash(gettext('User is already an owner'), 'warning')
else:
old_list = project.owners_ids.copy()
project.owners_ids.append(user.id)
project_repo.update(project)
auditlogger.log_event(project, current_user, 'update',
'project.coowners', old_list, project.owners_ids)
flash(gettext('User was added to list of owners'), 'success')
return redirect_content_type(url_for(".coowners", short_name=short_name))
return abort(404)
Expand All @@ -3238,8 +3241,11 @@ def del_coowner(short_name, user_name=None):
elif user.id not in project.owners_ids:
flash(gettext('User is not a project owner'), 'error')
else:
old_list = project.owners_ids.copy()
project.owners_ids.remove(user.id)
project_repo.update(project)
auditlogger.log_event(project, current_user, 'update',
'project.coowners', old_list, project.owners_ids)
flash(gettext('User was deleted from the list of owners'),
'success')
return redirect_content_type(url_for('.coowners', short_name=short_name))
Expand Down

0 comments on commit ed37c4e

Please sign in to comment.