SAS fixes

This commit is contained in:
Skia 2016-11-29 11:35:31 +01:00
parent 7969e9ba5f
commit 7f0561234f
3 changed files with 8 additions and 6 deletions

View File

@ -1086,10 +1086,10 @@ def migrate_sas():
file_name += "/" + str(r['id_photo']) + ".jpg"
file = File(open(file_name, "rb"))
file.name = (str(r['id_photo']) + ".jpg").encode('utf-8')
file.name = str(r['id_photo']) + ".jpg"
p = Picture(
name=(to_unicode(str(r['id_photo'])) + ".jpg").encode('utf-8'),
name=str(r['id_photo']) + ".jpg",
owner=user,
is_moderated=True,
is_folder=False,

View File

@ -17,9 +17,11 @@ class Picture(SithFile):
@property
def is_vertical(self):
im = Image.open(BytesIO(self.file.read()))
with open(settings.MEDIA_ROOT + self.file.name).encode('utf-8'), 'rb') as f:
im = Image.open(BytesIO(f.read()))
(w, h) = im.size
return (w / h) < 1
return False
def can_be_edited_by(self, user):
return user.is_in_group(settings.SITH_SAS_ADMIN_GROUP_ID)

View File

@ -18,7 +18,7 @@
<a href="{{ url('sas:album_edit', album_id=album.id) }}">{% trans %}Edit{% endtrans %}</a><br>
<hr>
<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).order_by('-id') %}
<a href="{{ url("sas:album", album_id=a.id) }}" style="display: inline-block">
<div class="album">
<div>