Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
AE UTBM
Sith
Commits
1b63d585
Commit
1b63d585
authored
Oct 05, 2016
by
guillaume-renaud
Browse files
Addition of the user's club tab
parent
0acc97fa
Changes
3
Hide whitespace changes
Inline
Side-by-side
core/templates/core/user_clubs.jinja
0 → 100644
View file @
1b63d585
{%
extends
"core/base.jinja"
%}
{%
block
title
%}
{%
trans
user_name
=
profile.get_display_name
()
%}{{
user_name
}}
's club(s)
{%
endtrans
%}
{%
endblock
%}
{%
block
content
%}
<h3>
{%
trans
%}
Club(s)
{%
endtrans
%}
</h3>
<h4>
{%
trans
%}
Current club(s)
{%
endtrans
%}
</h4>
<ul>
{%
for
m
in
profile.memberships.
filter
(
end_date
=
None
)
.
all
()
%}
<li><a
href=
"
{{
url
(
'club:club_members'
,
club_id
=
m.club.id
)
}}
"
>
{{
m.club
}}
</a></li>
{%
endfor
%}
</ul>
<h4>
{%
trans
%}
Old club(s)
{%
endtrans
%}
</h4>
<ul>
{%
for
m
in
profile.memberships.exclude
(
end_date
=
None
)
.
all
()
%}
<li><a
href=
"
{{
url
(
'club:club_members'
,
club_id
=
m.club.id
)
}}
"
>
{{
m.club
}}
</a></li>
{%
endfor
%}
</ul>
{%
endblock
%}
core/urls.py
View file @
1b63d585
...
...
@@ -36,6 +36,7 @@ urlpatterns = [
url
(
r
'^user/(?P<user_id>[0-9]+)/godfathers/(?P<godfather_id>[0-9]+)/(?P<is_father>(True)|(False))/delete$'
,
DeleteUserGodfathers
,
name
=
'user_godfathers_delete'
),
url
(
r
'^user/(?P<user_id>[0-9]+)/edit$'
,
UserUpdateProfileView
.
as_view
(),
name
=
'user_edit'
),
url
(
r
'^user/(?P<user_id>[0-9]+)/profile_upload$'
,
UserUploadProfilePictView
.
as_view
(),
name
=
'user_profile_upload'
),
url
(
r
'^user/(?P<user_id>[0-9]+)/clubs$'
,
UserClubView
.
as_view
(),
name
=
'user_clubs'
),
url
(
r
'^user/(?P<user_id>[0-9]+)/groups$'
,
UserUpdateGroupView
.
as_view
(),
name
=
'user_groups'
),
url
(
r
'^user/tools/$'
,
UserToolsView
.
as_view
(),
name
=
'user_tools'
),
url
(
r
'^user/(?P<user_id>[0-9]+)/account$'
,
UserAccountView
.
as_view
(),
name
=
'user_account'
),
...
...
core/views/user.py
View file @
1b63d585
...
...
@@ -20,6 +20,7 @@ import logging
from
core.views
import
CanViewMixin
,
CanEditMixin
,
CanEditPropMixin
,
TabedViewMixin
from
core.views.forms
import
RegisteringForm
,
UserPropForm
,
UserProfileForm
,
LoginForm
,
UserGodfathersForm
from
core.models
import
User
,
SithFile
from
club.models
import
Club
from
subscription.models
import
Subscription
def
login
(
request
):
...
...
@@ -150,6 +151,12 @@ class UserTabsMixin(TabedViewMixin):
'slug'
:
'edit'
,
'name'
:
_
(
"Edit"
),
})
if
self
.
request
.
user
.
can_view
(
self
.
object
):
tab_list
.
append
({
'url'
:
reverse
(
'core:user_clubs'
,
kwargs
=
{
'user_id'
:
self
.
object
.
id
}),
'slug'
:
'clubs'
,
'name'
:
_
(
"Clubs"
),
})
if
self
.
request
.
user
.
is_owner
(
self
.
object
):
tab_list
.
append
({
'url'
:
reverse
(
'core:user_groups'
,
kwargs
=
{
'user_id'
:
self
.
object
.
id
}),
...
...
@@ -336,6 +343,16 @@ class UserUpdateProfileView(UserTabsMixin, CanEditMixin, UpdateView):
kwargs
[
'form'
]
=
self
.
form
return
kwargs
class
UserClubView
(
UserTabsMixin
,
CanViewMixin
,
DetailView
):
"""
Display the user's club(s)
"""
model
=
User
context_object_name
=
"profile"
pk_url_kwarg
=
"user_id"
template_name
=
"core/user_clubs.jinja"
current_tab
=
"clubs"
class
UserUpdateGroupView
(
UserTabsMixin
,
CanEditPropMixin
,
UpdateView
):
"""
Edit a user's groups
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a 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