From f3a6a9f668406e5fc140d10b34721094ed15718d Mon Sep 17 00:00:00 2001 From: Radek Czajka Date: Thu, 6 Sep 2012 17:21:08 +0200 Subject: [PATCH] Cite: allow shifting and cites without books. --- apps/social/admin.py | 2 +- apps/social/locale/pl/LC_MESSAGES/django.mo | Bin 1822 -> 2083 bytes apps/social/locale/pl/LC_MESSAGES/django.po | 24 ++++-- ...d_cite_image_shift__chg_field_cite_book.py | 80 ++++++++++++++++++ apps/social/models.py | 4 +- apps/social/templates/social/cite_promo.html | 2 + .../templates/main_page.html | 6 +- 7 files changed, 107 insertions(+), 11 deletions(-) create mode 100644 apps/social/migrations/0003_auto__add_field_cite_image_shift__chg_field_cite_book.py 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 ae0df5a5da8461144cf8bcd97952e0b3d7a0bd91..7ce37b67f582f2ce20c59f41cf5a5a7860d17ca0 100644 GIT binary patch delta 842 zcmYk(ziSg=7{Kv2$u(-VwXK>e7JU&54k28jB6YIpP`3`^eoe0Sn&jSicOkS0nfwb5 zha$SzMG1nWAe181rgRq(x;RJ$(LpC&MEpLNEA%CAKJV}6x%YiO{9>g2dCYpEC>N*` z)C1}ywUgnGax1G;6K8P{-{NI_kH_%~p2Ht_7Be}eu3!NRID`DuJb!a|5A*m8Ev4FO zz28tTae#@}sT+8T{$}bPvO#@BNn{^o{Xyz?l!JevtoxIW|HW-SCd*)l@gAFG|3el} z6JI@|A%WiD8GMKGMIZ1Qe#1*RdaVB?HX8cVC<(0N34E3IH;^rAGwpBVF#WyMPbllZ zVxIWwCygQejdGyHy`IEDlzsu_zzLLBk*AU}-X}>uZ6?TBvR;D76P%|W7LG`6=deFJ zLQ8@XTb)ivCEGEo+=5({Br!^r+u=5ocLv3iE7cvyj%ViXyFuiYoth4pyv3-fJzqE6 zpzQilSkktxyN(~~$TW(2%C@x^>ID-;re4x_+(oBZi)84!Jz0t`=I&Z@M7)p-ts6J( znRq{UmBy6a%~+jmdp=lo!=~@`*2~vec!@RB- z{a~jX`0lc<22QKDR$2A>xiC{PH73Z#)K_+&($>pv7$x~Arx}?*RYR}$cz3Jn#9R5> MLye<3#Q*a8KXQhLy8r+H delta 594 zcmYk(J1j#{7{Kwb?X9*R)dy;5G{MkF4AP2_bQOt>#i)@E)T6i^F2hYaNn^V)vapbv z?rae0z+^DjPGXbT_z2x;wtWTQr3k~GDMbmBXY!ffEOhi6scnj z`_V=1Z(G!>hRJDhMHZ;&305(WWt_k!l0$A$7re(9 z`lkJWJo04PFBqr&YJ5i>|AjpA!%Or0;sAyt1nWzZiVn!2-a0oYNkS(N6aPz!hF-gF zEMYoy^O{&srHQo+5v1!DJ-yzb{vIvq9^K8x^dEH>_e;S{z`G2sc%Pv|YksLX=WSZk pS}FKvRx9Y;MAmY9<#xl7+R=$q-L32#>^ovts>in2j$Lmz\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 %}
-- 2.20.1