]> git.parisson.com Git - mezzo.git/commitdiff
Make related block and image fully generic
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 24 Aug 2016 13:51:02 +0000 (15:51 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Wed, 24 Aug 2016 13:51:02 +0000 (15:51 +0200)
app/organization/network/models.py
app/organization/pages/migrations/0003_auto_20160824_1550.py [new file with mode: 0644]
app/organization/pages/models.py
app/settings.py
app/templates/pages/custompage.html
app/templates/pages/includes/page_card.html

index 7c0893248586e0bab7e0a85ea79ce1e1c2569321..bad30084693b4b3ca988f1b9b530a07b42bd9990 100644 (file)
@@ -19,7 +19,6 @@ from mezzanine.pages.models import Page
 from mezzanine.core.models import RichText, Displayable, Slugged
 from mezzanine.core.fields import RichTextField, OrderField, FileField
 from mezzanine.utils.models import AdminThumbMixin, upload_to
-from mezzanine.galleries.models import BaseGallery
 
 from organization.core.models import *
 
diff --git a/app/organization/pages/migrations/0003_auto_20160824_1550.py b/app/organization/pages/migrations/0003_auto_20160824_1550.py
new file mode 100644 (file)
index 0000000..4eac454
--- /dev/null
@@ -0,0 +1,26 @@
+# -*- coding: utf-8 -*-
+# Generated by Django 1.9.7 on 2016-08-24 13:50
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('organization-pages', '0002_auto_20160824_1454'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='pageblock',
+            name='page',
+            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='blocks', to='pages.Page', verbose_name='page'),
+        ),
+        migrations.AlterField(
+            model_name='pageimage',
+            name='page',
+            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='images', to='pages.Page', verbose_name='page'),
+        ),
+    ]
index a8643fa3074e89947973d5f16ecd82fbae98769f..e409b913bc76058e58202f3f912a04758e313b24 100644 (file)
@@ -13,7 +13,7 @@ class CustomPage(Page, SubTitled, RichText):
 
 class PageBlock(Block):
 
-    page = models.ForeignKey(Page, verbose_name=_('page'), related_name='page_blocks', blank=True, null=True, on_delete=models.SET_NULL)
+    page = models.ForeignKey(Page, verbose_name=_('page'), related_name='blocks', blank=True, null=True, on_delete=models.SET_NULL)
 
     class Meta:
         verbose_name = _("block")
@@ -23,7 +23,7 @@ class PageBlock(Block):
 
 class PageImage(Image):
 
-    page = models.ForeignKey(Page, verbose_name=_('page'), related_name='page_images', blank=True, null=True, on_delete=models.SET_NULL)
+    page = models.ForeignKey(Page, verbose_name=_('page'), related_name='images', blank=True, null=True, on_delete=models.SET_NULL)
 
     class Meta:
         verbose_name = _("image")
index 15ccf8ac76ce6eb1e3ccb76cfc123b78951274fc..5bc3977aa594430411337e91ced00e7a34e331ff 100644 (file)
@@ -216,7 +216,7 @@ INSTALLED_APPS = [
     "mezzanine.pages",
     "mezzanine.blog",
     "mezzanine.forms",
-    "mezzanine.galleries",
+    "mezzanine.galleries",
     "mezzanine.twitter",
     "mezzanine.accounts",
     # "mezzanine.mobile",
index 4e37acf123be9feca1c12a67db80e890a8c3c786..f71622a1a61855b7cabf3901bb7bf3c2b3a6c50a 100644 (file)
 {% endblock %}
 
 {% block page_sub_content %}
-    {% if page.custompage.page_blocks.all %}
+    {% if page.custompage.blocks.all %}
         <div class="white-bg">
             <div class="container">
                 <div class="row">
                     <div class="col-sm-12">
                         <hr class="mt0" />
-                        {% for pageblock in page.custompage.page_blocks.all %}
+                        {% for pageblock in page.custompage.blocks.all %}
                             <div class="row" data-summary-content>
                                 <div class="col-sm-9 col-sm-push-3 col-lg-8 col-lg-push-2 white-bg">
                                     {% if not forloop.first and pageblock.with_separator %}
index b7ef60aa1a96db1bf19eb91f0bca4f4340970ef1..8a0e842c527d3211cf8f407ccb897f534e0b1bcf 100644 (file)
@@ -1,7 +1,7 @@
 {% load mezzanine_tags organization_tags %}
 <a href="{{ object.get_absolute_url }}" title="{{ object.title }}" class="page-box">
     <div class="page-box__image">
-      {% with object.page_images.all|get_type:'card' as image %}
+      {% with object.images.all|get_type:'card' as image %}
         <img src="{{ MEDIA_URL }}{% thumbnail image.file 900 400 %}" />
       {% endwith %}
     </div>