Skip to content
Snippets Groups Projects
Commit 217be33e authored by Parbhat Puri's avatar Parbhat Puri Committed by Fredrik Jonsson
Browse files

Open Call index page

parent a281060d
No related branches found
No related tags found
No related merge requests found
# Generated by Django 2.0.9 on 2019-03-26 12:12
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('images', '0003_customimage_drupal_id'),
('wagtailcore', '0040_page_draft_title'),
('public_funds', '0010_correct_related_page_required'),
]
operations = [
migrations.CreateModel(
name='OpenCallIndexPage',
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)),
('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),
),
]
......@@ -20,6 +20,8 @@ from wagtail.core.fields import StreamField
from wagtail.images.edit_handlers import ImageChooserPanel
from wagtail.search import index
from opentech.apply.funds.models import ApplicationSubmission
from opentech.apply.funds.workflow import OPEN_CALL_PHASES
from opentech.public.utils.models import (
BasePage,
RelatedPage,
......@@ -237,3 +239,36 @@ class LabIndex(BasePage):
context = super().get_context(request, *args, **kwargs)
context.update(subpages=labs)
return context
class OpenCallIndexPage(BasePage):
subpage_types = []
parent_page_types = ['home.HomePage']
introduction = models.TextField(blank=True)
content_panels = BasePage.content_panels + [
FieldPanel('introduction'),
]
search_fields = BasePage.search_fields + [
index.SearchField('introduction'),
]
def get_context(self, request, *args, **kwargs):
context = super().get_context(request, *args, **kwargs)
open_call_submissions = ApplicationSubmission.objects.filter(status__in=OPEN_CALL_PHASES)
per_page = settings.DEFAULT_PER_PAGE
page_number = request.GET.get('page')
paginator = Paginator(open_call_submissions, per_page)
try:
open_call_submissions = paginator.page(page_number)
except PageNotAnInteger:
open_call_submissions = paginator.page(1)
except EmptyPage:
open_call_submissions = paginator.page(paginator.num_pages)
context['open_call_submissions'] = open_call_submissions
return context
{% extends "base.html" %}
{% load wagtailcore_tags wagtailimages_tags %}
{% block content %}
<div class="wrapper wrapper--small wrapper--inner-space-medium">
{% if page.introduction %}
<h4 class="heading heading--listings-introduction">{{ page.introduction }}</h4>
{% endif %}
<div class="wrapper wrapper--listings">
{% if open_call_submissions %}
{% for submission in open_call_submissions %}
<div class="listing listing--not-a-link">
<h4 class="listing__title">{{ submission.title }}</h4>
<a class="listing__button" href="{% pageurl submission.page %}">Build it</a>
</div>
{% endfor %}
{% include "includes/pagination.html" with paginator_page=open_call_submissions %}
{% else %}
{# no items on this page #}
{% endif %}
</div>
</div>
{% endblock %}
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