Commit 71d22e36 authored by Skia's avatar Skia
Browse files

Add picture view to users

parent 22ab21e4
{% 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/(?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]+)/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/(?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'),
......
......@@ -134,6 +134,11 @@ class UserTabsMixin(TabedViewMixin):
'slug': '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:
tab_list.append({
'url': reverse('core:user_tools'),
......@@ -201,6 +206,15 @@ def DeleteUserGodfathers(request, user_id, godfather_id, is_father):
raise PermissionDenied
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):
"""
......
......@@ -4,7 +4,16 @@
{% trans %}SAS{% endtrans %}
{% 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 %}
{{ print_path(album.parent) }} {{ album.get_display_name() }}
<h3>{{ album.get_display_name() }}</h3>
<div>
{% for a in album.children.filter(is_folder=True, is_moderated=True).all() %}
......
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