Update frontend and forms

This commit is contained in:
Livvy Mackintosh
2017-11-18 16:54:44 +00:00
parent aa6c1cf33b
commit 310be805c5
16 changed files with 712 additions and 128 deletions

View File

@ -1,7 +1,9 @@
from django.urls import reverse
from django import forms
from django.utils.translation import ugettext as _
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit, Layout
from crispy_forms.bootstrap import Tab, TabHolder
from crispy_forms.layout import Submit, Layout, HTML, Fieldset
from crispy_forms.bootstrap import Tab, TabHolder, PrependedText, FormActions
from leaflet.forms.widgets import LeafletWidget
from moderation.forms import BaseModeratedObjectForm
@ -19,12 +21,16 @@ class BaseCaseStudyForm(BaseModeratedObjectForm):
self.helper.form_action = 'add'
self.helper.label_class = 'col-lg-2'
self.helper.field_class = 'col-lg-8'
self.helper.add_input(Submit('submit', 'Submit'))
class Meta:
model = CaseStudy
fields = '__all__'
widgets = {'location': LeafletWidget(attrs={})}
widgets = {
'location': LeafletWidget(attrs={}),
'official_project_documents': forms.ClearableFileInput(attrs={'multiple': True}),
'other_documents': forms.ClearableFileInput(attrs={'multiple': True}),
'shapefiles': forms.ClearableFileInput(attrs={'multiple': True}),
}
class ShortCaseStudyForm(BaseCaseStudyForm):
@ -69,7 +75,7 @@ class LongCaseStudyForm(BaseCaseStudyForm):
self.helper.form_action = reverse('long-form')
self.helper.layout = Layout(
TabHolder(
Tab("First Page",
Tab(_("Basic information"),
'entry_name',
'location',
'sector_of_economy',
@ -86,28 +92,116 @@ class LongCaseStudyForm(BaseCaseStudyForm):
'project_status',
'synopsis',
'full_description',
'project_owners',
'shareholders',
'financial_institutions',
'energy_customers',
'image',
'image_caption',
'image_credit',
'video',
'video_caption',
'video_credit',
'media_coverage_mainstream',
'media_coverage_independent',
'community_voices'),
'community_voices',
'direct_comms',
'social_media_links',
FormActions(
HTML("<a class='btn btn-primary btnNext pull-right'>"+_("Next")+"</a>")
)
),
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',
_("Technical and economic analysis"),
Fieldset(
_("Power Generation Questions"),
'generation_technology',
'biomass_detail',
'generation_technology_other',
'total_generation_capacity',
'generation_equipment_supplier',
'total_investment',
'technical_or_economic_details',
css_id="power_generation_questions"
),
Fieldset(
_("Power Grids/Energy Storage Questions"),
'power_technology',
'power_technology_other',
'energy_storage_capacity',
'maximum_power_output',
'discharge_time',
'contractor_or_supplier_of_technology',
'approximate_total_investment',
'additional_technical_details',
css_id="power_grids_energy_storage_questions"
),
Fieldset(
_("Mineral/Commodity Questions"),
'minerals_or_commodities',
'minerals_or_commodities_other',
'use_in_energy_economy',
'use_in_energy_economy_other',
'project_life_span',
'size_of_concessions',
'projected_production_of_commodities',
'type_of_extraction',
'associated_infrastructure',
css_id="mineral_commodity_questions"
),
FormActions(
HTML("<a class='btn btn-primary btnPrevious'>"+_("Previous")+"</a>"),
HTML("<a class='btn btn-primary btnNext pull-right'>"+_("Next")+"</a>")
)
),
Tab(
_("Socio-environmental analysis"),
Fieldset(
_("Positive Case Questions"),
'positive_case_type',
'socioeconomic_benefits',
'project_status_detail',
'obstacles_and_hindrances',
'identified_partnerships',
css_id="positive_case_questions"
),
Fieldset(
_("Negative Case Questions"),
'negative_case_reasons',
'negative_case_reasons_other',
'negative_socioenvironmental_impacts',
'isolated_or_widespread',
'when_did_organising_start',
'who_has_been_involved',
'participation_mechanisms',
'potential_partnerships',
'wants_conversation_with_ojuso',
css_id="negative_case_questions"
),
Fieldset(
_("Common Questions"),
'key_actors_involved',
css_id="common_questions"
),
FormActions(
HTML("<a class='btn btn-primary btnPrevious'>"+_("Previous")+"</a>"),
HTML("<a class='btn btn-primary btnNext pull-right'>"+_("Next")+"</a>")
)
),
Tab(
_("Uploads"),
'official_project_documents',
'other_documents',
'shapefiles',
'coordinate_reference_system',
'name_of_territory_or_area',
'shown_on_other_platforms',
'shown_on_other_platforms_detail',
FormActions(
HTML("<a class='btn btn-primary btnPrevious'>"+_("Previous")+"</a>"),
Submit('submit', _('Submit'), css_class="btn-success pull-right")
)
)))
class Meta(BaseCaseStudyForm.Meta):
fields = '__all__'
fields = '__all__'