Commit 7a817c59 authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

Merge branch 'feature/photos-translations' into 'master'

Add translations for photos app

Closes #300

See merge request !372
parents 2117a728 c9aa7db9
...@@ -7,6 +7,7 @@ from django.contrib import admin ...@@ -7,6 +7,7 @@ from django.contrib import admin
from django.contrib import messages from django.contrib import messages
from django.core.exceptions import ValidationError from django.core.exceptions import ValidationError
from django.core.files.base import ContentFile from django.core.files.base import ContentFile
from django.utils.translation import ugettext_lazy as _
from .models import Album, Photo from .models import Album, Photo
...@@ -29,8 +30,8 @@ class AlbumForm(forms.ModelForm): ...@@ -29,8 +30,8 @@ class AlbumForm(forms.ModelForm):
album_archive = forms.FileField( album_archive = forms.FileField(
required=False, required=False,
help_text="Uploading a zip or tar file adds all contained images as " help_text=_("Uploading a zip or tar file adds all contained images as "
"photos.", "photos."),
validators=[validate_uploaded_archive] validators=[validate_uploaded_archive]
) )
...@@ -60,7 +61,7 @@ def save_photo(request, archive_file, photo, album): ...@@ -60,7 +61,7 @@ def save_photo(request, archive_file, photo, album):
photo_obj.file.save(photo_filename, ContentFile(f.read())) photo_obj.file.save(photo_filename, ContentFile(f.read()))
except (OSError, AttributeError): except (OSError, AttributeError):
messages.add_message(request, messages.WARNING, messages.add_message(request, messages.WARNING,
"Ignoring {}".format(photo_filename)) _("Ignoring {}").format(photo_filename))
else: else:
photo_obj.save() photo_obj.save()
...@@ -90,20 +91,20 @@ class AlbumAdmin(admin.ModelAdmin): ...@@ -90,20 +91,20 @@ class AlbumAdmin(admin.ModelAdmin):
for photo in tar_file.getmembers(): for photo in tar_file.getmembers():
save_photo(request, tar_file, photo, obj) save_photo(request, tar_file, photo, obj)
except tarfile.ReadError: except tarfile.ReadError:
raise ValueError("The uploaded file is not a zip or tar " raise ValueError(_("The uploaded file is not a zip or tar "
"file.") "file."))
messages.add_message(request, messages.WARNING, messages.add_message(request, messages.WARNING,
"Full-sized photos will not be saved on the " _("Full-sized photos will not be saved "
"Thalia-website.") "on the Thalia-website."))
class PhotoAdmin(admin.ModelAdmin): class PhotoAdmin(admin.ModelAdmin):
def save_model(self, request, obj, form, change): def save_model(self, request, obj, form, change):
obj.save() obj.save()
messages.add_message(request, messages.WARNING, messages.add_message(request, messages.WARNING,
"Full-sized photos will not be saved on the " _("Full-sized photos will not be saved "
"Thalia-website.") "on the Thalia-website."))
admin.site.register(Album, AlbumAdmin) admin.site.register(Album, AlbumAdmin)
admin.site.register(Photo, PhotoAdmin) admin.site.register(Photo, PhotoAdmin)
...@@ -7,30 +7,101 @@ msgid "" ...@@ -7,30 +7,101 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: \n" "Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-11-14 22:13+0100\n" "POT-Creation-Date: 2017-02-22 20:29+0100\n"
"PO-Revision-Date: 2016-11-14 22:14+0100\n" "PO-Revision-Date: 2017-02-22 20:31+0100\n"
"Last-Translator: Sébastiaan Versteeg <se_bastiaan@outlook.com>\n"
"Language-Team: \n"
"Language: nl\n" "Language: nl\n"
"MIME-Version: 1.0\n" "MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n" "Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n" "Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Last-Translator: Joost Rijneveld <joost@joostrijneveld.nl>\n" "X-Generator: Poedit 1.8.12\n"
"Language-Team: \n"
"X-Generator: Poedit 1.8.11\n" #: admin.py:33
msgid "Uploading a zip or tar file adds all contained images as photos."
msgstr ""
"Indien je een zip of tar file upload worden alle afbeeldingen in het bestand "
"als foto’s toegevoegd."
#: admin.py:64
msgid "Ignoring {}"
msgstr "{} wordt genegeerd"
#: admin.py:94
msgid "The uploaded file is not a zip or tar file."
msgstr "Het geüploade bestand is geen als zip of tar archief."
#: admin.py:98 admin.py:106
msgid "Full-sized photos will not be saved on the Thalia-website."
msgstr ""
"De foto’s op de Thalia-website worden niet opgeslagen in originele grootte."
#: models.py:23
msgid "album"
msgstr "album"
#: models.py:27
msgid "file"
msgstr "bestand"
#: models.py:32
msgid "rotation"
msgstr "rotatie"
#: models.py:35
msgid "This does not modify the original image file."
msgstr "Dit verandert het originele bestand niet."
#: models.py:39 models.py:88
msgid "hidden"
msgstr "verborgen"
#: models.py:70
msgid "title"
msgstr "titel"
#: models.py:75
msgid "directory name"
msgstr "mapnaam"
#: models.py:80
msgid "date"
msgstr "datum"
#: models.py:84
msgid "slug"
msgstr "slug"
#: models.py:98
msgid "cover image"
msgstr "coverafbeelding"
#: models.py:102
msgid "shareable"
msgstr "deelbaar"
#: templates/photos/album.html:4 templates/photos/index.html:4 #: templates/photos/album.html:4 templates/photos/index.html:4
#: templates/photos/index.html:12 #: templates/photos/index.html:14
msgid "Photos" msgid "Photos"
msgstr "Foto's" msgstr "Foto's"
#: templates/photos/album.html:16 #: templates/photos/album.html:24
msgid "" msgid ""
"Note: This album can be shared with people outside the association by " "Note: This album can be shared with people outside the association by "
"sending them the following link:" "sending them the following link:"
msgstr "" msgstr ""
"Let op: Dit album kan gedeeld worden met mensen buiten de vereniging " "Let op: Dit album kan gedeeld worden met mensen buiten de vereniging via de "
"via de volgende link:" "volgende link:"
#: templates/photos/index.html:64 #: templates/photos/index.html:66
msgid "Next" msgid "Next"
msgstr "Volgende" msgstr "Volgende"
#, fuzzy
#~| msgid "The uploaded file is not a zip or tar file."
#~ msgid "The uploaded file is not azip or tar file."
#~ msgstr "Het geüploade bestand is geen als zip of tar archief."
#~ msgid "The uploaded file is not recognised as zip or tar."
#~ msgstr "Het geüploade bestand wordt niet herkend als zip of tar."
# -*- coding: utf-8 -*-
# Generated by Django 1.10.3 on 2017-02-18 20:42
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import photos.models
class Migration(migrations.Migration):
dependencies = [
('photos', '0006_auto_20170120_0837'),
]
operations = [
migrations.AlterField(
model_name='album',
name='_cover',
field=models.OneToOneField(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='covered_album', to='photos.Photo', verbose_name='cover image'),
),
migrations.AlterField(
model_name='album',
name='date',
field=models.DateField(verbose_name='date'),
),
migrations.AlterField(
model_name='album',
name='dirname',
field=models.CharField(max_length=200, verbose_name='directory name'),
),
migrations.AlterField(
model_name='album',
name='hidden',
field=models.BooleanField(default=False, verbose_name='hidden'),
),
migrations.AlterField(
model_name='album',
name='shareable',
field=models.BooleanField(default=False, verbose_name='shareable'),
),
migrations.AlterField(
model_name='album',
name='slug',
field=models.SlugField(verbose_name='slug'),
),
migrations.AlterField(
model_name='album',
name='title',
field=models.CharField(max_length=200, verbose_name='title'),
),
migrations.AlterField(
model_name='photo',
name='album',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='photos.Album', verbose_name='album'),
),
migrations.AlterField(
model_name='photo',
name='file',
field=models.ImageField(upload_to=photos.models.photo_uploadto, verbose_name='file'),
),
migrations.AlterField(
model_name='photo',
name='hidden',
field=models.BooleanField(default=False, verbose_name='hidden'),
),
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.', verbose_name='rotation'),
),
]
...@@ -6,6 +6,7 @@ from django.conf import settings ...@@ -6,6 +6,7 @@ from django.conf import settings
from django.db import models from django.db import models
from django.urls import reverse from django.urls import reverse
from django.utils.functional import cached_property from django.utils.functional import cached_property
from django.utils.translation import ugettext_lazy as _
from PIL import Image from PIL import Image
COVER_FILENAME = 'cover.jpg' COVER_FILENAME = 'cover.jpg'
...@@ -16,14 +17,28 @@ def photo_uploadto(instance, filename): ...@@ -16,14 +17,28 @@ def photo_uploadto(instance, filename):
class Photo(models.Model): class Photo(models.Model):
album = models.ForeignKey('Album', on_delete=models.CASCADE) album = models.ForeignKey(
file = models.ImageField(upload_to=photo_uploadto) 'Album',
on_delete=models.CASCADE,
verbose_name=_("album")
)
file = models.ImageField(
_('file'),
upload_to=photo_uploadto
)
rotation = models.IntegerField( rotation = models.IntegerField(
verbose_name=_('rotation'),
default=0, default=0,
choices=((x, x) for x in (0, 90, 180, 270)), choices=((x, x) for x in (0, 90, 180, 270)),
help_text="This does not modify the original image file.", help_text=_('This does not modify the original image file.'),
)
hidden = models.BooleanField(
_('hidden'),
default=False
) )
hidden = models.BooleanField(default=False)
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs) super().__init__(*args, **kwargs)
...@@ -51,14 +66,42 @@ class Photo(models.Model): ...@@ -51,14 +66,42 @@ class Photo(models.Model):
class Album(models.Model): class Album(models.Model):
title = models.CharField(max_length=200) title = models.CharField(
dirname = models.CharField(max_length=200) verbose_name=_('title'),
date = models.DateField() max_length=200,
slug = models.SlugField() )
hidden = models.BooleanField(default=False)
_cover = models.OneToOneField(Photo, on_delete=models.SET_NULL, blank=True, dirname = models.CharField(
null=True, related_name='covered_album') verbose_name=_('directory name'),
shareable = models.BooleanField(default=False) max_length=200,
)
date = models.DateField(
verbose_name=_('date'),
)
slug = models.SlugField(
verbose_name=_('slug'),
)
hidden = models.BooleanField(
verbose_name=_('hidden'),
default=False
)
_cover = models.OneToOneField(
Photo,
on_delete=models.SET_NULL,
blank=True,
null=True,
related_name='covered_album',
verbose_name=_('cover image'),
)
shareable = models.BooleanField(
verbose_name=_('shareable'),
default=False
)
photosdir = 'photos' photosdir = 'photos'
photospath = os.path.join(settings.MEDIA_ROOT, photosdir) photospath = os.path.join(settings.MEDIA_ROOT, photosdir)
......
Supports Markdown
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