From: Emilie Date: Tue, 5 Jul 2016 16:28:35 +0000 (+0200) Subject: Task #59: Basic Page - adding image X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=b4a1fffe48f2bef4bb21c957702b090c994dab57;p=mezzo.git Task #59: Basic Page - adding image --- diff --git a/app/custom/migrations/0003_auto_20160705_1702.py b/app/custom/migrations/0003_auto_20160705_1702.py new file mode 100644 index 00000000..260418e5 --- /dev/null +++ b/app/custom/migrations/0003_auto_20160705_1702.py @@ -0,0 +1,30 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-07-05 15:02 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('custom', '0002_auto_20160705_1559'), + ] + + operations = [ + migrations.AlterField( + model_name='basicpage', + name='sub_title', + field=models.CharField(blank=True, max_length=1000, verbose_name='sub title'), + ), + migrations.AlterField( + model_name='basicpage', + name='sub_title_en', + field=models.CharField(blank=True, max_length=1000, null=True, verbose_name='sub title'), + ), + migrations.AlterField( + model_name='basicpage', + name='sub_title_fr', + field=models.CharField(blank=True, max_length=1000, null=True, verbose_name='sub title'), + ), + ] diff --git a/app/custom/migrations/0004_auto_20160705_1810.py b/app/custom/migrations/0004_auto_20160705_1810.py new file mode 100644 index 00000000..d3e93e97 --- /dev/null +++ b/app/custom/migrations/0004_auto_20160705_1810.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.7 on 2016-07-05 16:10 +from __future__ import unicode_literals + +from django.db import migrations, models +import mezzanine.core.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('custom', '0003_auto_20160705_1702'), + ] + + operations = [ + migrations.AddField( + model_name='basicpage', + name='photo', + field=mezzanine.core.fields.FileField(blank=True, max_length=1024, verbose_name='photo'), + ), + migrations.AddField( + model_name='basicpage', + name='photo_alignment', + field=models.CharField(blank=True, choices=[('left', 'left'), ('right', 'right')], default='left', max_length=32, verbose_name='photo alignment'), + ), + migrations.AddField( + model_name='basicpage', + name='photo_credits', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='photo credits'), + ), + migrations.AddField( + model_name='basicpage', + name='photo_description', + field=models.TextField(blank=True, verbose_name='photo description'), + ), + migrations.AddField( + model_name='basicpage', + name='photo_featured', + field=mezzanine.core.fields.FileField(blank=True, max_length=1024, verbose_name='photo featured'), + ), + migrations.AddField( + model_name='basicpage', + name='photo_featured_credits', + field=models.CharField(blank=True, max_length=255, null=True, verbose_name='photo featured credits'), + ), + ] diff --git a/app/custom/models.py b/app/custom/models.py index 5be18acc..32dceb47 100644 --- a/app/custom/models.py +++ b/app/custom/models.py @@ -1,13 +1,10 @@ from django.db import models from django.utils.translation import ugettext_lazy as _ from django.core.urlresolvers import reverse, reverse_lazy -#from mezzanine.core.models import Displayable from mezzanine.pages.models import Page, RichText -# Create your models here. -# class DisplayableCustom(Displayable): -# -# sub_title = models.TextField(_('sub_title'), blank=True) +from mezzanine.core.fields import RichTextField, OrderField, FileField +ALIGNMENT_CHOICES = (('left', _('left')), ('right', _('right'))) class SubTitle(models.Model): @@ -19,4 +16,11 @@ class SubTitle(models.Model): class BasicPage(Page, RichText): - sub_title = models.TextField(_('sub title'), blank=True) + sub_title = models.CharField(_('sub title'), blank=True, max_length=1000) + # description = models.TextField(_('description'), blank=True) + photo = FileField(_('photo'), upload_to='images/photos', max_length=1024, blank=True, format="Image") + photo_credits = models.CharField(_('photo credits'), max_length=255, blank=True, null=True) + photo_alignment = models.CharField(_('photo alignment'), choices=ALIGNMENT_CHOICES, max_length=32, default="left", blank=True) + photo_description = models.TextField(_('photo description'), blank=True) + photo_featured = FileField(_('photo featured'), upload_to='images/photos', max_length=1024, blank=True, format="Image") + photo_featured_credits = models.CharField(_('photo featured credits'), max_length=255, blank=True, null=True) diff --git a/app/custom/translations.py b/app/custom/translations.py index bd3f3db3..1d0d1bc9 100644 --- a/app/custom/translations.py +++ b/app/custom/translations.py @@ -1,24 +1,3 @@ -# from modeltranslation.translator import translator, register, TranslationOptions -# from mezzanine.pages.models import Page, RichTextPage, Link -# from mezzanine.pages.translation import TranslatedRichText -# from mezzanine.forms.models import Form -# from mezzanine.galleries.models import Gallery -# -# # @register(RichText) -# # class RichTextTranslationOptions(TranslatedRichText): -# # -# # fields = ('sub_title') -# -# # print(RichTextPage._meta.get_fields()) -# # print('///////////////////////////') -# class TranslatedInjectedRichText(TranslatedRichText): -# fields = ('sub_title',) -# -# translator.unregister(RichTextPage) -# -# translator.register(RichTextPage, TranslatedInjectedRichText) - - from modeltranslation.translator import translator, register, TranslationOptions from mezzanine.pages.models import Page, RichText from mezzanine.pages.translation import TranslatedRichText