suggestions: fixes and missing files
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 9 Jun 2011 12:12:57 +0000 (14:12 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Thu, 9 Jun 2011 12:12:57 +0000 (14:12 +0200)
apps/suggest/forms.py
apps/suggest/locale/pl/LC_MESSAGES/django.mo
apps/suggest/locale/pl/LC_MESSAGES/django.po
apps/suggest/migrations/0002_auto__add_publishingsuggestion.py [new file with mode: 0644]
apps/suggest/models.py
apps/suggest/templates/publishing_suggest.html [new file with mode: 0755]
apps/suggest/templates/publishing_suggest_full.html [new file with mode: 0755]

index 5c034e6..76170e1 100644 (file)
@@ -18,8 +18,15 @@ class SuggestForm(forms.Form):
 
 class PublishingSuggestForm(forms.Form):
     contact = forms.CharField(label=_('Contact'), max_length=120, required=False)
-    books = forms.CharField(label=_('books'), widget=forms.Textarea, required=True)
-    audiobooks = forms.CharField(label=_('audiobooks'), widget=forms.Textarea, required=True)
+    books = forms.CharField(label=_('books'), widget=forms.Textarea, required=False)
+    audiobooks = forms.CharField(label=_('audiobooks'), widget=forms.Textarea, required=False)
+
+    def clean(self, *args, **kwargs):
+        if not self.cleaned_data['books'] and not self.cleaned_data['audiobooks']:
+            msg = _(u"One of these fields is required.")
+            self._errors["books"] = self.error_class([msg])
+            self._errors["audiobooks"] = self.error_class([msg])
+        return super(PublishingSuggestForm, self).clean(*args, **kwargs)
 
     def save(self, request):
         contact = self.cleaned_data['contact']
index 2e3e5d7..3990bea 100644 (file)
Binary files a/apps/suggest/locale/pl/LC_MESSAGES/django.mo and b/apps/suggest/locale/pl/LC_MESSAGES/django.mo differ
index a14e7f3..7fdcbb5 100644 (file)
@@ -7,8 +7,8 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2011-06-09 12:31+0200\n"
-"PO-Revision-Date: 2011-06-09 12:35+0100\n"
+"POT-Creation-Date: 2011-06-09 13:06+0200\n"
+"PO-Revision-Date: 2011-06-09 13:06+0100\n"
 "Last-Translator: Radek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>\n"
 "Language-Team: LANGUAGE <LL@li.org>\n"
 "Language: \n"
@@ -27,19 +27,25 @@ msgid "Description"
 msgstr "Opis"
 
 #: forms.py:21
+#: models.py:27
 msgid "books"
 msgstr "książki"
 
 #: forms.py:22
+#: models.py:28
 msgid "audiobooks"
 msgstr "audiobooki"
 
-#: forms.py:55
+#: forms.py:26
+msgid "One of these fields is required."
+msgstr "Proszę wypełnić co najmniej jedno z tych pól."
+
+#: forms.py:62
 #: views.py:95
 msgid "Thank you for your suggestion."
 msgstr "Dziękujemy za zgłoszenie."
 
-#: forms.py:56
+#: forms.py:63
 #: views.py:96
 msgid ""
 "Thank you for your comment on WolneLektury.pl.\n"
@@ -48,7 +54,7 @@ msgstr ""
 "Dziękujemy za zgłoszenie uwag do serwisu Wolne Lektury.\n"
 "Sugestia została przekazana koordynatorce projektu."
 
-#: forms.py:62
+#: forms.py:69
 #: views.py:102
 msgid "Message sent automatically. Please do not reply."
 msgstr "Wiadomość wysłana automatycznie. Proszę nie odpowiadać."
@@ -59,8 +65,6 @@ msgid "contact"
 msgstr "kontakt"
 
 #: models.py:11
-#: models.py:27
-#: models.py:28
 msgid "description"
 msgstr "opis"
 
diff --git a/apps/suggest/migrations/0002_auto__add_publishingsuggestion.py b/apps/suggest/migrations/0002_auto__add_publishingsuggestion.py
new file mode 100644 (file)
index 0000000..8a52a7f
--- /dev/null
@@ -0,0 +1,88 @@
+# encoding: utf-8
+import datetime
+from south.db import db
+from south.v2 import SchemaMigration
+from django.db import models
+
+class Migration(SchemaMigration):
+
+    def forwards(self, orm):
+        
+        # Adding model 'PublishingSuggestion'
+        db.create_table('suggest_publishingsuggestion', (
+            ('id', self.gf('django.db.models.fields.AutoField')(primary_key=True)),
+            ('contact', self.gf('django.db.models.fields.CharField')(max_length=120, blank=True)),
+            ('books', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
+            ('audiobooks', self.gf('django.db.models.fields.TextField')(null=True, blank=True)),
+            ('created_at', self.gf('django.db.models.fields.DateTimeField')(auto_now_add=True, blank=True)),
+            ('ip', self.gf('django.db.models.fields.IPAddressField')(max_length=15)),
+            ('user', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['auth.User'], null=True, blank=True)),
+        ))
+        db.send_create_signal('suggest', ['PublishingSuggestion'])
+
+
+    def backwards(self, orm):
+        
+        # Deleting model 'PublishingSuggestion'
+        db.delete_table('suggest_publishingsuggestion')
+
+
+    models = {
+        'auth.group': {
+            'Meta': {'object_name': 'Group'},
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '80', 'unique': 'True'}),
+            'permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'})
+        },
+        'auth.permission': {
+            'Meta': {'ordering': "('content_type__app_label', 'content_type__model', 'codename')", 'unique_together': "(('content_type', 'codename'),)", 'object_name': 'Permission'},
+            'codename': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'content_type': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['contenttypes.ContentType']"}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '50'})
+        },
+        'auth.user': {
+            'Meta': {'object_name': 'User'},
+            'date_joined': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'email': ('django.db.models.fields.EmailField', [], {'max_length': '75', 'blank': 'True'}),
+            'first_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'groups': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Group']", 'symmetrical': 'False', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'is_active': ('django.db.models.fields.BooleanField', [], {'default': 'True'}),
+            'is_staff': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'is_superuser': ('django.db.models.fields.BooleanField', [], {'default': 'False'}),
+            'last_login': ('django.db.models.fields.DateTimeField', [], {'default': 'datetime.datetime.now'}),
+            'last_name': ('django.db.models.fields.CharField', [], {'max_length': '30', 'blank': 'True'}),
+            'password': ('django.db.models.fields.CharField', [], {'max_length': '128'}),
+            'user_permissions': ('django.db.models.fields.related.ManyToManyField', [], {'to': "orm['auth.Permission']", 'symmetrical': 'False', 'blank': 'True'}),
+            'username': ('django.db.models.fields.CharField', [], {'max_length': '30', 'unique': 'True'})
+        },
+        'contenttypes.contenttype': {
+            'Meta': {'ordering': "('name',)", 'unique_together': "(('app_label', 'model'),)", 'object_name': 'ContentType', 'db_table': "'django_content_type'"},
+            'app_label': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'model': ('django.db.models.fields.CharField', [], {'max_length': '100'}),
+            'name': ('django.db.models.fields.CharField', [], {'max_length': '100'})
+        },
+        'suggest.publishingsuggestion': {
+            'Meta': {'ordering': "('-created_at',)", 'object_name': 'PublishingSuggestion'},
+            'audiobooks': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'books': ('django.db.models.fields.TextField', [], {'null': 'True', 'blank': 'True'}),
+            'contact': ('django.db.models.fields.CharField', [], {'max_length': '120', 'blank': 'True'}),
+            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'ip': ('django.db.models.fields.IPAddressField', [], {'max_length': '15'}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'})
+        },
+        'suggest.suggestion': {
+            'Meta': {'ordering': "('-created_at',)", 'object_name': 'Suggestion'},
+            'contact': ('django.db.models.fields.CharField', [], {'max_length': '120', 'blank': 'True'}),
+            'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'blank': 'True'}),
+            'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}),
+            'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}),
+            'ip': ('django.db.models.fields.IPAddressField', [], {'max_length': '15'}),
+            'user': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['auth.User']", 'null': 'True', 'blank': 'True'})
+        }
+    }
+
+    complete_apps = ['suggest']
index 492f4ce..e58c9a8 100644 (file)
@@ -24,8 +24,8 @@ class Suggestion(models.Model):
 
 class PublishingSuggestion(models.Model):
     contact = models.CharField(_('contact'), blank=True, max_length=120)
-    books = models.TextField(_('books'))
-    audiobooks = models.TextField(_('audiobooks'))
+    books = models.TextField(_('books'), null=True, blank=True)
+    audiobooks = models.TextField(_('audiobooks'), null=True, blank=True)
     created_at = models.DateTimeField(_('creation date'), auto_now_add=True)
     ip = models.IPAddressField(_('IP address'))
     user = models.ForeignKey(User, blank=True, null=True)
diff --git a/apps/suggest/templates/publishing_suggest.html b/apps/suggest/templates/publishing_suggest.html
new file mode 100755 (executable)
index 0000000..a6ed283
--- /dev/null
@@ -0,0 +1,15 @@
+{% load i18n %}
+<h2>{% trans "Didn't find a book? Make a suggestion." %}</h2>
+<form id='suggest-publishing-form' action="{% url suggest_publishing %}" method="post" accept-charset="utf-8" class="cuteform">
+<ol>
+    <li><span class="error">{{ pubsuggest_form.contact.errors }}</span><label for="id_contact">{{ pubsuggest_form.contact.label }}</label> {{ pubsuggest_form.contact }}</li>
+
+    <li>{% trans "I'd like to find in WolneLektury.pl these…" %}</li>
+
+    <li><span class="error">{{ pubsuggest_form.books.errors }}</span><label for="id_books">{{ pubsuggest_form.books.label }}:</label> {{ pubsuggest_form.books }}</li>
+
+    <li><span class="error">{{ pubsuggest_form.audiobooks.errors }}</span><label for="id_audiobooks">{{ pubsuggest_form.audiobooks.label }}:</label> {{ pubsuggest_form.audiobooks }}</li>
+
+    <li><input type="submit" value="{% trans "Send report" %}"/></li>
+</ol>
+</form>
diff --git a/apps/suggest/templates/publishing_suggest_full.html b/apps/suggest/templates/publishing_suggest_full.html
new file mode 100755 (executable)
index 0000000..c5d8c28
--- /dev/null
@@ -0,0 +1,24 @@
+{% extends "base.html" %}
+{% load i18n %}
+
+{% block title %}Sugestia do planu wydawniczego w WolneLektury.pl{% endblock %}
+
+{% block metadescription %}Sugestia do planu wydawniczego.{% endblock %}
+
+{% block bodyid %}suggest-publishing{% endblock %}
+
+{% block body %}
+    <form action="{% url search %}" method="get" accept-charset="utf-8" id="search-form">
+        <p>{{ form.q }} <input type="submit" value="{% trans "Search" %}" /> <strong>{% trans "or" %}</strong> <a href="{% url main_page %}">{% trans "return to main page" %}</a></p>
+    </form>
+
+    <div id="books-list">
+    </div>
+
+    <div class="column-right block-form">
+        {% include "publishing_suggest.html" %}
+        {% if response_data.message %}
+            <p>{{ response_data.message }}</p>
+        {% endif %}
+    </div>
+{% endblock %}