Make all galleries public

This commit is contained in:
Alexandre Iooss 2022-01-30 13:13:53 +01:00
parent 8b768108d2
commit 4b3cf83181
7 changed files with 24 additions and 31 deletions

View file

@ -17,6 +17,6 @@ class MediaAccess(LoginRequiredMixin, View):
class IndexView(LoginRequiredMixin, ListView):
queryset = Gallery.objects.filter(is_public=True)
queryset = Gallery.objects.all()
paginate_by = 4
template_name = "index.html"

View file

@ -5,8 +5,8 @@ from .models import Gallery, Photo, Tag
class GalleryAdmin(admin.ModelAdmin):
list_display = ('title', 'date_start', 'photo_count', 'is_public')
list_filter = ['date_start', 'is_public']
list_display = ('title', 'date_start', 'photo_count')
list_filter = ['date_start']
date_hierarchy = 'date_start'
prepopulated_fields = {'slug': ('title',)}
model = Gallery

View file

@ -0,0 +1,17 @@
# Generated by Django 3.2.11 on 2022-01-30 12:14
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('photologue', '0002_auto_20220130_1020'),
]
operations = [
migrations.RemoveField(
model_name='gallery',
name='is_public',
),
]

View file

@ -15,7 +15,6 @@ import exifread
from django.conf import settings
from django.core.exceptions import ValidationError
from django.core.files.base import ContentFile
from django.core.files.storage import default_storage
from django.core.validators import RegexValidator
from django.db import models
from django.template.defaultfilters import slugify
@ -153,10 +152,6 @@ class Gallery(models.Model):
verbose_name=_('tags'),
blank=True,
)
is_public = models.BooleanField(_('is public'),
default=True,
help_text=_('Public galleries will be displayed '
'in the default views.'))
photos = models.ManyToManyField('photologue.Photo',
related_name='galleries',
verbose_name=_('photos'),
@ -500,7 +495,7 @@ class Photo(ImageModel):
def public_galleries(self):
"""Return the public galleries to which this photo belongs."""
return self.galleries.filter(is_public=True)
return self.galleries
def get_previous_in_gallery(self, gallery):
"""Find the neighbour of this photo in the supplied gallery.

View file

@ -39,7 +39,6 @@ SPDX-License-Identifier: GPL-3.0-or-later
{% endif %}
</h1>
{% if gallery.date_start %}<p class="text-muted small">{{ gallery.date_start }}{% if gallery.date_end and gallery.date_end != gallery.date_start %} {% trans "to" %} {{ gallery.date_end }}{% endif %}</p>{% endif %}
{% if not gallery.is_public %}<p><span class="badge rounded-pill bg-danger">PRIVATE</span></p>{% endif %}
{% if gallery.tags.all %}
<p class="text-muted">
Tags : {% for tag in gallery.tags.all %}

View file

@ -1,13 +1,12 @@
{% load i18n %}
<div class="card text-white {% if not gallery.is_public %}bg-danger{% else %}bg-dark{% endif %}">
<div class="card text-white bg-dark">
{% for photo in gallery.sample %}
<img src="{{ photo.get_thumbnail_url }}" class="card-img-top" alt="{{ photo.title }}">
{% endfor %}
<div class="card-body">
<h5 class="card-title">{{ gallery.title }}</h5>
{% if gallery.date_start %}<p class="card-text text-muted small mb-0">{{ gallery.date_start }}{% if gallery.date_end and gallery.date_end != gallery.date_start %} - {{ gallery.date_end }}{% endif %}</p>{% endif %}
{% if not gallery.is_public %}<p class="card-text small mb-0">(private)</p>{% endif %}
<a href="{{ gallery.get_absolute_url }}" class="stretched-link"></a>
</div>
</div>

View file

@ -29,14 +29,6 @@ class GalleryDateView(LoginRequiredMixin):
uses_datetime_field = False # Fix related object access
allow_empty = True
def get_queryset(self):
"""Non-staff members only see public galleries"""
qs = super().get_queryset()
if self.request.user.is_staff:
return qs
else:
return qs.filter(is_public=True)
class GalleryArchiveIndexView(GalleryDateView, ArchiveIndexView):
pass
@ -67,8 +59,7 @@ class TagDetail(LoginRequiredMixin, DetailView):
"""
current_tag = self.get_object().slug
context = super().get_context_data(**kwargs)
context['galleries'] = Gallery.objects.filter(is_public=True) \
.filter(tags__slug=current_tag) \
context['galleries'] = Gallery.objects.filter(tags__slug=current_tag) \
.order_by('-date_start')
return context
@ -79,14 +70,6 @@ class GalleryDetailView(LoginRequiredMixin, DetailView):
"""
model = Gallery
def get_queryset(self):
"""Non-staff members only see public galleries"""
qs = super().get_queryset()
if self.request.user.is_staff:
return qs
else:
return qs.filter(is_public=True)
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
@ -110,7 +93,7 @@ class GalleryDetailView(LoginRequiredMixin, DetailView):
class GalleryDownload(LoginRequiredMixin, DetailView):
queryset = Gallery.objects.filter(is_public=True)
model = Gallery
def get(self, request, *args, **kwargs):
"""