Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Commit

Permalink
#5, allow staff members to delete project sites
Browse files Browse the repository at this point in the history
  • Loading branch information
ezwang committed Jul 15, 2017
1 parent d413e53 commit 9e028a4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion web3/apps/sites/views/sites.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,9 +76,12 @@ def edit_view(request, site_id):
return render(request, "sites/create_site.html", context)


@superuser_required
def delete_view(request, site_id):
site = get_object_or_404(Site, id=site_id)

if not request.user.is_superuser and not (site.purpose == "project" and site.group.users.filter(id=request.user.id).exists()):
raise PermissionDenied

if request.method == "POST":
if not request.POST.get("confirm", None) == site.name:
messages.error(request, "Delete confirmation failed!")
Expand Down
2 changes: 1 addition & 1 deletion web3/templates/sites/info_site.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ <h3>{{ site.name }}</h3>

<a href="{% url 'index' %}" class="btn btn-ion"><i class="fa fa-undo"></i> Back</a>
<a href="{% url 'edit_site' site.id %}" class="btn btn-ion"><i class="fa fa-pencil"></i> Configure Site</a>
{% if request.user.is_superuser %}
{% if request.user.is_superuser or site.purpose == "project" %}
<a href="{% url 'delete_site' site.id %}" class="btn btn-ion btn-danger"><i class="fa fa-trash-o"></i> Delete Site</a>
{% endif %}
<br /><br />
Expand Down

0 comments on commit 9e028a4

Please sign in to comment.