From: Radek Czajka Date: Tue, 25 Feb 2014 12:33:46 +0000 (+0100) Subject: Link to existing cover when trying to add a duplicate. X-Git-Url: https://git.mdrn.pl/redakcja.git/commitdiff_plain/44f4112a8796f5d2c555bed63f34b9ce98e5fe65?ds=inline;hp=--cc Link to existing cover when trying to add a duplicate. --- 44f4112a8796f5d2c555bed63f34b9ce98e5fe65 diff --git a/apps/cover/forms.py b/apps/cover/forms.py index 5b514f08..f49f4f54 100755 --- a/apps/cover/forms.py +++ b/apps/cover/forms.py @@ -6,8 +6,9 @@ import re from urllib2 import urlopen from django import forms -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import ugettext_lazy as _, ugettext from cover.models import Image +from django.utils.text import mark_safe class ImageAddForm(forms.ModelForm): class Meta: @@ -18,10 +19,17 @@ class ImageAddForm(forms.ModelForm): self.fields['file'].required = False def clean_download_url(self): - return self.cleaned_data['download_url'] or None - - def clean_source_url(self): - return self.cleaned_data['source_url'] or None + cl = self.cleaned_data['download_url'] or None + if cl is not None: + try: + img = Image.objects.get(download_url=cl) + except Image.DoesNotExist: + pass + else: + raise forms.ValidationError(mark_safe( + ugettext('Image already in repository.' + ) % {'url': img.get_absolute_url()})) + return cl def clean(self): cleaned_data = super(ImageAddForm, self).clean() @@ -29,7 +37,6 @@ class ImageAddForm(forms.ModelForm): raise forms.ValidationError('No image specified') return cleaned_data - class ImageEditForm(forms.ModelForm): """Form used for editing a Book.""" class Meta: diff --git a/apps/cover/locale/pl/LC_MESSAGES/django.mo b/apps/cover/locale/pl/LC_MESSAGES/django.mo index 3a84d1d3..1c297fe0 100644 Binary files a/apps/cover/locale/pl/LC_MESSAGES/django.mo and b/apps/cover/locale/pl/LC_MESSAGES/django.mo differ diff --git a/apps/cover/locale/pl/LC_MESSAGES/django.po b/apps/cover/locale/pl/LC_MESSAGES/django.po index 7b8ba0fc..67547cec 100644 --- a/apps/cover/locale/pl/LC_MESSAGES/django.po +++ b/apps/cover/locale/pl/LC_MESSAGES/django.po @@ -7,62 +7,67 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-06-18 12:36+0200\n" -"PO-Revision-Date: 2012-06-18 12:38+0100\n" +"POT-Creation-Date: 2014-02-25 13:29+0100\n" +"PO-Revision-Date: 2014-02-25 13:30+0100\n" "Last-Translator: Radek Czajka \n" "Language-Team: LANGUAGE \n" -"Language: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2)\n" +"Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 " +"|| n%100>=20) ? 1 : 2);\n" +"X-Generator: Poedit 1.5.4\n" -#: forms.py:37 +#: forms.py:29 +#, python-format +msgid "Image already in repository." +msgstr "Obraz jest już w repozytorium." + +#: forms.py:60 msgid "Flickr URL" msgstr "URL z Flickra" -#: models.py:18 +#: models.py:19 msgid "title" msgstr "tytuł" -#: models.py:19 +#: models.py:20 msgid "author" msgstr "autor" -#: models.py:20 +#: models.py:21 msgid "license name" msgstr "nazwa licencji" -#: models.py:21 +#: models.py:22 msgid "license URL" msgstr "URL licencji" -#: models.py:22 +#: models.py:23 msgid "source URL" msgstr "URL źródła" -#: models.py:23 +#: models.py:24 msgid "image download URL" msgstr "URL pliku do pobrania" -#: models.py:24 +#: models.py:25 msgid "file" msgstr "plik" -#: models.py:27 +#: models.py:28 msgid "cover image" msgstr "obrazek na okładkę" -#: models.py:28 +#: models.py:29 msgid "cover images" msgstr "obrazki na okładki" -#: templates/cover/add_image.html:6 -#: templates/cover/add_image.html.py:21 +#: templates/cover/add_image.html:33 templates/cover/add_image.html.py:62 msgid "Add image" msgstr "Dodaj obrazek" -#: templates/cover/add_image.html:13 +#: templates/cover/add_image.html:40 msgid "Load from Flickr" msgstr "Pobierz z Flickra" @@ -74,15 +79,22 @@ msgstr "Obrazek na okładkę" msgid "source" msgstr "źródło" -#: templates/cover/image_detail.html:31 +#: templates/cover/image_detail.html:35 msgid "Change" msgstr "Zmień" -#: templates/cover/image_list.html:8 +#: templates/cover/image_detail.html:41 +msgid "Used in:" +msgstr "Użyte w:" + +#: templates/cover/image_detail.html:49 +msgid "None" +msgstr "Brak" + +#: templates/cover/image_list.html:7 msgid "Cover images" msgstr "Obrazki na okładki" -#: templates/cover/image_list.html:11 +#: templates/cover/image_list.html:10 msgid "Add new" msgstr "Dodaj nowy" - diff --git a/lib/librarian b/lib/librarian index ca1a7383..6351b433 160000 --- a/lib/librarian +++ b/lib/librarian @@ -1 +1 @@ -Subproject commit ca1a73838b1045835171dfa243f9c2c0dfa735fe +Subproject commit 6351b433475b8119c8cd0cf7a8c72c623308c5d3