Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Sith
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
59
Issues
59
List
Boards
Labels
Service Desk
Milestones
Merge Requests
9
Merge Requests
9
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
AE
Sith
Commits
7e335cfb
Commit
7e335cfb
authored
Nov 30, 2016
by
Skia
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update rotating function
parent
00feca44
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
7 deletions
+10
-7
sas/models.py
sas/models.py
+10
-7
No files found.
sas/models.py
View file @
7e335cfb
...
...
@@ -60,13 +60,13 @@ class Picture(SithFile):
def
rotate
(
self
,
degree
):
for
attr
in
[
'file'
,
'compressed'
,
'thumbnail'
]:
if
self
.
__getattribute__
(
attr
):
im
=
Image
.
open
(
BytesIO
(
self
.
__getattribute__
(
attr
).
read
()))
new_image
=
BytesIO
()
im
=
im
.
rotate
(
degree
,
expand
=
True
)
im
.
save
(
fp
=
new_image
,
format
=
self
.
mime_type
.
split
(
'/'
)[
-
1
].
upper
(),
quality
=
90
,
optimize
=
True
,
progressive
=
True
)
self
.
__getattribute__
(
attr
).
save
(
self
.
name
,
ContentFile
(
new_image
.
getvalue
())
)
self
.
save
(
)
name
=
self
.
__getattribute__
(
attr
).
name
with
open
((
settings
.
MEDIA_ROOT
+
name
).
encode
(
'utf-8'
),
'r+b'
)
as
file
:
if
file
:
im
=
Image
.
open
(
BytesIO
(
file
.
read
())
)
file
.
seek
(
0
)
im
=
im
.
rotate
(
degree
,
expand
=
True
)
im
.
save
(
fp
=
file
,
format
=
self
.
mime_type
.
split
(
'/'
)[
-
1
].
upper
(),
quality
=
90
,
optimize
=
True
,
progressive
=
True
)
def
get_next
(
self
):
return
self
.
parent
.
children
.
filter
(
is_moderated
=
True
,
asked_for_removal
=
False
,
is_folder
=
False
,
...
...
@@ -90,6 +90,9 @@ class Album(SithFile):
def
get_absolute_url
(
self
):
return
reverse
(
'sas:album'
,
kwargs
=
{
'album_id'
:
self
.
id
})
def
get_download_url
(
self
):
return
reverse
(
'sas:download'
,
kwargs
=
{
'picture_id'
:
self
.
id
})
class
PeoplePictureRelation
(
models
.
Model
):
"""
The PeoplePictureRelation class makes the connection between User and Picture
...
...
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