diff options
Diffstat (limited to 'app/photos/forms.py')
-rw-r--r-- | app/photos/forms.py | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/app/photos/forms.py b/app/photos/forms.py index f12ce42..08927cd 100644 --- a/app/photos/forms.py +++ b/app/photos/forms.py @@ -13,6 +13,7 @@ except ImportError: from django import forms from django.utils.translation import ugettext_lazy as _ +from django.utils.safestring import mark_safe from django.contrib import messages from django.core.files.base import ContentFile from django.contrib.admin import widgets @@ -28,6 +29,26 @@ from .utils import resize_image logger = logging.getLogger('photos.forms') +class GalleryForm(forms.ModelForm): + class Meta: + model = LuxGallery + fields = '__all__' + widgets = { + 'images': forms.SelectMultiple, + } + + def __init__(self, *args, **kwargs): + super(GalleryForm, self).__init__(*args, **kwargs) + + images = LuxImage.objects.all()[:100] + items = [] + for image in images: + items.append( + (image.pk, mark_safe('%s' % image.get_image_name())) + ) + self.fields['images'].choices = items + self.fields['images'].allow_tags = True + class UploadZipForm(forms.Form): """ Handles the uploading of a gallery of photos packed in a .zip file @@ -129,7 +150,7 @@ class UploadZipForm(forms.Form): contentfile = ContentFile(data) image.image.save(filename, contentfile) image.save() - gallery.image.add(image) + gallery.images.add(image) with exiftool.ExifTool() as et: meta = et.get_metadata(image.image.path) @@ -146,7 +167,10 @@ class UploadZipForm(forms.Form): try: image.exif_lens = meta["MakerNotes:LensType"] except: - pass + try: + image.exif_lens = meta["XMP:Lens"] + except: + pass try: image.point = Point(meta["XMP:GPSLongitude"], meta["XMP:GPSLatitude"], srid=4326) try: |