mirror of
https://github.com/ae-utbm/sith.git
synced 2024-11-22 06:03:20 +00:00
Add picture view to users
This commit is contained in:
parent
22ab21e4e1
commit
71d22e367b
21
core/templates/core/user_pictures.jinja
Normal file
21
core/templates/core/user_pictures.jinja
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
{% extends "core/base.jinja" %}
|
||||||
|
{% from "core/macros.jinja" import user_link_with_pict, delete_godfather %}
|
||||||
|
|
||||||
|
{% block title %}
|
||||||
|
{% trans user_name=profile.get_display_name() %}{{ user_name }}'s pictures{% endtrans %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block content %}
|
||||||
|
{% for r in user.pictures.exclude(picture=None).values('user__pictures__picture__parent').distinct() %}
|
||||||
|
{% set album = user.pictures.filter(picture__parent=r['user__pictures__picture__parent']).first().picture.parent %}
|
||||||
|
<h4>{{ album.name }}</h4>
|
||||||
|
{% for r in user.pictures.exclude(picture=None).filter(picture__parent=album) %}
|
||||||
|
<div style="display: inline-block; border: solid 1px black; width: 9%; margin: 0.1%">
|
||||||
|
<a href="{{ url("sas:picture", picture_id=r.picture.id) }}#pict">
|
||||||
|
<img src="{{ r.picture.as_picture.get_download_url() }}" alt="{{ r.picture.get_display_name() }}" style="max-width: 100%"/>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
{% endfor %}
|
||||||
|
{% endfor %}
|
||||||
|
{% endblock %}
|
||||||
|
|
@ -32,6 +32,7 @@ urlpatterns = [
|
|||||||
url(r'^user/$', UserListView.as_view(), name='user_list'),
|
url(r'^user/$', UserListView.as_view(), name='user_list'),
|
||||||
url(r'^user/(?P<user_id>[0-9]+)/mini$', UserMiniView.as_view(), name='user_profile_mini'),
|
url(r'^user/(?P<user_id>[0-9]+)/mini$', UserMiniView.as_view(), name='user_profile_mini'),
|
||||||
url(r'^user/(?P<user_id>[0-9]+)/$', UserView.as_view(), name='user_profile'),
|
url(r'^user/(?P<user_id>[0-9]+)/$', UserView.as_view(), name='user_profile'),
|
||||||
|
url(r'^user/(?P<user_id>[0-9]+)/pictures$', UserPicturesView.as_view(), name='user_pictures'),
|
||||||
url(r'^user/(?P<user_id>[0-9]+)/godfathers$', UserGodfathersView.as_view(), name='user_godfathers'),
|
url(r'^user/(?P<user_id>[0-9]+)/godfathers$', UserGodfathersView.as_view(), name='user_godfathers'),
|
||||||
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]+)/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]+)/edit$', UserUpdateProfileView.as_view(), name='user_edit'),
|
||||||
|
@ -134,6 +134,11 @@ class UserTabsMixin(TabedViewMixin):
|
|||||||
'slug': 'godfathers',
|
'slug': 'godfathers',
|
||||||
'name': _("Godfathers"),
|
'name': _("Godfathers"),
|
||||||
})
|
})
|
||||||
|
tab_list.append({
|
||||||
|
'url': reverse('core:user_pictures', kwargs={'user_id': self.object.id}),
|
||||||
|
'slug': 'pictures',
|
||||||
|
'name': _("Pictures"),
|
||||||
|
})
|
||||||
if self.request.user == self.object:
|
if self.request.user == self.object:
|
||||||
tab_list.append({
|
tab_list.append({
|
||||||
'url': reverse('core:user_tools'),
|
'url': reverse('core:user_tools'),
|
||||||
@ -201,6 +206,15 @@ def DeleteUserGodfathers(request, user_id, godfather_id, is_father):
|
|||||||
raise PermissionDenied
|
raise PermissionDenied
|
||||||
return redirect('core:user_godfathers', user_id=user_id)
|
return redirect('core:user_godfathers', user_id=user_id)
|
||||||
|
|
||||||
|
class UserPicturesView(UserTabsMixin, CanViewMixin, DetailView):
|
||||||
|
"""
|
||||||
|
Display a user's pictures
|
||||||
|
"""
|
||||||
|
model = User
|
||||||
|
pk_url_kwarg = "user_id"
|
||||||
|
context_object_name = "profile"
|
||||||
|
template_name = "core/user_pictures.jinja"
|
||||||
|
current_tab = 'pictures'
|
||||||
|
|
||||||
class UserGodfathersView(UserTabsMixin, CanViewMixin, DetailView):
|
class UserGodfathersView(UserTabsMixin, CanViewMixin, DetailView):
|
||||||
"""
|
"""
|
||||||
|
@ -4,7 +4,16 @@
|
|||||||
{% trans %}SAS{% endtrans %}
|
{% trans %}SAS{% endtrans %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
{% macro print_path(file) %}
|
||||||
|
{% if file %}
|
||||||
|
{{ print_path(file.parent) }}
|
||||||
|
<a href="{{ url('sas:album', album_id=file.id) }}">{{ file.get_display_name() }}</a> >
|
||||||
|
{% endif %}
|
||||||
|
{% endmacro %}
|
||||||
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
{{ print_path(album.parent) }} {{ album.get_display_name() }}
|
||||||
<h3>{{ album.get_display_name() }}</h3>
|
<h3>{{ album.get_display_name() }}</h3>
|
||||||
<div>
|
<div>
|
||||||
{% for a in album.children.filter(is_folder=True, is_moderated=True).all() %}
|
{% for a in album.children.filter(is_folder=True, is_moderated=True).all() %}
|
||||||
|
Loading…
Reference in New Issue
Block a user