Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
AE
Sith
Commits
61d27655
Commit
61d27655
authored
Aug 02, 2017
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
core: refactor user picture page algorithm
Signed-off-by:
Skia
<
skia@libskia.so
>
parent
3eea8ed4
Pipeline
#1111
passed with stage
in 4 minutes and 19 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
6 deletions
+20
-6
core/templates/core/user_pictures.jinja
core/templates/core/user_pictures.jinja
+5
-6
core/views/user.py
core/views/user.py
+15
-0
No files found.
core/templates/core/user_pictures.jinja
View file @
61d27655
...
...
@@ -5,15 +5,14 @@
{%
endblock
%}
{%
block
content
%}
{%
set
picture_qs
=
profile.pictures.exclude
(
picture
=
None
)
.
order_by
(
'-picture__parent__id'
,
'id'
)
.
select_related
(
'picture__parent__parent__name'
)
%}
{%
for
a
in
picture_qs.distinct
(
'picture__parent'
)
%}
{%
for
a
in
albums
%}
<div
style=
"padding: 10px"
>
<h4>
{{
a.
picture.parent.
name
}}
</h4>
<h4>
{{
a.name
}}
</h4>
<hr>
{%
for
r
in
picture
_qs.
filter
(
picture__parent
=
a.picture.parent
)
-
%}
{%
for
picture
in
pictures
[
a.id
]
%}
<div
class=
"picture"
>
<a
href=
"
{{
url
(
"sas:picture"
,
picture_id
=
r.
picture.id
)
}}
#pict"
>
<img
src=
"
{{
r.
picture.get_download_thumb_url
()
}}
"
alt=
"
{{
r.
picture.get_display_name
()
}}
"
style=
"max-width: 100%"
/>
<a
href=
"
{{
url
(
"sas:picture"
,
picture_id
=
picture.id
)
}}
#pict"
>
<img
src=
"
{{
picture.get_download_thumb_url
()
}}
"
alt=
"
{{
picture.get_display_name
()
}}
"
style=
"max-width: 100%"
/>
</a>
</div>
{%
endfor
%}
...
...
core/views/user.py
View file @
61d27655
...
...
@@ -258,6 +258,21 @@ class UserPicturesView(UserTabsMixin, CanViewMixin, DetailView):
template_name
=
"core/user_pictures.jinja"
current_tab
=
'pictures'
def
get_context_data
(
self
,
**
kwargs
):
kwargs
=
super
(
UserPicturesView
,
self
).
get_context_data
(
**
kwargs
)
kwargs
[
'albums'
]
=
[]
kwargs
[
'pictures'
]
=
{}
picture_qs
=
self
.
object
.
pictures
.
exclude
(
picture
=
None
).
order_by
(
'-picture__parent__date'
,
'id'
).
select_related
(
'picture__parent__name'
)
last_album
=
None
for
pict_relation
in
picture_qs
:
album
=
pict_relation
.
picture
.
parent
if
album
.
id
!=
last_album
:
kwargs
[
'albums'
].
append
(
album
)
kwargs
[
'pictures'
][
album
.
id
]
=
[]
last_album
=
album
.
id
print
(
album
,
album
.
date
)
kwargs
[
'pictures'
][
album
.
id
].
append
(
pict_relation
.
picture
)
return
kwargs
class
UserGodfathersView
(
UserTabsMixin
,
CanViewMixin
,
DetailView
):
"""
...
...
Write
Preview
Markdown
is supported
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