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")
}
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):
return [
(
@ -246,6 +253,15 @@ class LongCaseStudyForm(BaseCaseStudyForm):
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['shareholders'].required = True
@ -297,7 +313,8 @@ class LongCaseStudyForm(BaseCaseStudyForm):
_("Technical and economic analysis"),
'sector_of_economy',
Fieldset(
_("Power Generation Questions"),
'',
'generation_type',
'generation_technology',
'biomass_detail',
'generation_technology_other',
@ -308,7 +325,7 @@ class LongCaseStudyForm(BaseCaseStudyForm):
css_id="power_generation_questions"
),
Fieldset(
_("Power Grids/Energy Storage Questions"),
'',
'power_technology',
'power_technology_other',
'energy_storage_capacity',
@ -320,7 +337,7 @@ class LongCaseStudyForm(BaseCaseStudyForm):
css_id="power_grids_energy_storage_questions"
),
Fieldset(
_("Mineral/Commodity Questions"),
'',
'minerals_or_commodities',
'minerals_or_commodities_other',
'use_in_energy_economy',

View File

@ -138,31 +138,47 @@ class CaseStudy(models.Model):
('WB', _('World Bank')),
)
GENERATION_TYPE_CHOICES = (
('POW', _('Power')),
('HOT', _('Heat/Cool')),
('CHP', _('Combined Heat/Cool and Power (CHP)')),
)
GENERATION_TECHNOLOGY_CHOICES = (
(_('Wind 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)')),
('BIO', _('Bio-energy')),
('GEOT', _('Geothermal electricity')),
('BIOG', _('Biogas turbine')),
('OTHB', _('Other biomass (including liquid/solid biofuel)')),
(_('Hydro'), (
('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)'))
)
POWER_TECHNOLOGY_CHOICES = (
('PT', _('Power transmission (grid lines, substations etc)')),
('ES', _('Energy storage (pumped storage, compressed air, battery systems etc')),
('OT', _('Others'))
('PT', _('Electrical power transmission')),
('ES', _('Energy storage')),
('HN', _('Heat networks')),
('OT', _('Other')),
)
TYPE_OF_EXTRACTION_CHOICES = (
@ -556,8 +572,15 @@ class CaseStudy(models.Model):
# Second Screen - Technical and economic analysis
##
# 2.1 - Renewable Energy Generation
# 2.1.1
## Energy generation project
generation_type = models.CharField(
verbose_name=_('What is being generated?'),
max_length=4,
choices=GENERATION_TYPE_CHOICES,
blank=True
)
generation_technology = models.CharField(
verbose_name=_("Generation technology"),
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
)
# 2.1.1.12
# Should be filled in if 2.1.1 was answered as biogas or biomass.
biomass_detail = models.CharField(
verbose_name=_("Description of feedstock"),
help_text=_("If you selected biogas or biomass, please describe the feedstock (where the fuel came from e.g. \
corn, algae, anaerobic digestion, commercial waste etc)"),
generation_technology_other = models.CharField(
verbose_name=_("Further details"),
help_text=_("If you selected other, or if you would like to further define what you have chosen, \
please specify the generation technology further. For example, if you chose solar PV \
it is most likely to be a crystalline silicon type, but maybe it is not."),
max_length=200,
blank=True
)
# 2.1.1.14
generation_technology_other = models.CharField(
verbose_name=_("Other generation type"),
help_text=_("If you selected other, please specify the generation technology (e.g. tidal, wave etc)"),
# Should be filled in if generation_technology was answered as bio-energy
biomass_detail = models.CharField(
verbose_name=_("Bio-energy feedstock"),
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,
blank=True
)
@ -595,8 +630,8 @@ class CaseStudy(models.Model):
# 2.1.3
# TODO: Auto-completion based on previous entries so we can query case-studies with the same answer.
generation_equipment_supplier = models.TextField(
verbose_name=_("Generation equipment supplier"),
help_text=_("Enter the supplier of the generation equipment. (E.g. Siemens)"),
verbose_name=_("Generation equipment supplier(s)"),
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
)
@ -619,7 +654,6 @@ class CaseStudy(models.Model):
# 2.2.1
power_technology = models.CharField(
verbose_name=_("Power technology"),
help_text=_("Select the related energy technology."),
max_length=2,
choices=POWER_TECHNOLOGY_CHOICES,
blank=True
@ -628,7 +662,7 @@ class CaseStudy(models.Model):
# 2.2.1.4
power_technology_other = models.CharField(
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,
blank=True
)

View File

@ -48,11 +48,6 @@
"showHide": ["#div_id_type_of_ecosystem"],
"condition": ["RUR"]
},
{
"field": "#id_power_technology",
"showHide": ["#div_id_power_technology_other"],
"condition": ["OT"]
},
{ // 2.1 - Power Generation
"field": "#id_sector_of_economy",
"showHide": ["#power_generation_questions"],
@ -61,12 +56,7 @@
{
"field": "#id_generation_technology",
"showHide": ["#div_id_biomass_detail"],
"condition": ["BIOG", "OTHB"]
},
{
"field": "#id_generation_technology",
"showHide": ["#div_id_generation_technology_other"],
"condition": ["OTHR"]
"condition": ["BIO"]
},
{ // 2.2 - Power Grids
"field": "#id_sector_of_economy",
@ -94,19 +84,66 @@
// logic as they rely on the 'checked' attribute rather than value.
var conditionalCheckboxes = [
{
"checkbox": "#id_affects_indigenous",
"showHide": "#div_id_affects_indigenous_detail"
checkbox: "#id_affects_indigenous",
showHide: "#div_id_affects_indigenous_detail",
},
{
"checkbox": "#id_shown_on_other_platforms",
"showHide": "#div_id_shown_on_other_platforms_detail"
checkbox: "#id_shown_on_other_platforms",
showHide: "#div_id_shown_on_other_platforms_detail"
},
{
"checkbox": "#id_negative_case_reasons_8",
"showHide": "#div_id_negative_case_reasons_other"
}
checkbox: "#id_negative_case_reasons_8",
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.
// Takes a single conditionalField dictionary with (field, showHide and condition).
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
function show(tag) {
$(tag).show();
@ -209,12 +218,10 @@
$(item.checkbox).change();
});
for (const option of analysisToggles) {
const input = document.getElementById(option.input)
$(input).on('change', showAnalysisSection);
$(input).trigger('change');
}
conditionalRadioGroups.forEach(function (group) {
$(`input[name=${group.name}]`).on('change', group.redraw)
group.redraw();
});
});
</script>