Commit 777536fa authored by Thibaut Broggi's avatar Thibaut Broggi

Add a list of users on route /user

parent 9423f034
Pipeline #1430 passed with stages
in 1 minute and 49 seconds
{% extends "base.html" %}
{% block content-header %}
{% endblock %}
{% block content %}
<div class="row">
<div class="col-md-12 white-bg">
{% if is_paginated %}
<div class="pagination">
<span class="page-links">
{% if page_obj.has_previous %}
<a href="?page={{ page_obj.previous_page_number }}"><i class="fa fa-chevron-left" aria-hidden="true"></i></a>
{% endif %}
<span class="page-current">
Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}
</span>
{% if page_obj.has_next %}
<a href="?page={{ page_obj.next_page_number }}"><i class="fa fa-chevron-right" aria-hidden="true"></i></a>
{% endif %}
</span>
</div>
{% endif %}
<table class="article-table table table-sm my-4">
<thead>
<tr>
<th>ID</th>
<th>Username</th>
<th>Email</th>
<th>Registration date</th>
<th>Role</th>
<th>Actions<img class="inline-image ml-2" role="img" src="{% static 'img/jedi.svg' %}" /></th>
</tr>
</thead>
<tbody>
{% for article in object_list|slice:":10" %}
<tr id="row_{{article.id}}">
<td>{{article.id}}</td>
<td>{{article.username}}</td>
<td>{{article.email}}</td>
<td>{{article.date_joined |date:'d/m/Y - H:i:s'}}</td>
<td>{{article.groups.all.0.name}}</td>
<td></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
</div>
</div>
{% endblock %}
......@@ -2,6 +2,7 @@ from django.contrib.auth.decorators import login_required
from django.conf.urls import url
from rp.views.articles import ArticleListFlux, ArticleEdit, ArticleDetailView, ArticleList
from rp.views.users import UserListView
urlpatterns = [
url(
......@@ -43,5 +44,10 @@ urlpatterns = [
r"^article/preview/(?P<pk>\d+)",
login_required(ArticleDetailView.as_view(preview=True)),
name="article-preview"
),
url(
r"^user",
login_required(UserListView.as_view()),
name="user-list"
)
]
from django.contrib.auth.models import User
from django.views.generic.list import ListView
class UserListView(ListView):
paginate_by = 10
template_name = "rp/user_list.html"
def get_queryset(self):
return User.objects.all()
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
return context
Markdown is supported
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