Permalink
Browse files

Add ability to delete grants

  • Loading branch information...
1 parent 49a1df1 commit 2e7b9c4346fd881fadffb565b38b784910da8a7f @paltman paltman committed Jul 17, 2012
@@ -0,0 +1,53 @@
+{% extends "privileges/base.html" %}
+
+{% load bootstrap_tags %}
+
+
+{% block body %}
+ <header class="jumbotron subhead" id="overview">
+ <h1>Grant Deletion</h1>
+ <p class="lead">Are you sure you really want to delete the grant?</p>
+ </header>
+
+ <table class="table">
+ <tr>
+ <th>Grantee</th><td>{{ grant.grantee }}</td>
+ </tr>
+ <tr>
+ <th>Grantor</th><td>{{ grant.grantor }}</td>
+ </tr>
+ <tr>
+ <th>Effective Period</th>
+ <td>
+ {% if grant.end %}
+ {{ grant.start }} through {{ grant.end }}
+ {% else %}
+ Starts {{ grant.start}}
+ {% endif %}
+ </td>
+ </tr>
+ <tr>
+ <th>Privilege</th><td>{{ grant.privilege }}</td>
+ </tr>
+ <tr>
+ <th>Delegation Count</th><td>{{ grant.redelegate_count }}</td>
+ </tr>
+ <tr>
+ <th>Created</th><td>{{ grant.date_created }}</td>
+ </tr>
+ </table>
+
+ <form class="form" action="
+ {% url privileges_grant_delete username=username pk=grant.pk %}" method="post">
+ {% csrf_token %}
+ {{ form|as_bootstrap }}
+ <div class="form-actions">
+ <a class="btn" href="{% url privileges_grant_list username=username %}">
+ Cancel
+ </a>
+ <button type="submit" class="btn btn-danger">
+ Delete
+ </button>
+ </div>
+ </form>
+{% endblock %}
@@ -25,6 +25,7 @@
</thead>
<tbody>
{% for grant in grant_list %}
+ {% url privileges_grant_delete username=username pk=grant.pk as delete_url %}
{% url privileges_grant_update username=username pk=grant.pk as edit_url %}
<tr>
<td>
View
@@ -17,5 +17,8 @@
views.GrantUpdateView.as_view(),
name="privileges_grant_update"
),
+ url(r"^(?P<username>\w+)/(?P<pk>\d+)/delete/$",
+ views.GrantDeleteView.as_view(),
+ name="privileges_grant_delete"
)
)
View
@@ -98,4 +98,14 @@ def get_success_url(self):
)
+@cbv_decorator(owner_required)
+class GrantDeleteView(UsernameContextMixin, DeleteView):
+ model = Grant
+ def get_success_url(self):
+ return reverse(
+ "privileges_grant_list",
+ kwargs={"username": self.request.user.username}
+ )
+
+

0 comments on commit 2e7b9c4

Please sign in to comment.