From: Radek Czajka Date: Thu, 6 Sep 2012 15:21:08 +0000 (+0200) Subject: Cite: allow shifting and cites without books. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/f3a6a9f668406e5fc140d10b34721094ed15718d?ds=inline;hp=--cc Cite: allow shifting and cites without books. --- f3a6a9f668406e5fc140d10b34721094ed15718d diff --git a/apps/social/admin.py b/apps/social/admin.py index bc0ac0b75..01b4c6578 100755 --- a/apps/social/admin.py +++ b/apps/social/admin.py @@ -14,7 +14,7 @@ class CiteAdmin(admin.ModelAdmin): (None, {'fields': ('book', 'text', 'small', 'vip', 'link', 'sticky')}), ( _('Background'), - {'fields': ('image', 'image_title', 'image_author', + {'fields': ('image', 'image_shift', 'image_title', 'image_author', 'image_link', 'image_license', 'image_license_link') } ) diff --git a/apps/social/locale/pl/LC_MESSAGES/django.mo b/apps/social/locale/pl/LC_MESSAGES/django.mo index ae0df5a5d..7ce37b67f 100644 Binary files a/apps/social/locale/pl/LC_MESSAGES/django.mo and b/apps/social/locale/pl/LC_MESSAGES/django.mo differ diff --git a/apps/social/locale/pl/LC_MESSAGES/django.po b/apps/social/locale/pl/LC_MESSAGES/django.po index fa7b35d3e..da3bf79d8 100644 --- a/apps/social/locale/pl/LC_MESSAGES/django.po +++ b/apps/social/locale/pl/LC_MESSAGES/django.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2012-09-06 15:41+0200\n" -"PO-Revision-Date: 2012-09-06 15:43+0100\n" +"POT-Creation-Date: 2012-09-06 17:09+0200\n" +"PO-Revision-Date: 2012-09-06 17:10+0100\n" "Last-Translator: Radek Czajka \n" "Language-Team: LANGUAGE \n" "Language: \n" @@ -55,7 +55,7 @@ msgid "VIP" msgstr "VIP" #: models.py:18 -#: models.py:28 +#: models.py:30 msgid "link" msgstr "odnośnik" @@ -68,26 +68,34 @@ msgid "Sticky cites will take precedense." msgstr "Przyklejone cytaty mają pierwszeństwo." #: models.py:24 +msgid "shift" +msgstr "przesunięcie" + +#: models.py:25 +msgid "Vertical shift, in percents. 0 means top, 100 is bottom. Default is 50%." +msgstr "Przesunięcie w pionie, w procentach. 0 to wyrównanie do górnej krawędzi, 100 do dolnej. Domyślne jest 50%." + +#: models.py:26 msgid "title" msgstr "tytuł" -#: models.py:26 +#: models.py:28 msgid "author" msgstr "autor" -#: models.py:29 +#: models.py:31 msgid "license name" msgstr "nazwa licencji" -#: models.py:31 +#: models.py:33 msgid "license link" msgstr "adres licencji" -#: models.py:35 +#: models.py:37 msgid "cite" msgstr "cytat" -#: models.py:36 +#: models.py:38 msgid "cites" msgstr "cytaty" diff --git a/apps/social/migrations/0003_auto__add_field_cite_image_shift__chg_field_cite_book.py b/apps/social/migrations/0003_auto__add_field_cite_image_shift__chg_field_cite_book.py new file mode 100644 index 000000000..3c04611c6 --- /dev/null +++ b/apps/social/migrations/0003_auto__add_field_cite_image_shift__chg_field_cite_book.py @@ -0,0 +1,80 @@ +# -*- coding: 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 field 'Cite.image_shift' + db.add_column('social_cite', 'image_shift', + self.gf('django.db.models.fields.IntegerField')(null=True, blank=True), + keep_default=False) + + # Adding index on 'Cite', fields ['sticky'] + db.create_index('social_cite', ['sticky']) + + + # Changing field 'Cite.book' + db.alter_column('social_cite', 'book_id', self.gf('django.db.models.fields.related.ForeignKey')(to=orm['catalogue.Book'], null=True)) + + def backwards(self, orm): + # Removing index on 'Cite', fields ['sticky'] + db.delete_index('social_cite', ['sticky']) + + # Deleting field 'Cite.image_shift' + db.delete_column('social_cite', 'image_shift') + + + # Changing field 'Cite.book' + db.alter_column('social_cite', 'book_id', self.gf('django.db.models.fields.related.ForeignKey')(default=0, to=orm['catalogue.Book'])) + + models = { + 'catalogue.book': { + 'Meta': {'ordering': "('sort_key',)", 'object_name': 'Book'}, + '_related_info': ('jsonfield.fields.JSONField', [], {'null': 'True', 'blank': 'True'}), + 'changed_at': ('django.db.models.fields.DateTimeField', [], {'auto_now': 'True', 'db_index': 'True', 'blank': 'True'}), + 'common_slug': ('django.db.models.fields.SlugField', [], {'max_length': '120'}), + 'cover': ('catalogue.fields.EbookField', [], {'max_length': '100', 'null': 'True', 'format_name': "'cover'", 'blank': 'True'}), + 'created_at': ('django.db.models.fields.DateTimeField', [], {'auto_now_add': 'True', 'db_index': 'True', 'blank': 'True'}), + 'description': ('django.db.models.fields.TextField', [], {'blank': 'True'}), + 'epub_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'epub'", 'blank': 'True'}), + 'extra_info': ('jsonfield.fields.JSONField', [], {'default': "'{}'"}), + 'fb2_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'fb2'", 'blank': 'True'}), + 'gazeta_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}), + 'html_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'html'", 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'language': ('django.db.models.fields.CharField', [], {'default': "'pol'", 'max_length': '3', 'db_index': 'True'}), + 'mobi_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'mobi'", 'blank': 'True'}), + 'parent': ('django.db.models.fields.related.ForeignKey', [], {'blank': 'True', 'related_name': "'children'", 'null': 'True', 'to': "orm['catalogue.Book']"}), + 'parent_number': ('django.db.models.fields.IntegerField', [], {'default': '0'}), + 'pdf_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'pdf'", 'blank': 'True'}), + 'slug': ('django.db.models.fields.SlugField', [], {'unique': 'True', 'max_length': '120'}), + 'sort_key': ('django.db.models.fields.CharField', [], {'max_length': '120', 'db_index': 'True'}), + 'title': ('django.db.models.fields.CharField', [], {'max_length': '120'}), + 'txt_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'txt'", 'blank': 'True'}), + 'wiki_link': ('django.db.models.fields.CharField', [], {'max_length': '240', 'blank': 'True'}), + 'xml_file': ('catalogue.fields.EbookField', [], {'default': "''", 'max_length': '100', 'format_name': "'xml'", 'blank': 'True'}) + }, + 'social.cite': { + 'Meta': {'ordering': "('vip', 'text')", 'object_name': 'Cite'}, + 'book': ('django.db.models.fields.related.ForeignKey', [], {'to': "orm['catalogue.Book']", 'null': 'True', 'blank': 'True'}), + 'id': ('django.db.models.fields.AutoField', [], {'primary_key': 'True'}), + 'image': ('django.db.models.fields.files.ImageField', [], {'max_length': '100', 'null': 'True', 'blank': 'True'}), + 'image_author': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'image_license': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'image_license_link': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), + 'image_link': ('django.db.models.fields.URLField', [], {'max_length': '200', 'null': 'True', 'blank': 'True'}), + 'image_shift': ('django.db.models.fields.IntegerField', [], {'null': 'True', 'blank': 'True'}), + 'image_title': ('django.db.models.fields.CharField', [], {'max_length': '255', 'null': 'True', 'blank': 'True'}), + 'link': ('django.db.models.fields.URLField', [], {'max_length': '200'}), + 'small': ('django.db.models.fields.BooleanField', [], {'default': 'False'}), + 'sticky': ('django.db.models.fields.BooleanField', [], {'default': 'False', 'db_index': 'True'}), + 'text': ('django.db.models.fields.TextField', [], {}), + 'vip': ('django.db.models.fields.CharField', [], {'max_length': '128', 'null': 'True', 'blank': 'True'}) + } + } + + complete_apps = ['social'] \ No newline at end of file diff --git a/apps/social/models.py b/apps/social/models.py index e1c7e379a..835773de1 100644 --- a/apps/social/models.py +++ b/apps/social/models.py @@ -10,7 +10,7 @@ from catalogue.models import Book class Cite(models.Model): - book = models.ForeignKey(Book, verbose_name=_('book')) + book = models.ForeignKey(Book, verbose_name=_('book'), null=True, blank=True) text = models.TextField(_('text')) small = models.BooleanField(_('small'), default=False, help_text=_('Make this cite display smaller.')) @@ -21,6 +21,8 @@ class Cite(models.Model): image = models.ImageField(_('image'), upload_to='social/cite', null=True, blank=True) + image_shift = models.IntegerField(_('shift'), null=True, blank=True, + help_text=_(u'Vertical shift, in percents. 0 means top, 100 is bottom. Default is 50%.')) image_title = models.CharField(_('title'), max_length=255, null=True, blank=True) image_author = models.CharField(_('author'), diff --git a/apps/social/templates/social/cite_promo.html b/apps/social/templates/social/cite_promo.html index 0554d23af..c3a73e89a 100755 --- a/apps/social/templates/social/cite_promo.html +++ b/apps/social/templates/social/cite_promo.html @@ -8,7 +8,9 @@
{{ cite.text|linebreaksbr|safe }}
+ {% if cite.book %}

{{ cite.book.pretty_title }}

+ {% endif %} {% else %} {% if fallback %} diff --git a/apps/wolnelektury_core/templates/main_page.html b/apps/wolnelektury_core/templates/main_page.html index 9932b677b..f4ffef1ec 100755 --- a/apps/wolnelektury_core/templates/main_page.html +++ b/apps/wolnelektury_core/templates/main_page.html @@ -7,7 +7,11 @@ {% block ogtitle %}{% trans "Wolne Lektury internet library" %}{% endblock %} {% block body %} -
+
{% render_cite cite %}