Verified Commit f678e5cf authored by Thibaut Broggi's avatar Thibaut Broggi
Browse files

Allow jedi to delete users

parent 63a62a47
Pipeline #1798 passed with stages
in 2 minutes and 18 seconds
...@@ -43,9 +43,14 @@ ...@@ -43,9 +43,14 @@
<td>{{user.email}}</td> <td>{{user.email}}</td>
<td>{{user.date_joined | date:'d/m/Y - H:i:s'}}</td> <td>{{user.date_joined | date:'d/m/Y - H:i:s'}}</td>
<td>{{user.groups.last.name}}</td> <td>{{user.groups.last.name}}</td>
<td><a href="{% url 'users:edit' user.id %}"> <td>
<i class="fa fa-fw fa-pencil" aria-hidden="true"></i> <a href="{% url 'users:edit' user.id %}">
Edit</a> <i class="fa fa-fw fa-pencil" aria-hidden="true"></i> Edit
</a>
<br />
<a href="{% url 'users:delete' user.id %}">
<i class="fa fa-fw fa-times" aria-hidden="true"></i> Delete
</a>
</td> </td>
</tr> </tr>
{% endfor %} {% endfor %}
......
from django.conf.urls import url from django.conf.urls import url
from userprofile.views.users import UserEditView, UserListView from userprofile.views.users import UserDeleteView, UserEditView, UserListView
urlpatterns = [ urlpatterns = [
url( url(
...@@ -13,5 +13,11 @@ urlpatterns = [ ...@@ -13,5 +13,11 @@ urlpatterns = [
r"^edit/(?P<pk>\d+)", r"^edit/(?P<pk>\d+)",
UserEditView.as_view(), UserEditView.as_view(),
name="edit" name="edit"
),
url(
r"^delete/(?P<pk>\d+)",
UserDeleteView.as_view(),
name="delete"
) )
] ]
...@@ -4,7 +4,7 @@ from django.contrib.auth.models import User ...@@ -4,7 +4,7 @@ from django.contrib.auth.models import User
from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin from django.contrib.auth.mixins import LoginRequiredMixin, PermissionRequiredMixin
from django.views.generic.list import ListView from django.views.generic.list import ListView
from django.views.generic.edit import UpdateView from django.views.generic.edit import DeleteView, UpdateView
class UserListView(LoginRequiredMixin, PermissionRequiredMixin, ListView): class UserListView(LoginRequiredMixin, PermissionRequiredMixin, ListView):
model = User model = User
...@@ -30,3 +30,11 @@ class UserEditView(LoginRequiredMixin, PermissionRequiredMixin, UpdateView): ...@@ -30,3 +30,11 @@ class UserEditView(LoginRequiredMixin, PermissionRequiredMixin, UpdateView):
fields = ['groups'] fields = ['groups']
success_url = reverse_lazy("users:list") success_url = reverse_lazy("users:list")
class UserDeleteView(LoginRequiredMixin, PermissionRequiredMixin, DeleteView):
model = User
permission_required = 'userprofile.can_edit_users'
template_name = 'user/user_delete_confirm.html'
context_object_name = 'user_delete'
success_url = reverse_lazy("users:list")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment