Skip to content
Snippets Groups Projects
Commit 8eb3343f authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Add rounds model which pulls in its parents form

parent 01fab416
No related branches found
No related tags found
No related merge requests found
from wagtail.contrib.modeladmin.options import ModelAdmin, ModelAdminGroup
from .models import ApplicationForm, FundType
from .models import ApplicationForm, FundType, Round
from opentech.apply.categories.admin import CategoryAdmin
class RoundAdmin(ModelAdmin):
model = Round
menu_icon = 'doc-empty'
class FundAdmin(ModelAdmin):
model = FundType
menu_icon = 'doc-empty'
......@@ -17,4 +22,4 @@ class ApplicationFormAdmin(ModelAdmin):
class ApplyAdminGroup(ModelAdminGroup):
menu_label = 'Apply'
menu_icon = 'folder-open-inverse'
items = (FundAdmin, ApplicationFormAdmin, CategoryAdmin)
items = (RoundAdmin, FundAdmin, ApplicationFormAdmin, CategoryAdmin)
# -*- coding: utf-8 -*-
# Generated by Django 1.11.8 on 2018-01-18 15:59
from __future__ import unicode_literals
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('wagtailcore', '0040_page_draft_title'),
('funds', '0004_categoryblock_add_required_option'),
]
operations = [
migrations.CreateModel(
name='Round',
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',),
),
]
from django import forms
from django.db import models
from modelcluster.fields import ParentalKey
from wagtail.wagtailadmin.edit_handlers import (
FieldPanel,
......@@ -23,9 +25,8 @@ WORKFLOW_CLASS = {
class FundType(AbstractStreamForm):
parent_page_types = ['apply_home.ApplyHomePage']
subpage_types = [] # type: ignore
subpage_types = ['funds.Round']
base_form_class = WorkflowFormAdminForm
WORKFLOWS = {
'single': SingleStage.name,
'double': DoubleStage.name,
......@@ -33,6 +34,9 @@ class FundType(AbstractStreamForm):
workflow = models.CharField(choices=WORKFLOWS.items(), max_length=100, default='single')
base_form_class = WorkflowFormAdminForm
def get_defined_fields(self):
# Only return the first form, will need updating for when working with 2 stage WF
return self.forms.all()[0].fields
......@@ -67,3 +71,13 @@ class ApplicationForm(models.Model):
def __str__(self):
return self.name
class Round(AbstractStreamForm):
parent_page_types = ['funds.FundType']
subpage_types = [] # type: ignore
def get_defined_fields(self):
# Only return the first form, will need updating for when working with 2 stage WF
return self.get_parent().specific.forms.all()[0].fields
{% include "funds/fund_type.html" %}
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