From 5d99514c7d5de3336d4d6312150cca9bbe613587 Mon Sep 17 00:00:00 2001 From: Jake Howard Date: Mon, 28 Nov 2016 20:21:56 +0000 Subject: [PATCH] rename fields to fix stuff --- project/projects/migrations/0001_initial.py | 9 ++++----- project/projects/models.py | 10 ++++++---- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/project/projects/migrations/0001_initial.py b/project/projects/migrations/0001_initial.py index 34c783a..d79d878 100644 --- a/project/projects/migrations/0001_initial.py +++ b/project/projects/migrations/0001_initial.py @@ -1,10 +1,9 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.10.3 on 2016-11-28 18:42 +# Generated by Django 1.10.3 on 2016-11-28 20:04 from __future__ import unicode_literals from django.db import migrations, models import django.db.models.deletion -import project.projects.models import wagtail.wagtailcore.fields @@ -13,8 +12,8 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('wagtailcore', '0030_index_on_pagerevision_created_at'), ('wagtaildocs', '0007_merge'), + ('wagtailcore', '0030_index_on_pagerevision_created_at'), ('wagtailimages', '0015_fill_filter_spec_field'), ] @@ -25,8 +24,8 @@ class Migration(migrations.Migration): ('page_ptr', models.OneToOneField(auto_created=True, on_delete=django.db.models.deletion.CASCADE, parent_link=True, primary_key=True, serialize=False, to='wagtailcore.Page')), ('summary', models.CharField(max_length=500)), ('body', wagtail.wagtailcore.fields.RichTextField()), - ('url', models.URLField(blank=True, validators=[project.projects.models.validate_url])), - ('download_url', models.URLField(blank=True, validators=[project.projects.models.validate_url])), + ('project_url', models.URLField(blank=True)), + ('download_url', models.URLField(blank=True)), ('asset', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtaildocs.Document')), ('main_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailimages.Image')), ], diff --git a/project/projects/models.py b/project/projects/models.py index 1c77099..71f81bf 100644 --- a/project/projects/models.py +++ b/project/projects/models.py @@ -33,8 +33,8 @@ class ProjectPage(Entity): ) summary = models.CharField(max_length=500) body = RichTextField() - url = models.URLField(validators=[validate_url], blank=True) - download_url = models.URLField(validators=[validate_url], blank=True) + project_url = models.URLField(blank=True) + download_url = models.URLField(blank=True) asset = models.ForeignKey( 'wagtaildocs.Document', null=True, @@ -43,8 +43,10 @@ class ProjectPage(Entity): related_name='+' ) + def get_download_url(self): + return self.download_url or self.asset.url + search_fields = Page.search_fields + [ - index.SearchField('intro'), index.SearchField('body'), ] @@ -52,7 +54,7 @@ class ProjectPage(Entity): ImageChooserPanel('main_image'), FieldPanel('summary'), FieldPanel('body'), - FieldPanel('url'), FieldPanel('download_url'), + FieldPanel('project_url'), DocumentChooserPanel('asset') ]