Unverified Commit e4cb4e28 authored by Joost Rijneveld's avatar Joost Rijneveld
Browse files

Enable hiding of photos and albums

This might be a useful feature before publishing albums publically,
to review if everything looks ok.
parent 51266987
# -*- coding: utf-8 -*-
# Generated by Django 1.10 on 2016-08-10 12:47
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('photos', '0003_auto_20160809_1856'),
]
operations = [
migrations.AddField(
model_name='album',
name='hidden',
field=models.BooleanField(default=False),
),
migrations.AddField(
model_name='photo',
name='hidden',
field=models.BooleanField(default=False),
),
]
......@@ -21,6 +21,7 @@ class Photo(models.Model):
choices=((x, x) for x in (0, 90, 180, 270)),
help_text="This does not modify the original image file.",
)
hidden = models.BooleanField(default=False)
def __str__(self):
return self.file.name
......@@ -31,6 +32,7 @@ class Album(models.Model):
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')
......
......@@ -13,7 +13,7 @@
<h2>{{ album.date|date:"d-m-Y" }}</h2>
<div class="gallery">
<ul class="gallery-photos row">
{% for photo in album.photo_set.all %}
{% for photo in photos %}
<li class="post gallery-photo span3 has-overlay {% if forloop.counter0|divisibleby:4 %}first-child{% endif %}">
<a data-fancybox-rotation="{{ photo.rotation }}" class="gallery-box" rel="gallery" data-download="{% url 'photos:download' photo.file %}" href="{% thumbnail photo.file '1024x768' fit=False %}">
<span class="post-inner">
......
......@@ -15,7 +15,7 @@ COVER_FILENAME = 'cover.jpg'
@login_required
def index(request):
albums = Album.objects.all().order_by('-date')
albums = Album.objects.filter(hidden=False).order_by('-date')
paginator = Paginator(albums, 12)
page = request.GET.get('page')
......@@ -33,7 +33,8 @@ def index(request):
@login_required
def album(request, slug):
album = get_object_or_404(Album, slug=slug)
return render(request, 'photos/album.html', {'album': album})
context = {'album': album, 'photos': album.photo_set.filter(hidden=False)}
return render(request, 'photos/album.html', context)
@login_required
......
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