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
bf4f92fe
Verified
Commit
bf4f92fe
authored
Jan 08, 2018
by
Thibaut Broggi
Browse files
Add an (ugly) form to change users' groups
parent
8da1de6a
Pipeline
#1793
passed with stages
in 2 minutes and 21 seconds
Changes
5
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
apps/userprofile/templates/user/user_list.html
View file @
bf4f92fe
...
...
@@ -43,7 +43,10 @@
<td>
{{user.email}}
</td>
<td>
{{user.date_joined | date:'d/m/Y - H:i:s'}}
</td>
<td>
{{user.groups.last.name}}
</td>
<td></td>
<td><a
href=
"{% url 'users:edit' user.id %}"
>
<i
class=
"fa fa-fw fa-pencil"
aria-hidden=
"true"
></i>
Edit
</a>
</td>
</tr>
{% endfor %}
</tbody>
...
...
apps/userprofile/templates/user/user_update_form.html
0 → 100644
View file @
bf4f92fe
{% extends "base.html" %}
{% block content %}
<form
action=
""
method=
"post"
>
{% csrf_token %}
{{ form.as_p }}
<input
type=
"submit"
value=
"Update"
/>
</form>
{% endblock %}
apps/userprofile/urls.py
View file @
bf4f92fe
from
django.conf.urls
import
url
from
userprofile.views.users
import
UserListView
from
userprofile.views.users
import
UserEditView
,
UserListView
urlpatterns
=
[
url
(
r
"^list"
,
UserListView
.
as_view
(),
name
=
"user-list"
name
=
"list"
),
url
(
r
"^edit/(?P<pk>\d+)"
,
UserEditView
.
as_view
(),
name
=
"edit"
)
]
apps/userprofile/views/users.py
View file @
bf4f92fe
from
django.urls
import
reverse_lazy
from
django.contrib.auth.models
import
User
from
django.contrib.auth.mixins
import
LoginRequiredMixin
,
PermissionRequiredMixin
from
django.views.generic.list
import
ListView
from
django.views.generic.edit
import
UpdateView
class
UserListView
(
LoginRequiredMixin
,
PermissionRequiredMixin
,
ListView
):
model
=
User
...
...
@@ -18,3 +21,11 @@ class UserListView(LoginRequiredMixin, PermissionRequiredMixin, ListView):
context
=
super
().
get_context_data
(
**
kwargs
)
return
context
class
UserEditView
(
LoginRequiredMixin
,
PermissionRequiredMixin
,
UpdateView
):
model
=
User
permission_required
=
'userprofile.can_edit_users'
template_name
=
'user/user_update_form.html'
fields
=
[
'groups'
]
success_url
=
reverse_lazy
(
"users:list"
)
project/urls.py
View file @
bf4f92fe
...
...
@@ -22,7 +22,7 @@ urlpatterns = [
url
(
r
"^feeds/"
,
include
(
"rp.feeds.urls"
,
namespace
=
"feeds"
)),
url
(
r
"^rp/"
,
include
(
"rp.urls"
,
namespace
=
"rp"
)),
url
(
r
'^accounts/'
,
include
(
'allauth.urls'
)),
url
(
r
"^users/"
,
include
(
'userprofile.urls'
))
url
(
r
"^users/"
,
include
(
'userprofile.urls'
,
namespace
=
"users"
))
]
if
settings
.
DEBUG
:
...
...
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