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:
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 <a href="%(url)s">already in repository</a>.'
+ ) % {'url': img.get_absolute_url()}))
+ return cl
def clean(self):
cleaned_data = super(ImageAddForm, self).clean()
raise forms.ValidationError('No image specified')
return cleaned_data
-
class ImageEditForm(forms.ModelForm):
"""Form used for editing a Book."""
class Meta:
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 <radoslaw.czajka@nowoczesnapolska.org.pl>\n"
"Language-Team: LANGUAGE <LL@li.org>\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 <a href=\"%(url)s\">already in repository</a>."
+msgstr "Obraz <a href=\"%(url)s\">jest już w repozytorium</a>."
+
+#: 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"
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"
-