def photo(request, album, photo):
    """Shows a detailed view of the photo."""
    tpl = 'cmsplugin_photologue_pro/photo.html'
    gallery = models.Gallery.objects.filter(pk=album)
    gallery = filter_association_content(
      gallery, request, key='galleryassociation__')
    if len(gallery) == 0:
        return render(request, tpl)
    else:
        gallery = gallery[0]
    try:
        photo = gallery.photos.get(pk=photo)
    except models.Photo.DoesNotExist:
        return render(request, tpl)
    if not gallery.is_public or not photo.is_public:
        return render(request, tpl, {'is_not_public': True})
    photosize = models.PhotoSize.objects.get(name='normal')
    photo.create_size(photosize)
    # FIXME: In the template, DATE_FORMAT is wrong. So I'm going this way
    photo.datetaken = formats.date_format(photo.date_taken, 'DATE_FORMAT',
                                          True)
    exif = None
    previous_photo = photo.get_previous_in_gallery(gallery)
    next_photo = photo.get_next_in_gallery(gallery)
    if getattr(settings, 'PHOTOLOGUE_PRO_EXIF_ENABLED', False):
        exif = photo.EXIF
    return render(request, tpl,
                  {'gallery': gallery,
                   'photo': photo,
                   'exif': exif,
                   'previous': previous_photo,
                   'next': next_photo})
def overview(request):
    """Shows all available photo galleries."""
    galleries = models.Gallery.objects.select_related()
    galleries = galleries.order_by('date_added').filter(is_public=True)
    galleries = filter_association_content(
        galleries, request, key='galleryassociation__')
    for gallery in galleries:
        photos = gallery.photos.filter(is_public=True).order_by('id')
        gallery.filtered_photos = photos
    photosize = models.PhotoSize.objects.get(name='thumbnail')
    return render(request, 'cmsplugin_photologue_pro/index.html',
                  {'galleries': galleries,
                   'order': [1, 2, 3],
                   'photosize': photosize})
def album(request, album):
    """Shows all images of album."""
    tpl = 'cmsplugin_photologue_pro/album.html'
    gallery = models.Gallery.objects.filter(pk=album)
    gallery = filter_association_content(
      gallery, request, key='galleryassociation__')
    if len(gallery) == 0:
        return render(request, tpl)
    else:
        gallery = gallery[0]
    if not gallery.is_public:
        return render(request, tpl,
                      {'is_not_public': True})
    photos = gallery.photos.filter(is_public=True).order_by('id')
    photosize = models.PhotoSize.objects.get(name='thumbnail')
    return render(request, tpl,
                  {'gallery': gallery,
                   'photos': photos,
                   'photosize': photosize})
Beispiel #4
0
 def get_queryset(self, *args, **kwargs):
     queryset = super(EventView, self).get_queryset(*args, **kwargs)
     return filter_association_content(queryset, self.request)