Commit 73711818 authored by Thom Wiggers's avatar Thom Wiggers 📐
Browse files

Merge branch '217-photo-cover' into 'master'

Constrain album cover selection to photos from album

Closes #217

See merge request !223
parents 6b2bbdc9 85b23793
...@@ -10,6 +10,15 @@ from .models import Album, Photo ...@@ -10,6 +10,15 @@ from .models import Album, Photo
class AlbumForm(forms.ModelForm): class AlbumForm(forms.ModelForm):
# Excuse my french
# https://stackoverflow.com/questions/4391776/django-admin-inline-forms-limit-foreign-key-queryset-to-a-set-of-values#4392047
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if 'instance' in kwargs:
self.fields['_cover'].queryset = Photo.objects.filter(
album=self.instance)
album_archive = forms.FileField( album_archive = forms.FileField(
required=False, required=False,
help_text="Uploading a zip file adds all contained images as photos.", help_text="Uploading a zip file adds all contained images as photos.",
......
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