Skip to content
Snippets Groups Projects
Unverified Commit daa51171 authored by Todd Dembrey's avatar Todd Dembrey Committed by GitHub
Browse files

Merge pull request #19 from OpenTechFund/feature/102-add-fund-page-model

Feature/102 add fund page model
parents ddb46b8f 7e61fed8
No related branches found
No related tags found
No related merge requests found
Showing
with 211 additions and 8 deletions
<article class="person">
<h2><a href="{% pageurl person %}">{{ person.first_name }} {{ person.last_name }}</a></h2>
{% if person.listing_summary or person.introduction %}
<p>{{ person.listing_summary|default:person.introduction }}</p>
{% endif %}
</article>
default_app_config = 'opentech.public.funds.apps.FundsConfig'
# from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class FundsConfig(AppConfig):
name = 'opentech.public.funds'
label = 'public_funds'
from wagtail.wagtailcore.blocks import StaticBlock
from opentech.public.utils.blocks import StoryBlock
class ProjectsBlock(StaticBlock):
class Meta:
icon = 'grip'
label = 'List of Projects funded'
admin_text = f'{label}: Will include the list of projects under this fund.'
template = 'public_funds/blocks/related_projects.html'
class ReviewersBlock(StaticBlock):
class Meta:
icon = 'grip'
label = 'List of fund Reviewers'
admin_text = f'{label}: Will include the list of reviewers for this fund.'
template = 'public_funds/blocks/related_reviewers.html'
class FundBlock(StoryBlock):
project_list = ProjectsBlock()
reviewer_list = ReviewersBlock()
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2018-01-09 11:20
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
import wagtail.wagtailcore.blocks
import wagtail.wagtailcore.fields
import wagtail.wagtaildocs.blocks
import wagtail.wagtailembeds.blocks
import wagtail.wagtailimages.blocks
import wagtail.wagtailsnippets.blocks
import opentech
class Migration(migrations.Migration):
initial = True
dependencies = [
('wagtailcore', '0040_page_draft_title'),
('images', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='FundIndex',
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')),
('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)),
('header_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage')),
('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')),
('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)),
('introduction', models.TextField(blank=True)),
('body', wagtail.wagtailcore.fields.StreamField((('heading', wagtail.wagtailcore.blocks.CharBlock(classname='full title', icon='title')), ('paragraph', wagtail.wagtailcore.blocks.RichTextBlock()), ('image', wagtail.wagtailcore.blocks.StructBlock((('image', wagtail.wagtailimages.blocks.ImageChooserBlock()), ('caption', wagtail.wagtailcore.blocks.CharBlock(required=False))))), ('quote', wagtail.wagtailcore.blocks.StructBlock((('quote', wagtail.wagtailcore.blocks.CharBlock(classname='title')), ('attribution', wagtail.wagtailcore.blocks.CharBlock(required=False)), ('job_title', wagtail.wagtailcore.blocks.CharBlock(required=False))))), ('embed', wagtail.wagtailembeds.blocks.EmbedBlock()), ('call_to_action', wagtail.wagtailsnippets.blocks.SnippetChooserBlock('utils.CallToActionSnippet', template='blocks/call_to_action_block.html')), ('document', wagtail.wagtailcore.blocks.StructBlock((('document', wagtail.wagtaildocs.blocks.DocumentChooserBlock()), ('title', wagtail.wagtailcore.blocks.CharBlock(required=False))))), ('project_list', opentech.public.funds.blocks.ProjectsBlock()), ('reviewer_list', opentech.public.funds.blocks.ReviewersBlock())))),
('fund_type', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='wagtailcore.Page')),
('header_image', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='+', to='images.CustomImage')),
('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),
),
]
from django.conf import settings
from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
from django.db import models
from wagtail.wagtailadmin.edit_handlers import (
FieldPanel,
PageChooserPanel,
StreamFieldPanel,
)
from wagtail.wagtailcore.fields import StreamField
from opentech.public.utils.models import BasePage
from .blocks import FundBlock
class FundPage(BasePage):
subpage_types = []
parent_page_types = ['FundIndex']
introduction = models.TextField(blank=True)
fund_type = models.ForeignKey(
'wagtailcore.Page',
blank=True,
null=True,
on_delete=models.SET_NULL,
related_name='+',
)
body = StreamField(FundBlock())
content_panels = BasePage.content_panels + [
FieldPanel('introduction'),
PageChooserPanel('fund_type', 'funds.FundType'),
StreamFieldPanel('body'),
]
class FundIndex(BasePage):
subpage_types = ['FundPage']
parent_page_types = ['home.HomePage']
def get_context(self, request, *args, **kwargs):
funds = FundPage.objects.live().public().descendant_of(self)
# Pagination
page = request.GET.get('page', 1)
paginator = Paginator(funds, settings.DEFAULT_PER_PAGE)
try:
news = paginator.page(page)
except PageNotAnInteger:
news = paginator.page(1)
except EmptyPage:
news = paginator.page(paginator.num_pages)
context = super().get_context(request, *args, **kwargs)
context.update(news=news)
return context
{% for project in page.projects %}
{% include "public_funds/includes/project_listing.html" with project=project %}
{% endfor %}
{% for person in page.reviewers %}
{% include "person/includes/person_listing.html" with person=person %}
{% endfor %}
{% extends "standardpages/index_page.html" %}
{% extends "base.html" %}
{% load wagtailcore_tags wagtailimages_tags navigation_tags static %}
{% block content %}
{% include "public_funds/includes/fund_apply_cta.html" with fund_type=page.fund_type.specific %}
<div class="wrapper wrapper--flex">
<section class="section section--main">
<h1>{{ page.title }}</h1>
<h5>{{ page.introduction }}</h5>
{% include_block page.body %}
</section>
</div>
{% include "public_funds/includes/fund_apply_cta.html" with fund_type=page.fund_type.specific %}
{% include "includes/relatedcontent.html" with related_pages=page.related_pages.all %}
{% endblock %}
{% load wagtailcore_tags i18n %}
<div class="wrapper wrapper--flex">
<div class="section section--apply-cta">
{% if fund_type.deadline %}
<div class="deadline">
{% trans "Next deadline" %}: {{ fund_type.deadline|date:"M j, Y" }}
</div>
<div class="apply-link">
<a class="button" href="{% pageurl fund_type %}">{% trans "Apply for this fund" %}</a>
</div>
{% else %}
<div class="deadline">
{% trans "CLOSED" %}
</div>
{% endif %}
</div>
</div>
<p>A PROJECT</p>
# from django.test import TestCase
# Create your tests here.
# from django.shortcuts import render
# Create your views here.
......@@ -13,13 +13,7 @@
<div class="container">
{% if people.paginator.count %}
{% for person in people %}
<article class="person">
<h2><a href="{% pageurl person %}">{{ person.first_name }} {{ person.last_name }}</a></h2>
{% if person.listing_summary or person.introduction %}
<p>{{ person.listing_summary|default:person.introduction }}</p>
{% endif %}
</article>
{% include "people/includes/person_listing.html" with person=person %}
{% endfor %}
{% include "includes/pagination.html" with paginator_page=people %}
......
......@@ -22,6 +22,7 @@ INSTALLED_APPS = [
'opentech.public.esi',
'opentech.public.forms',
'opentech.public.funds',
'opentech.public.home',
'opentech.public.navigation',
'opentech.public.news',
......
{% load wagtailcore_tags %}
{% for block in value %}
{% if block.block_type == 'heading' %}
<h2>{{ block.value }}</h2>
{% else %}
{{ block }}
{% include_block block %}
{% endif %}
{% endfor %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment