diff --git a/opentech/apply/admin.py b/opentech/apply/admin.py index 7e15ae65697b092262159a9fa0806108635f8bf3..4185d360e9a725a190ddfd9b8cce8aeb0df64cc3 100644 --- a/opentech/apply/admin.py +++ b/opentech/apply/admin.py @@ -1,18 +1,3 @@ -from wagtail.contrib.modeladmin.options import ModelAdmin, ModelAdminGroup +# from django.contrib import admin -from .models import Fund - - -class FundModelAdmin(ModelAdmin): - model = Fund - menu_icon = 'site' - list_display = ('name',) - list_filter = ('name',) - search_fields = ('name',) - - -class ApplyAdminGroup(ModelAdminGroup): - menu_label = 'Apply' - menu_icon = 'folder-open-inverse' - menu_order = 200 - items = (FundModelAdmin,) +# Register your models here. diff --git a/opentech/apply/migrations/0001_initial.py b/opentech/apply/migrations/0001_initial.py index cc00366f19740d2f37fe26e0670675438858bb42..916e8f8f55b3e9c9cf2ba256780fd0653be8b08f 100644 --- a/opentech/apply/migrations/0001_initial.py +++ b/opentech/apply/migrations/0001_initial.py @@ -1,8 +1,9 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.11.7 on 2017-12-19 09:33 +# Generated by Django 1.11.7 on 2017-12-22 09:28 from __future__ import unicode_literals from django.db import migrations, models +import django.db.models.deletion class Migration(migrations.Migration): @@ -10,14 +11,35 @@ class Migration(migrations.Migration): initial = True dependencies = [ + ('images', '0001_initial'), + ('wagtailcore', '0040_page_draft_title'), ] operations = [ migrations.CreateModel( - name='Fund', + name='ApplyHomePage', fields=[ - ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), - ('name', models.CharField(max_length=60)), + ('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')), + ('social_text', models.CharField(blank=True, max_length=255)), + ('listing_title', models.CharField(blank=True, help_text='Override the page title used when this page appears in listings', max_length=255)), + ('listing_summary', models.CharField(blank=True, help_text="The text summary used when this page appears in listings. It's also used as the description for search engines if the 'Search description' field above is not defined.", max_length=255)), + ('strapline', models.CharField(blank=True, max_length=255)), + ('listing_image', models.ForeignKey(blank=True, help_text='Choose the image you wish to be displayed when this page appears in listings', null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage')), + ('social_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage')), ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page', models.Model), + ), + migrations.CreateModel( + name='FundPage', + fields=[ + ('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')), + ], + options={ + 'abstract': False, + }, + bases=('wagtailcore.page',), ), ] diff --git a/opentech/apply/migrations/0002_create_apply_homepage.py b/opentech/apply/migrations/0002_create_apply_homepage.py new file mode 100644 index 0000000000000000000000000000000000000000..d6bce1aed6dff0bad595c239b514b8b96ba27603 --- /dev/null +++ b/opentech/apply/migrations/0002_create_apply_homepage.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import migrations + + +def create_homepage(apps, schema_editor): + # Get models + ContentType = apps.get_model('contenttypes.ContentType') + Page = apps.get_model('wagtailcore.Page') + Site = apps.get_model('wagtailcore.Site') + ApplyHomePage = apps.get_model('apply.ApplyHomePage') + + # Create content type for homepage model + homepage_content_type, created = ContentType.objects.get_or_create( + model='applyhomepage', app_label='apply') + + # Create a new homepage + applyhomepage = ApplyHomePage.objects.create( + title="ApplyHomepage", + draft_title="ApplyHomepage", + slug='apply', + content_type=homepage_content_type, + path='00010002', + depth=2, + numchild=0, + url_path='/apply/', + ) + + # Create a site with the new homepage set as the root + Site.objects.create( + hostname='apply.localhost', root_page=applyhomepage, is_default_site=True) + + +class Migration(migrations.Migration): + + dependencies = [ + ('apply', '0001_initial'), + ('home', '0001_initial'), + ] + + operations = [ + migrations.RunPython(create_homepage), + ] diff --git a/opentech/apply/models.py b/opentech/apply/models.py index 8b0a89a1bed3b9fc3b2e5557c8140ae15baf2148..d2347072906ed1d6ee3d7897a3a5f945f1c855d6 100644 --- a/opentech/apply/models.py +++ b/opentech/apply/models.py @@ -1,5 +1,32 @@ from django.db import models +from wagtail.wagtailadmin.edit_handlers import FieldPanel +from wagtail.wagtailcore.models import Page +from wagtail.wagtailsearch import index +from wagtail.wagtailsnippets.edit_handlers import SnippetChooserPanel +from opentech.utils.models import SocialFields, ListingFields -class Fund(models.Model): - name = models.CharField(max_length=60) + +class ApplyHomePage(Page, SocialFields, ListingFields): + # Only allow creating HomePages at the root level + parent_page_types = ['wagtailcore.Page'] + + strapline = models.CharField(blank=True, max_length=255) + + search_fields = Page.search_fields + [ + index.SearchField('strapline'), + ] + + content_panels = Page.content_panels + [ + FieldPanel('strapline'), + ] + + promote_panels = ( + Page.promote_panels + + SocialFields.promote_panels + + ListingFields.promote_panels + ) + + +class FundPage(Page): + parent_page_types = [ApplyHomePage] diff --git a/opentech/apply/wagtail_hooks.py b/opentech/apply/wagtail_hooks.py deleted file mode 100644 index d9ad3c978b7ba35f8d762f27cde028290befa828..0000000000000000000000000000000000000000 --- a/opentech/apply/wagtail_hooks.py +++ /dev/null @@ -1,6 +0,0 @@ -from wagtail.contrib.modeladmin.options import modeladmin_register - -from .admin import ApplyAdminGroup - - -modeladmin_register(ApplyAdminGroup) diff --git a/opentech/settings/dev.py b/opentech/settings/dev.py index fb9385a426ff3ddb8dbf94ccba325c1f5f50f41e..388ccda6a9b53ef682076fb6ce0ab7c87c089521 100644 --- a/opentech/settings/dev.py +++ b/opentech/settings/dev.py @@ -8,6 +8,8 @@ SECRET_KEY = 'CHANGEME!!!' INTERNAL_IPS = ('127.0.0.1', '10.0.2.2') +ALLOWED_HOSTS= ['apply.localhost', 'localhost'] + BASE_URL = 'http://localhost:8000' EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'