diff --git a/website/photos/migrations/0003_auto_20160809_1856.py b/website/photos/migrations/0003_auto_20160809_1856.py new file mode 100644 index 0000000000000000000000000000000000000000..7db93b337b99e521deec1b5df654ff59b0dc8cca --- /dev/null +++ b/website/photos/migrations/0003_auto_20160809_1856.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.10 on 2016-08-09 16:56 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('photos', '0002_auto_20160809_1755'), + ] + + operations = [ + migrations.AlterField( + model_name='photo', + name='rotation', + field=models.IntegerField(choices=[(0, 0), (90, 90), (180, 180), (270, 270)], default=0, help_text='This does not modify the original image file.'), + ), + ] diff --git a/website/photos/models.py b/website/photos/models.py index 5a2196ce7274b8055a8f40431e7474283f24c0f6..505072d63578cdd15ae2735baefce3941a18f226 100644 --- a/website/photos/models.py +++ b/website/photos/models.py @@ -16,7 +16,11 @@ def photo_uploadto(instance, filename): class Photo(models.Model): album = models.ForeignKey('Album', on_delete=models.CASCADE) file = models.ImageField(upload_to=photo_uploadto) - rotation = models.IntegerField(default=0) + rotation = models.IntegerField( + default=0, + choices=((x, x) for x in (0, 90, 180, 270)), + help_text="This does not modify the original image file.", + ) def __str__(self): return self.file.name diff --git a/website/photos/static/photos/css/style.css b/website/photos/static/photos/css/style.css new file mode 100644 index 0000000000000000000000000000000000000000..a7b023c56adeb81afbb18a4a401488a90a1add79 --- /dev/null +++ b/website/photos/static/photos/css/style.css @@ -0,0 +1,13 @@ + +/* Solving this with dynamic a data attribute (i.e. attr(data-rotation)) does not work, as that's a string. */ +img.rotate90 { + transform: rotate(90deg); +} + +img.rotate180 { + transform: rotate(180deg); +} + +img.rotate270 { + transform: rotate(270deg); +} diff --git a/website/photos/templates/photos/album.html b/website/photos/templates/photos/album.html index 9d500be98754dd9e61a84c44445274b4ec2a3f27..992ee9f2c8cf7791a59a2e78fdc9cd1744e0347e 100644 --- a/website/photos/templates/photos/album.html +++ b/website/photos/templates/photos/album.html @@ -3,6 +3,11 @@ {% block page_title %}{% trans "Photos" %}{% endblock %} +{% block css_head %} +{{ block.super }} + +{% endblock %} + {% block body %}

{{ album.title }}

{{ album.date|date:"d-m-Y" }}

@@ -10,10 +15,10 @@