From 237dc400a6995da6d8a439d4abb173eecbe74a01 Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Thu, 9 Jun 2011 14:12:57 +0200 Subject: [PATCH] suggestions: fixes and missing files --- apps/suggest/forms.py | 11 ++- apps/suggest/locale/pl/LC_MESSAGES/django.mo | Bin 1901 -> 2000 bytes apps/suggest/locale/pl/LC_MESSAGES/django.po | 18 ++-- .../0002_auto__add_publishingsuggestion.py | 88 ++++++++++++++++++ apps/suggest/models.py | 4 +- .../suggest/templates/publishing_suggest.html | 15 +++ .../templates/publishing_suggest_full.html | 24 +++++ 7 files changed, 149 insertions(+), 11 deletions(-) create mode 100644 apps/suggest/migrations/0002_auto__add_publishingsuggestion.py create mode 100755 apps/suggest/templates/publishing_suggest.html create mode 100755 apps/suggest/templates/publishing_suggest_full.html diff --git a/apps/suggest/forms.py b/apps/suggest/forms.py index 5c034e654..76170e1c6 100644 --- a/apps/suggest/forms.py +++ b/apps/suggest/forms.py @@ -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'] diff --git a/apps/suggest/locale/pl/LC_MESSAGES/django.mo b/apps/suggest/locale/pl/LC_MESSAGES/django.mo index 2e3e5d7e599439e7805eb8f2f5221913ad17f20b..3990bea84d438ccad42a092ccb660806c93ec1fd 100644 GIT binary patch delta 630 zcmXZYJ1hi27{Kva*8BY|Jf{$aC{BbzbQDxXBTBg)>|vMN6FHHHM~Fmo5k#esC?u*& zBpMB(ks#4%lq!N!MB@LQon-bmv%BB-&3x~r4`nMamG+)u)G`~Gcg#lSvc-e(iFx>i zMfi=an3JVcJGNsXj$s5H)VPOrc#e|q5heZur|}1ylv+`f+5ZVPF^3N+l!6CXf=4KU zXIO(5D2KgADf}9K|H4fU_lpw0K{6Y6unSW-h_{%J6}d|FQeV}v=-|aDN(Z))lc^J| z!W;DP8S8O?>{8gl0`yS|CV7qujoW3q5LcfhC(^y!X18P(=@I+MiVVm7VCni$FDB>A&6?+4 jZ|SJ7z46$r=bD&~8OQVWl1?O}Q+nL&getOru_u9S{zVpFH$=w;oBHFfND5M z_D6WlVO~-BdlYl%V;$Sr!h4*;G45c5o(Z^3=I=ziIM2orcJLgR@e9?^Qhge;s77U` z0#;BBtEl{1ViVQSPdrA>X?TFRP6_jeOe(IS\n" "Language-Team: LANGUAGE \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 index 000000000..8a52a7fbb --- /dev/null +++ b/apps/suggest/migrations/0002_auto__add_publishingsuggestion.py @@ -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'] diff --git a/apps/suggest/models.py b/apps/suggest/models.py index 492f4cecb..e58c9a805 100644 --- a/apps/suggest/models.py +++ b/apps/suggest/models.py @@ -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 index 000000000..a6ed283d5 --- /dev/null +++ b/apps/suggest/templates/publishing_suggest.html @@ -0,0 +1,15 @@ +{% load i18n %} +

{% trans "Didn't find a book? Make a suggestion." %}

+
+
    +
  1. {{ pubsuggest_form.contact.errors }} {{ pubsuggest_form.contact }}
  2. + +
  3. {% trans "I'd like to find in WolneLektury.pl these…" %}
  4. + +
  5. {{ pubsuggest_form.books.errors }} {{ pubsuggest_form.books }}
  6. + +
  7. {{ pubsuggest_form.audiobooks.errors }} {{ pubsuggest_form.audiobooks }}
  8. + +
  9. +
+
diff --git a/apps/suggest/templates/publishing_suggest_full.html b/apps/suggest/templates/publishing_suggest_full.html new file mode 100755 index 000000000..c5d8c2833 --- /dev/null +++ b/apps/suggest/templates/publishing_suggest_full.html @@ -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.q }} {% trans "or" %} {% trans "return to main page" %}

+
+ +
+
+ +
+ {% include "publishing_suggest.html" %} + {% if response_data.message %} +

{{ response_data.message }}

+ {% endif %} +
+{% endblock %} -- 2.20.1