Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
La Quadrature du Net
rpteam
Revue de Press
Commits
777536fa
Verified
Commit
777536fa
authored
Oct 18, 2017
by
Thibaut Broggi
Browse files
Add a list of users on route /user
parent
9423f034
Pipeline
#1430
passed with stages
in 1 minute and 49 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
apps/rp/templates/rp/user_list.html
0 → 100644
View file @
777536fa
{% 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 %}
apps/rp/urls.py
View file @
777536fa
...
...
@@ -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"
)
]
apps/rp/views/users.py
0 → 100644
View file @
777536fa
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment