Verified Commit c9aa7db9 authored by Sébastiaan Versteeg's avatar Sébastiaan Versteeg
Browse files

Add translations for photos app

parent f8b15a27
......@@ -7,6 +7,7 @@ from django.contrib import admin
from django.contrib import messages
from django.core.exceptions import ValidationError
from django.core.files.base import ContentFile
from django.utils.translation import ugettext_lazy as _
from .models import Album, Photo
......@@ -29,8 +30,8 @@ class AlbumForm(forms.ModelForm):
album_archive = forms.FileField(
required=False,
help_text="Uploading a zip or tar file adds all contained images as "
"photos.",
help_text=_("Uploading a zip or tar file adds all contained images as "
"photos."),
validators=[validate_uploaded_archive]
)
......@@ -60,7 +61,7 @@ def save_photo(request, archive_file, photo, album):
photo_obj.file.save(photo_filename, ContentFile(f.read()))
except (OSError, AttributeError):
messages.add_message(request, messages.WARNING,
"Ignoring {}".format(photo_filename))
_("Ignoring {}").format(photo_filename))
else:
photo_obj.save()
......@@ -90,20 +91,20 @@ class AlbumAdmin(admin.ModelAdmin):
for photo in tar_file.getmembers():
save_photo(request, tar_file, photo, obj)
except tarfile.ReadError:
raise ValueError("The uploaded file is not a zip or tar "
"file.")
raise ValueError(_("The uploaded file is not a zip or tar "
"file."))
messages.add_message(request, messages.WARNING,
"Full-sized photos will not be saved on the "
"Thalia-website.")
_("Full-sized photos will not be saved "
"on the Thalia-website."))
class PhotoAdmin(admin.ModelAdmin):
def save_model(self, request, obj, form, change):
obj.save()
messages.add_message(request, messages.WARNING,
"Full-sized photos will not be saved on the "
"Thalia-website.")
_("Full-sized photos will not be saved "
"on the Thalia-website."))
admin.site.register(Album, AlbumAdmin)
admin.site.register(Photo, PhotoAdmin)
......@@ -7,30 +7,101 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2016-11-14 22:13+0100\n"
"PO-Revision-Date: 2016-11-14 22:14+0100\n"
"POT-Creation-Date: 2017-02-22 20:29+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"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Last-Translator: Joost Rijneveld <joost@joostrijneveld.nl>\n"
"Language-Team: \n"
"X-Generator: Poedit 1.8.11\n"
"X-Generator: Poedit 1.8.12\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/index.html:12
#: templates/photos/index.html:14
msgid "Photos"
msgstr "Foto's"
#: templates/photos/album.html:16
#: templates/photos/album.html:24
msgid ""
"Note: This album can be shared with people outside the association by "
"sending them the following link:"
msgstr ""
"Let op: Dit album kan gedeeld worden met mensen buiten de vereniging "
"via de volgende link:"
"Let op: Dit album kan gedeeld worden met mensen buiten de vereniging via de "
"volgende link:"
#: templates/photos/index.html:64
#: templates/photos/index.html:66
msgid "Next"
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
from django.db import models
from django.urls import reverse
from django.utils.functional import cached_property
from django.utils.translation import ugettext_lazy as _
from PIL import Image
COVER_FILENAME = 'cover.jpg'
......@@ -16,14 +17,28 @@ def photo_uploadto(instance, filename):
class Photo(models.Model):
album = models.ForeignKey('Album', on_delete=models.CASCADE)
file = models.ImageField(upload_to=photo_uploadto)
album = models.ForeignKey(
'Album',
on_delete=models.CASCADE,
verbose_name=_("album")
)
file = models.ImageField(
_('file'),
upload_to=photo_uploadto
)
rotation = models.IntegerField(
verbose_name=_('rotation'),
default=0,
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):
super().__init__(*args, **kwargs)
......@@ -51,14 +66,42 @@ class Photo(models.Model):
class Album(models.Model):
title = models.CharField(max_length=200)
dirname = models.CharField(max_length=200)
date = models.DateField()
slug = models.SlugField()
hidden = models.BooleanField(default=False)
_cover = models.OneToOneField(Photo, on_delete=models.SET_NULL, blank=True,
null=True, related_name='covered_album')
shareable = models.BooleanField(default=False)
title = models.CharField(
verbose_name=_('title'),
max_length=200,
)
dirname = models.CharField(
verbose_name=_('directory name'),
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'
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