From 221efdec6cd51b331f2512f8114e3f0f150d160a Mon Sep 17 00:00:00 2001 From: eric Date: Tue, 16 Aug 2016 17:17:24 -0400 Subject: [PATCH] make it easier to find and edit ebook editions --- frontend/forms.py | 6 +++++- frontend/templates/edition_display.html | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/frontend/forms.py b/frontend/forms.py index 0c10f46a..b432c2a2 100644 --- a/frontend/forms.py +++ b/frontend/forms.py @@ -242,7 +242,11 @@ class EditionForm(forms.ModelForm): has_goog = self.cleaned_data.get("goog", False) not in nulls has_http = self.cleaned_data.get("http", False) not in nulls has_doi = self.cleaned_data.get("doi", False) not in nulls - if not has_isbn and not has_oclc and not has_goog and not has_http and not has_doi: + try: + has_id = self.instance.work.identifiers.all().count() > 0 + except AttributeError: + has_id = False + if not has_id and not has_isbn and not has_oclc and not has_goog and not has_http and not has_doi: raise forms.ValidationError(_("There must be either an ISBN, a DOI, a URL or an OCLC number.")) return self.cleaned_data class Meta: diff --git a/frontend/templates/edition_display.html b/frontend/templates/edition_display.html index 86de5126..0c9583c4 100644 --- a/frontend/templates/edition_display.html +++ b/frontend/templates/edition_display.html @@ -19,6 +19,9 @@ {% if edition.note %} {{ edition.note }}.
{% endif %} + {% if edition.ebooks.all %} + {{ edition.ebooks.all.count }} ebooks
+ {% endif %} {% if edition.publisher %} Publisher: {{edition.publisher}}
{% endif %}