Skip to content
Snippets Groups Projects
Commit a86a1116 authored by Andrea Callia D'Iddio's avatar Andrea Callia D'Iddio
Browse files

Merge branch 'prevent-unauthorized-deletion' into 'master'

Fix: prevent staff members from deleting projects published by other staff members.

See merge request edtech/project-allocator!17
parents 8d6b3170 d1212212
No related branches found
No related tags found
1 merge request!17Fix: prevent staff members from deleting projects published by other staff members.
Pipeline #375131 canceled
......@@ -18,8 +18,10 @@
<a href="{{ url_for("staff.view_project", project_id=project.id) }}"
class="w3-button w3-hover-teal">View</a>
{% endif %}
{% if allow_edit %}
<a href="{{ url_for("staff.delete_project", project_id=project.id) }}"
class="w3-button w3-hover-red">Delete</a>
{% endif %}
</div>
</li>
{% endfor %}
......
......@@ -133,6 +133,8 @@ def delete_project(project_id):
can_delete = False
elif project.category not in category_codes:
can_delete = False
elif project.proposer != current_user.username:
can_delete = False
if can_delete:
project.deleted = datetime.utcnow()
db.session.commit()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment