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 !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 @@ ...@@ -18,8 +18,10 @@
<a href="{{ url_for("staff.view_project", project_id=project.id) }}" <a href="{{ url_for("staff.view_project", project_id=project.id) }}"
class="w3-button w3-hover-teal">View</a> class="w3-button w3-hover-teal">View</a>
{% endif %} {% endif %}
{% if allow_edit %}
<a href="{{ url_for("staff.delete_project", project_id=project.id) }}" <a href="{{ url_for("staff.delete_project", project_id=project.id) }}"
class="w3-button w3-hover-red">Delete</a> class="w3-button w3-hover-red">Delete</a>
{% endif %}
</div> </div>
</li> </li>
{% endfor %} {% endfor %}
......
...@@ -133,6 +133,8 @@ def delete_project(project_id): ...@@ -133,6 +133,8 @@ def delete_project(project_id):
can_delete = False can_delete = False
elif project.category not in category_codes: elif project.category not in category_codes:
can_delete = False can_delete = False
elif project.proposer != current_user.username:
can_delete = False
if can_delete: if can_delete:
project.deleted = datetime.utcnow() project.deleted = datetime.utcnow()
db.session.commit() 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