Add updated front end, updated CaseStudy model and profiles app

This commit is contained in:
Livvy Mackintosh
2017-10-31 14:57:26 +00:00
parent f91b4d2a2a
commit 43d6ec989b
30 changed files with 1065 additions and 77 deletions

View File

@ -1,13 +1,14 @@
from django import forms
from django.urls import reverse
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit
from crispy_forms.layout import Submit, Layout
from crispy_forms.bootstrap import Tab, TabHolder
from leaflet.forms.widgets import LeafletWidget
from moderation.forms import BaseModeratedObjectForm
from .models import CaseStudy
class BaseCaseStudyForm(forms.ModelForm):
class BaseCaseStudyForm(BaseModeratedObjectForm):
"""Base form class for the CaseStudy model."""
def __init__(self, *args, **kwargs):
super(BaseCaseStudyForm, self).__init__(*args, **kwargs)
@ -52,6 +53,11 @@ class ShortCaseStudyForm(BaseCaseStudyForm):
'synopsis',
'full_description',
'image',
'image_caption',
'image_credit',
'video',
'media_coverage_mainstream',
'media_coverage_independent',
'community_voices'
]
@ -61,6 +67,47 @@ class LongCaseStudyForm(BaseCaseStudyForm):
def __init__(self, *args, **kwargs):
super(LongCaseStudyForm, self).__init__(*args, **kwargs)
self.helper.form_action = reverse('long-form')
self.helper.layout = Layout(
TabHolder(
Tab("First Page",
'entry_name',
'location',
'sector_of_economy',
'positive_or_negative',
'country',
'area_of_land',
'land_ownership',
'land_ownership_details',
'location_context',
'type_of_ecosystem',
'describe_ecosystem',
'affects_indigenous',
'affects_indigenous_detail',
'project_status',
'synopsis',
'full_description',
'image',
'image_caption',
'image_credit',
'video',
'media_coverage_mainstream',
'media_coverage_independent',
'community_voices'),
Tab(
"Second Page",
'generation_technology',
'biomass_detail',
'generation_technology_other',
'total_generation_capacity',
'total_investment',
'technical_or_economic_details',
'power_technology',
'power_technology_other',
'energy_storage_capacity',
)))
class Meta(BaseCaseStudyForm.Meta):
fields = '__all__'
fields = '__all__'