Through to row 101

This commit is contained in:
Anna Sidwell 2018-11-24 17:58:08 +00:00
parent 5c4e9c330d
commit 857634d1f1
3 changed files with 148 additions and 90 deletions

View File

@ -215,6 +215,13 @@ class LongCaseStudyForm(BaseCaseStudyForm):
'SM': _("including supply of minerals and/or manufacturing/processing of equipment used in the renewable energy economy") 'SM': _("including supply of minerals and/or manufacturing/processing of equipment used in the renewable energy economy")
} }
POWER_TECHNOLOGY_HELP = {
'PT': _('Lines, transformers, machinery etc.'),
'ES': _('Biological, chemical, electrical, electromagnetic, electrochemical, mechanical including gravitational potential, thermal etc.'),
'HN': _('District heating/cooling, etc.'),
'OT': '',
}
def add_explanatory_text(self, model_choices, explanatory_text): def add_explanatory_text(self, model_choices, explanatory_text):
return [ return [
( (
@ -246,6 +253,15 @@ class LongCaseStudyForm(BaseCaseStudyForm):
required=False required=False
) )
self.fields['power_technology'] = forms.ChoiceField(
widget=forms.RadioSelect(),
choices=self.add_explanatory_text(
CaseStudy.POWER_TECHNOLOGY_CHOICES,
self.POWER_TECHNOLOGY_HELP
),
required=False
)
self.fields['project_owners'].required = True self.fields['project_owners'].required = True
self.fields['shareholders'].required = True self.fields['shareholders'].required = True
@ -297,7 +313,8 @@ class LongCaseStudyForm(BaseCaseStudyForm):
_("Technical and economic analysis"), _("Technical and economic analysis"),
'sector_of_economy', 'sector_of_economy',
Fieldset( Fieldset(
_("Power Generation Questions"), '',
'generation_type',
'generation_technology', 'generation_technology',
'biomass_detail', 'biomass_detail',
'generation_technology_other', 'generation_technology_other',
@ -308,7 +325,7 @@ class LongCaseStudyForm(BaseCaseStudyForm):
css_id="power_generation_questions" css_id="power_generation_questions"
), ),
Fieldset( Fieldset(
_("Power Grids/Energy Storage Questions"), '',
'power_technology', 'power_technology',
'power_technology_other', 'power_technology_other',
'energy_storage_capacity', 'energy_storage_capacity',
@ -320,7 +337,7 @@ class LongCaseStudyForm(BaseCaseStudyForm):
css_id="power_grids_energy_storage_questions" css_id="power_grids_energy_storage_questions"
), ),
Fieldset( Fieldset(
_("Mineral/Commodity Questions"), '',
'minerals_or_commodities', 'minerals_or_commodities',
'minerals_or_commodities_other', 'minerals_or_commodities_other',
'use_in_energy_economy', 'use_in_energy_economy',

View File

@ -138,31 +138,47 @@ class CaseStudy(models.Model):
('WB', _('World Bank')), ('WB', _('World Bank')),
) )
GENERATION_TYPE_CHOICES = (
('POW', _('Power')),
('HOT', _('Heat/Cool')),
('CHP', _('Combined Heat/Cool and Power (CHP)')),
)
GENERATION_TECHNOLOGY_CHOICES = ( GENERATION_TECHNOLOGY_CHOICES = (
(_('Wind energy'), ( ('BIO', _('Bio-energy')),
('SSWE', _('Small-scale (less than 500kW)')),
('LSWE', _('Large-scale (more than 500kW)'))
)),
(_('Photovoltaic electricity'), (
('SSPV', _('Small-scale (less than 500kW)')),
('LSPV', _('Large-scale (more than 500kW)'))
)),
(_('Hydroelectric'), (
('SHYD', _('Small-scale (less than 1MW)')),
('MHYD', _('Medium-scale (between 1-20MW)')),
('LHYD', _('Large-scale (more than 20MW - often not considered renewable)')),
)),
('STHE', _('Solar thermal electricity (e.g using parabolic reflectors)')),
('GEOT', _('Geothermal electricity')), ('GEOT', _('Geothermal electricity')),
('BIOG', _('Biogas turbine')), (_('Hydro'), (
('OTHB', _('Other biomass (including liquid/solid biofuel)')), ('uHYD', _('Micro hydro (<100kW)')),
('SHYD', _('Small-scale hydro (<1MW)')),
('MHYD', _('Medium-scale hydro (1-30MW)')),
('LHYD', _('Large-scale hydro (>30MW - often not considered renewable)')),
)),
(_('Marine'), (
('WAVE', _('Wave')),
('TSTR', _('Tidal stream')),
('TBAR', _('Tidal barrage/lagoon')),
('TOTH', _('Other')),
)),
(_('Solar'), (
('SSPV', _('Small-scale photovoltaic (<500kW)')),
('LSPV', _('Large-scale photovoltaic (>500kW)')),
( 'CSP', _('Concentrated solar power (CSP)')),
('PARA', _('Parabolic trough (open or enclosed)')),
('FRES', _('Fresnel reflector')),
('STIR', _('Dish Stirling')),
)),
(_('Wind'), (
('SSWE', _('Small-scale wind (<500kW)')),
('LSWE', _('Large-scale wind (>500kW)'))
)),
('OTHR', _('Other (tidal, wave etc)')) ('OTHR', _('Other (tidal, wave etc)'))
) )
POWER_TECHNOLOGY_CHOICES = ( POWER_TECHNOLOGY_CHOICES = (
('PT', _('Power transmission (grid lines, substations etc)')), ('PT', _('Electrical power transmission')),
('ES', _('Energy storage (pumped storage, compressed air, battery systems etc')), ('ES', _('Energy storage')),
('OT', _('Others')) ('HN', _('Heat networks')),
('OT', _('Other')),
) )
TYPE_OF_EXTRACTION_CHOICES = ( TYPE_OF_EXTRACTION_CHOICES = (
@ -556,8 +572,15 @@ class CaseStudy(models.Model):
# Second Screen - Technical and economic analysis # Second Screen - Technical and economic analysis
## ##
# 2.1 - Renewable Energy Generation ## Energy generation project
# 2.1.1
generation_type = models.CharField(
verbose_name=_('What is being generated?'),
max_length=4,
choices=GENERATION_TYPE_CHOICES,
blank=True
)
generation_technology = models.CharField( generation_technology = models.CharField(
verbose_name=_("Generation technology"), verbose_name=_("Generation technology"),
help_text=_("Select the type of renewable energy generation that most applies to this case study."), help_text=_("Select the type of renewable energy generation that most applies to this case study."),
@ -566,20 +589,32 @@ class CaseStudy(models.Model):
blank=True blank=True
) )
# 2.1.1.12 generation_technology_other = models.CharField(
# Should be filled in if 2.1.1 was answered as biogas or biomass. verbose_name=_("Further details"),
biomass_detail = models.CharField( help_text=_("If you selected other, or if you would like to further define what you have chosen, \
verbose_name=_("Description of feedstock"), please specify the generation technology further. For example, if you chose solar PV \
help_text=_("If you selected biogas or biomass, please describe the feedstock (where the fuel came from e.g. \ it is most likely to be a crystalline silicon type, but maybe it is not."),
corn, algae, anaerobic digestion, commercial waste etc)"),
max_length=200, max_length=200,
blank=True blank=True
) )
# 2.1.1.14 # Should be filled in if generation_technology was answered as bio-energy
generation_technology_other = models.CharField( biomass_detail = models.CharField(
verbose_name=_("Other generation type"), verbose_name=_("Bio-energy feedstock"),
help_text=_("If you selected other, please specify the generation technology (e.g. tidal, wave etc)"), help_text=_("<div class='text-muted'>\
<p>Please describe the source of the fuel and how it is processed/used. \
Please consider:\
<ul>\
<li>where the fuel came from e.g. corn, forestry, algae, commercial food waste, \
landfill gas, sewage, livestock farm, etc. \
<li>how it is processed e.g. direct-fired, co-firing with other renewable input, \
gasification, bacterial decomposition (anaerobic digestion, AD), pyrolysis, \
small/modular, artificial photosynthesis, fuel cell, etc. \
</ul>\
\
<p>We do not expect users to know this information, but if you do \
it may be useful to give a fuller picture.\
</div>"),
max_length=200, max_length=200,
blank=True blank=True
) )
@ -595,8 +630,8 @@ class CaseStudy(models.Model):
# 2.1.3 # 2.1.3
# TODO: Auto-completion based on previous entries so we can query case-studies with the same answer. # TODO: Auto-completion based on previous entries so we can query case-studies with the same answer.
generation_equipment_supplier = models.TextField( generation_equipment_supplier = models.TextField(
verbose_name=_("Generation equipment supplier"), verbose_name=_("Generation equipment supplier(s)"),
help_text=_("Enter the supplier of the generation equipment. (E.g. Siemens)"), help_text=_("Enter the supplier of the generation equipment. (E.g. Siemens Gamesa, GE, Alstom, Vestas, Hanwha Q CELLS, Mitsubishi, First Solar, Jinko Solar, Trina Solar, Suzlon Energy, Statkraft, Shanghai Electric, Ballard Power Systems, Panasonic, etc.)"),
blank=True blank=True
) )
@ -619,7 +654,6 @@ class CaseStudy(models.Model):
# 2.2.1 # 2.2.1
power_technology = models.CharField( power_technology = models.CharField(
verbose_name=_("Power technology"), verbose_name=_("Power technology"),
help_text=_("Select the related energy technology."),
max_length=2, max_length=2,
choices=POWER_TECHNOLOGY_CHOICES, choices=POWER_TECHNOLOGY_CHOICES,
blank=True blank=True
@ -628,7 +662,7 @@ class CaseStudy(models.Model):
# 2.2.1.4 # 2.2.1.4
power_technology_other = models.CharField( power_technology_other = models.CharField(
verbose_name=_("Other power technology"), verbose_name=_("Other power technology"),
help_text=_("If you answered 'others', please specify the power technologies."), help_text=_("Please specify the power technology."),
max_length=128, max_length=128,
blank=True blank=True
) )

View File

@ -48,11 +48,6 @@
"showHide": ["#div_id_type_of_ecosystem"], "showHide": ["#div_id_type_of_ecosystem"],
"condition": ["RUR"] "condition": ["RUR"]
}, },
{
"field": "#id_power_technology",
"showHide": ["#div_id_power_technology_other"],
"condition": ["OT"]
},
{ // 2.1 - Power Generation { // 2.1 - Power Generation
"field": "#id_sector_of_economy", "field": "#id_sector_of_economy",
"showHide": ["#power_generation_questions"], "showHide": ["#power_generation_questions"],
@ -61,12 +56,7 @@
{ {
"field": "#id_generation_technology", "field": "#id_generation_technology",
"showHide": ["#div_id_biomass_detail"], "showHide": ["#div_id_biomass_detail"],
"condition": ["BIOG", "OTHB"] "condition": ["BIO"]
},
{
"field": "#id_generation_technology",
"showHide": ["#div_id_generation_technology_other"],
"condition": ["OTHR"]
}, },
{ // 2.2 - Power Grids { // 2.2 - Power Grids
"field": "#id_sector_of_economy", "field": "#id_sector_of_economy",
@ -94,19 +84,66 @@
// logic as they rely on the 'checked' attribute rather than value. // logic as they rely on the 'checked' attribute rather than value.
var conditionalCheckboxes = [ var conditionalCheckboxes = [
{ {
"checkbox": "#id_affects_indigenous", checkbox: "#id_affects_indigenous",
"showHide": "#div_id_affects_indigenous_detail" showHide: "#div_id_affects_indigenous_detail",
}, },
{ {
"checkbox": "#id_shown_on_other_platforms", checkbox: "#id_shown_on_other_platforms",
"showHide": "#div_id_shown_on_other_platforms_detail" showHide: "#div_id_shown_on_other_platforms_detail"
}, },
{ {
"checkbox": "#id_negative_case_reasons_8", checkbox: "#id_negative_case_reasons_8",
"showHide": "#div_id_negative_case_reasons_other" showHide: "#div_id_negative_case_reasons_other"
} },
]; ];
var conditionalRadioGroups = [
{
name: "power_technology",
redraw: function() {
const other = document.getElementById('id_id_power_technology_0_4')
const showHide = document.getElementById('div_id_power_technology_other')
if (other.checked) {
$(showHide).show();
} else {
$(showHide).hide();
}
}
},
{
name: "sector_of_economy",
redraw: function() {
var sections = [
{
"input": "id_id_sector_of_economy_0_1",
"section": "power_generation_questions",
},
{
"input": "id_id_sector_of_economy_0_2",
"section": "power_grids_energy_storage_questions",
},
{
"input": "id_id_sector_of_economy_0_3",
"section": "mineral_commodity_questions",
},
]
for (const option of sections) {
const input = document.getElementById(option.input)
const section = document.getElementById(option.section)
if (input.checked) {
$(section).show();
} else {
$(section).hide();
}
}
}
}
]
// Define a function that hides the field and then creates a listener to toggle the field. // Define a function that hides the field and then creates a listener to toggle the field.
// Takes a single conditionalField dictionary with (field, showHide and condition). // Takes a single conditionalField dictionary with (field, showHide and condition).
function addConditionalField(item) { function addConditionalField(item) {
@ -137,34 +174,6 @@
}); });
} }
var analysisToggles = [
{
"input": "id_id_sector_of_economy_0_1",
"section": "power_generation_questions",
},
{
"input": "id_id_sector_of_economy_0_2",
"section": "power_grids_energy_storage_questions",
},
{
"input": "id_id_sector_of_economy_0_3",
"section": "mineral_commodity_questions",
},
]
function showAnalysisSection() {
for (const option of analysisToggles) {
const input = document.getElementById(option.input)
const section = document.getElementById(option.section)
if (input.checked) {
$(section).show();
} else {
$(section).hide();
}
}
}
// Helper functions // Helper functions
function show(tag) { function show(tag) {
$(tag).show(); $(tag).show();
@ -209,12 +218,10 @@
$(item.checkbox).change(); $(item.checkbox).change();
}); });
for (const option of analysisToggles) { conditionalRadioGroups.forEach(function (group) {
const input = document.getElementById(option.input) $(`input[name=${group.name}]`).on('change', group.redraw)
group.redraw();
$(input).on('change', showAnalysisSection); });
$(input).trigger('change');
}
}); });
</script> </script>