Implement Tom's emailed suggestions

This commit is contained in:
Anna Sidwell 2018-11-26 22:34:06 +00:00
parent aac22da18c
commit 04b8ae7bf9
3 changed files with 133 additions and 118 deletions

View File

@ -179,17 +179,19 @@ class LongCaseStudyForm(BaseCaseStudyForm):
SECTOR_HELP = { SECTOR_HELP = {
'RN': _("including electricity, heat or combined heat and power generation"), 'RN': _("including electricity, heat or combined heat and power generation"),
'PG': '', 'PG': '',
'ST': _('Biological, chemical, electrical, electromagnetic, electrochemical, mechanical including gravitational potential, thermal etc.'),
'SM': _("including supply of minerals"), 'SM': _("including supply of minerals"),
'MA': '', 'MA': '',
} }
POWER_TECHNOLOGY_HELP = { POWER_TECHNOLOGY_HELP = {
'PT': _('Lines, transformers, machinery etc.'), 'PT': _('Lines, transformers, machinery etc.'),
'ES': _('Biological, chemical, electrical, electromagnetic, electrochemical, mechanical including gravitational potential, thermal etc.'),
'HN': _('District heating/cooling, etc.'), 'HN': _('District heating/cooling, etc.'),
'OT': '', 'OT': '',
} }
# TODO: Allow explanatory_text to not contain text for every option
# TODO: Only output <span> if there is explanatory text
def add_explanatory_text(self, model_choices, explanatory_text): def add_explanatory_text(self, model_choices, explanatory_text):
return [ return [
( (
@ -203,11 +205,8 @@ class LongCaseStudyForm(BaseCaseStudyForm):
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(LongCaseStudyForm, self).__init__(*args, **kwargs) super(LongCaseStudyForm, self).__init__(*args, **kwargs)
self.fields['positive_case_type'] = forms.ChoiceField( self.fields['positive_case_type'].label = ""
widget=forms.RadioSelect(), self.fields['negative_case_reasons'].label = ""
choices=CaseStudy.POSITIVE_CASE_TYPE_CHOICES,
required=False
)
self.fields['sector_of_economy'] = forms.ChoiceField( self.fields['sector_of_economy'] = forms.ChoiceField(
widget=forms.RadioSelect(), widget=forms.RadioSelect(),
@ -282,6 +281,7 @@ class LongCaseStudyForm(BaseCaseStudyForm):
'type_of_ecosystem', 'type_of_ecosystem',
'describe_ecosystem', 'describe_ecosystem',
'affected_communities', 'affected_communities',
'people_affected_other',
'project_status', 'project_status',
'synopsis', 'synopsis',
'full_description', 'full_description',
@ -297,7 +297,6 @@ class LongCaseStudyForm(BaseCaseStudyForm):
'shareholders', 'shareholders',
'financial_institutions', 'financial_institutions',
'financial_institutions_other', 'financial_institutions_other',
'energy_customers'
), ),
Fieldset( Fieldset(
_("Media reports and other communications"), _("Media reports and other communications"),
@ -314,31 +313,41 @@ class LongCaseStudyForm(BaseCaseStudyForm):
Tab( Tab(
_("Technical and economic analysis"), _("Technical and economic analysis"),
'sector_of_economy', 'sector_of_economy',
Fieldset( Div(
'',
'generation_type', 'generation_type',
'generation_technology', 'generation_technology',
'biomass_detail', css_class='power_generation_questions'
'generation_technology_other',
'total_generation_capacity',
'generation_equipment_supplier',
PrependedText('total_investment', 'USD$'),
'technical_or_economic_details',
css_id="power_generation_questions"
), ),
Fieldset( Div(
'',
'power_technology', 'power_technology',
'power_technology_other', css_class='energy_network_questions'
'energy_storage_capacity',
'energy_transmission_capacity',
'contractor_or_supplier_of_technology',
PrependedText('approximate_total_investment', 'USD$'),
'additional_technical_details',
css_id="power_grids_energy_storage_questions"
), ),
Fieldset( Div(
'', 'energy_details',
css_class='energy_generation_network_and_storage_questions'
),
Div(
'biomass_detail',
'total_generation_capacity',
css_class='power_generation_questions'
),
Div(
'energy_transmission_capacity',
css_class='energy_network_questions'
),
Div(
'energy_storage_capacity',
css_class='energy_storage_questions'
),
Div(
PrependedText('total_investment', 'USD $'),
'contractor_or_supplier_of_technology',
'energy_customers',
'additional_technical_details',
css_class='energy_generation_network_and_storage_questions'
),
Div(
'minerals_or_commodities', 'minerals_or_commodities',
'minerals_or_commodities_other', 'minerals_or_commodities_other',
'use_in_energy_economy', 'use_in_energy_economy',
@ -348,17 +357,16 @@ class LongCaseStudyForm(BaseCaseStudyForm):
'projected_production_of_commodities', 'projected_production_of_commodities',
'type_of_extraction', 'type_of_extraction',
'associated_infrastructure', 'associated_infrastructure',
css_id="mineral_commodity_questions" css_class="mineral_commodity_questions"
), ),
Fieldset( Div(
'',
'manufacturing_type', 'manufacturing_type',
'manufacturing_description', 'manufacturing_description',
'manufacturing_related_tech', 'manufacturing_related_tech',
'manufacturing_factors', 'manufacturing_factors',
'manufacturing_factors_description', 'manufacturing_factors_description',
'manufacturing_ownership', 'manufacturing_ownership',
css_id="manufacturing_questions" css_class="manufacturing_questions"
), ),
FormActions( FormActions(
HTML("<a class='btn btn-primary btnPrevious'>"+_("Previous")+"</a>"), HTML("<a class='btn btn-primary btnPrevious'>"+_("Previous")+"</a>"),
@ -369,9 +377,15 @@ class LongCaseStudyForm(BaseCaseStudyForm):
_("Socio-environmental analysis"), _("Socio-environmental analysis"),
HTML("<p>" + _("In the following, we expect the analysis to reflect the perspective of the organization(s) or person(s) describing the case.") + "</p>"), HTML("<p>" + _("In the following, we expect the analysis to reflect the perspective of the organization(s) or person(s) describing the case.") + "</p>"),
'positive_or_negative', 'positive_or_negative',
HTML("<b>What kind of case is this entry about?</b>"), Div(
'positive_case_type', HTML("<label class='col-md-3 control-label'>What kind of case is this entry about?</label>"),
'negative_case_reasons', Div(
'positive_case_type',
'negative_case_reasons',
css_class='col-md-9',
),
css_class='form-group',
),
'negative_case_reasons_other', 'negative_case_reasons_other',
'socioeconomic_benefits', 'socioeconomic_benefits',
'isolated_or_widespread', 'isolated_or_widespread',
@ -383,10 +397,9 @@ class LongCaseStudyForm(BaseCaseStudyForm):
'who_has_been_involved', 'who_has_been_involved',
'participation_mechanisms', 'participation_mechanisms',
'identified_partnerships', 'identified_partnerships',
'potential_partnerships',
'wants_conversation_with_ojuso', 'wants_conversation_with_ojuso',
Div( Div(
css_id="common_questions" css_class="common_questions"
), ),
FormActions( FormActions(
HTML("<a class='btn btn-primary btnPrevious'>"+_("Previous")+"</a>"), HTML("<a class='btn btn-primary btnPrevious'>"+_("Previous")+"</a>"),

View File

@ -53,13 +53,6 @@ class CaseStudy(models.Model):
approved = models.BooleanField(default=False) approved = models.BooleanField(default=False)
# Choice lists for drop-downs # Choice lists for drop-downs
SECTOR_CHOICES = (
('RN', _('Renewable energy generation project')),
('PG', _('Energy networks and energy storage facilities')),
('SM', _('Mining related to the renewable energy economy')),
('MA', _('Manufacturing and/or processing of equipment'))
)
POSITIVE_NEGATIVE_CHOICES = ( POSITIVE_NEGATIVE_CHOICES = (
('P', _('There is/was an organising process in favour of the project')), ('P', _('There is/was an organising process in favour of the project')),
('N', _('There is/was an organising process against the project')), ('N', _('There is/was an organising process against the project')),
@ -139,6 +132,14 @@ class CaseStudy(models.Model):
('WB', _('World Bank')), ('WB', _('World Bank')),
) )
SECTOR_CHOICES = (
('RN', _('Renewable energy generation project')),
('PG', _('Energy networks')),
('ST', _('Energy storage facilities')),
('SM', _('Mining related to the renewable energy economy')),
('MA', _('Manufacturing and/or processing of equipment'))
)
GENERATION_TYPE_CHOICES = ( GENERATION_TYPE_CHOICES = (
('POW', _('Power')), ('POW', _('Power')),
('HOT', _('Heat/Cool')), ('HOT', _('Heat/Cool')),
@ -177,7 +178,6 @@ class CaseStudy(models.Model):
POWER_TECHNOLOGY_CHOICES = ( POWER_TECHNOLOGY_CHOICES = (
('PT', _('Electrical power transmission')), ('PT', _('Electrical power transmission')),
('ES', _('Energy storage')),
('HN', _('Heat networks')), ('HN', _('Heat networks')),
('OT', _('Other')), ('OT', _('Other')),
) )
@ -275,11 +275,8 @@ class CaseStudy(models.Model):
('EACP', _('Community project owned by not-for-profit organizations and/or serving the public interest')), ('EACP', _('Community project owned by not-for-profit organizations and/or serving the public interest')),
('PSEP', _('Public/state (federal, state, municipal) project')), ('PSEP', _('Public/state (federal, state, municipal) project')),
('CORS', _('Reuse / Recycling / Circular economy project')), ('CORS', _('Reuse / Recycling / Circular economy project')),
('OTHR', _('Other(s)'))
) )
NEGATIVE_CASE_REASONS_OTHER_TEXT = _('Other reasons')
NEGATIVE_CASE_REASONS_CHOICES = ( NEGATIVE_CASE_REASONS_CHOICES = (
('VOLR', _('Violation of land rights')), ('VOLR', _('Violation of land rights')),
('VOHR', _('Violation of fundamental human rights, indigenous rights and/or other collective rights')), ('VOHR', _('Violation of fundamental human rights, indigenous rights and/or other collective rights')),
@ -291,14 +288,6 @@ class CaseStudy(models.Model):
etc')), etc')),
('ALAB', _('Abusive labour practices')), ('ALAB', _('Abusive labour practices')),
('CRUP', _('Corruption and/or irregular permitting or contracting, conflicts of interest etc')), ('CRUP', _('Corruption and/or irregular permitting or contracting, conflicts of interest etc')),
#
# N.B.
# If you add another field in here, you need to edit conditionalCheckboxes
# in templates/map/form.html and increment the check for the 'other' field there.
# If you don't, the 'other' detail entry won't show and hide at the appropriate
# times.
#
('OTHR', NEGATIVE_CASE_REASONS_OTHER_TEXT)
) )
# Dynamically generate a list of choices 40 years prior and after the current year. # Dynamically generate a list of choices 40 years prior and after the current year.
@ -378,13 +367,6 @@ class CaseStudy(models.Model):
max_length=128 max_length=128
) )
# 1.2
sector_of_economy = models.CharField(
verbose_name=_("Sector of economy"),
max_length=3,
choices=SECTOR_CHOICES
)
# 1.4 # 1.4
country = CountryField( country = CountryField(
verbose_name=_("Country"), verbose_name=_("Country"),
@ -447,7 +429,7 @@ class CaseStudy(models.Model):
blank=True blank=True
) )
# XXX Delete after migration # XXX Delete after migration - merge into affected_communities
people_affected_indigenous = models.TextField( people_affected_indigenous = models.TextField(
verbose_name=_("Indigenous people affected"), verbose_name=_("Indigenous people affected"),
help_text=_("What group or groups of indigenous people are affected by this project? \ help_text=_("What group or groups of indigenous people are affected by this project? \
@ -455,11 +437,10 @@ class CaseStudy(models.Model):
blank=True blank=True
) )
# XXX Delete after migration
people_affected_other = models.TextField( people_affected_other = models.TextField(
verbose_name=_("Non-indigenous people affected"), verbose_name=_("Communities or identities further detail"),
help_text=_("What other group or groups of people are affected by this project? \ help_text=_("Please describe further the communities or identities present \
Please separate by newline."), in the project area."),
blank=True blank=True
) )
@ -548,16 +529,6 @@ class CaseStudy(models.Model):
blank=True blank=True
) )
# 1.14
energy_customers = models.TextField(
verbose_name=_("Energy service consumers/off-takers"),
help_text=_("List any energy customers/off-takers that take energy from the \
development. E.g. 'national grids' or private energy suppliers. \
Also refer to if carbon markets, credits, blockchain etc. are \
involved in the process. Please separate with a new line."),
blank=True
)
# 1.15.1, 1.15.2, 1.15.3 # 1.15.1, 1.15.2, 1.15.3
images = models.ManyToManyField( images = models.ManyToManyField(
'files.ImageFile', 'files.ImageFile',
@ -632,6 +603,19 @@ class CaseStudy(models.Model):
# Second Screen - Technical and economic analysis # Second Screen - Technical and economic analysis
## ##
sector_of_economy = models.CharField(
verbose_name=_("Sector of economy"),
max_length=3,
choices=SECTOR_CHOICES
)
energy_details = models.CharField(
verbose_name=_("Further details"),
help_text=_("Please give more information about the transmission, network or storage technology."),
max_length=200,
blank=True
)
## Energy generation project ## Energy generation project
generation_type = models.CharField( generation_type = models.CharField(
@ -649,15 +633,6 @@ class CaseStudy(models.Model):
blank=True blank=True
) )
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
)
# Should be filled in if generation_technology was answered as bio-energy # Should be filled in if generation_technology was answered as bio-energy
biomass_detail = models.CharField( biomass_detail = models.CharField(
verbose_name=_("Bio-energy feedstock"), verbose_name=_("Bio-energy feedstock"),
@ -679,6 +654,16 @@ class CaseStudy(models.Model):
blank=True blank=True
) )
# 1.14
energy_customers = models.TextField(
verbose_name=_("Energy service consumers/off-takers"),
help_text=_("List any energy customers/off-takers that take energy from the \
development. E.g. 'national grids' or private energy suppliers. \
Also refer to if carbon markets, credits, blockchain etc. are \
involved in the process. Please separate with a new line."),
blank=True
)
# 2.1.2 # 2.1.2
total_generation_capacity = models.PositiveIntegerField( total_generation_capacity = models.PositiveIntegerField(
verbose_name=_("Total generation capacity (in kW)"), verbose_name=_("Total generation capacity (in kW)"),
@ -687,8 +672,7 @@ class CaseStudy(models.Model):
null=True null=True
) )
# 2.1.3 # XXX Delete after migration - merge into contractor_or_supplier_of_technology
# 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(s)"), 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.)"), 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.)"),
@ -698,12 +682,12 @@ class CaseStudy(models.Model):
# 2.1.4 # 2.1.4
total_investment = models.IntegerField( total_investment = models.IntegerField(
verbose_name=_("Total investment (in USD)"), verbose_name=_("Total investment (in USD)"),
help_text=_("The approximate total investment for the project in USD."), help_text=_("The approximate total investment for the project in US dollars."),
blank=True, blank=True,
null=True null=True
) )
# 2.1.5 # XXX Delete after migration - merge into additional_technical_details
technical_or_economic_details = models.TextField( technical_or_economic_details = models.TextField(
verbose_name=_("Additional technical or economic details"), verbose_name=_("Additional technical or economic details"),
help_text=_("Specify any additional technical or economic details relating to the project."), help_text=_("Specify any additional technical or economic details relating to the project."),
@ -742,7 +726,7 @@ class CaseStudy(models.Model):
null=True, null=True,
) )
# XXX Delete after migration # XXX Delete after migration - no merge
maximum_power_output = models.DecimalField( maximum_power_output = models.DecimalField(
verbose_name=_('Maximum power output'), verbose_name=_('Maximum power output'),
help_text=_('Enter the maximum power output of the storage system in kilowatts (kW).'), help_text=_('Enter the maximum power output of the storage system in kilowatts (kW).'),
@ -752,7 +736,7 @@ class CaseStudy(models.Model):
null=True, null=True,
) )
# XXX Delete after migration # XXX Delete after migration - no merge
discharge_time = models.DecimalField( discharge_time = models.DecimalField(
verbose_name=_('Time for discharge from full capacity'), verbose_name=_('Time for discharge from full capacity'),
help_text=_('Enter the time it takes to discharge from full capacity at maximum power output (in hours).'), help_text=_('Enter the time it takes to discharge from full capacity at maximum power output (in hours).'),
@ -762,15 +746,14 @@ class CaseStudy(models.Model):
null=True null=True
) )
# 2.2.3 # TODO: Auto-completion based on previous entries so we can query case-studies with the same answer.
contractor_or_supplier_of_technology = models.CharField( contractor_or_supplier_of_technology = models.TextField(
verbose_name=_('Contractor and/or supplier of technology'), verbose_name=_('Contractor and/or supplier of technology'),
help_text=_('List companies that act as contractors or suppliers  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'), help_text=_('List companies that act as contractors or suppliers  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'),
max_length=256,
blank=True, blank=True,
) )
# 2.2.4 # XXX Delete after migration - merge into total_investment
approximate_total_investment = models.PositiveIntegerField( approximate_total_investment = models.PositiveIntegerField(
verbose_name=_('Approximate total investment'), verbose_name=_('Approximate total investment'),
help_text=_('Enter the approximate total investment in USD ($).'), help_text=_('Enter the approximate total investment in USD ($).'),
@ -910,11 +893,10 @@ class CaseStudy(models.Model):
choices=POSITIVE_NEGATIVE_CHOICES choices=POSITIVE_NEGATIVE_CHOICES
) )
positive_case_type = models.CharField( positive_case_type = MultiSelectField(
verbose_name=_('What kind of case is this entry about?'), verbose_name=_('What kind of case is this entry about?'),
help_text=_('Select the most relevant type of positive case'),
choices=POSITIVE_CASE_TYPE_CHOICES, choices=POSITIVE_CASE_TYPE_CHOICES,
max_length=4, max_length=32,
blank=True, blank=True,
) )
@ -1007,6 +989,15 @@ class CaseStudy(models.Model):
blank=True blank=True
) )
# XXX delete after migration - merge with identified_partnerships
potential_partnerships = models.CharField(
verbose_name=_("Describe potential partnerships"),
help_text=_("Are you looking for partnerships or do you have any clearly identified need? If so, please \
describe it here."),
max_length=512,
blank=True
)
# 3.2.7 # 3.2.7
wants_conversation_with_ojuso = models.BooleanField( wants_conversation_with_ojuso = models.BooleanField(
verbose_name=_("Would you like to have a conversation with the ojuso team?"), verbose_name=_("Would you like to have a conversation with the ojuso team?"),
@ -1127,9 +1118,6 @@ class CaseStudy(models.Model):
"""Return a list of negative case reasons, minus the 'other' choice (if selected)""" """Return a list of negative case reasons, minus the 'other' choice (if selected)"""
choices = self.get_negative_case_reasons_list() choices = self.get_negative_case_reasons_list()
if choices.count(self.NEGATIVE_CASE_REASONS_OTHER_TEXT) > 0:
choices.remove(self.NEGATIVE_CASE_REASONS_OTHER_TEXT)
return choices return choices
def get_renewable_generation_detail(self): def get_renewable_generation_detail(self):

View File

@ -63,6 +63,10 @@
return elem => elem.value === condition return elem => elem.value === condition
} }
function isNot(condition) {
return elem => elem.value !== condition
}
// Returns a function that returns true if its parameter is in `conditions` // Returns a function that returns true if its parameter is in `conditions`
function isOneOf(conditions) { function isOneOf(conditions) {
return elem => conditions.includes(elem.value) return elem => conditions.includes(elem.value)
@ -84,7 +88,7 @@
// Technical/economic tab // Technical/economic tab
{ {
control: 'sector_of_economy', control: 'sector_of_economy',
showHide: '#power_generation_questions', showHide: '.power_generation_questions',
visible: isJust('RN') // Energy generation project visible: isJust('RN') // Energy generation project
}, },
{ {
@ -95,29 +99,29 @@
{ {
control: 'sector_of_economy', control: 'sector_of_economy',
showHide: '#power_grids_energy_storage_questions', showHide: '.energy_network_questions',
visible: isJust('PG') // Energy networks or storage (stands for 'power grid') visible: isJust('PG') // Energy networks (PG = power grid)
}, },
{ {
control: 'power_technology', control: 'power_technology',
showHide: '#div_id_power_technology_other', showHide: '#div_id_power_technology_other',
visible: isJust('OT') visible: isJust('OT')
}, },
{
control: 'power_technology', {
showHide: '#div_id_energy_storage_capacity', control: 'sector_of_economy',
visible: isOneOf(['ES', 'OT']) // Storage / other showHide: '.energy_storage_questions',
}, visible: isJust('ST') // Storage
{ },
control: 'power_technology', {
showHide: '#div_id_energy_transmission_capacity', control: 'sector_of_economy',
visible: isOneOf(['PT', 'HN', 'OT']) // Transmission / heat / other showHide: '.energy_generation_network_and_storage_questions',
}, visible: isOneOf(['RN', 'ST', 'PG']) // Generation (RN), Storage (ST) and networks (PG)
},
{ {
control: 'sector_of_economy', control: 'sector_of_economy',
showHide: '#mineral_commodity_questions', showHide: '.mineral_commodity_questions',
visible: isJust('SM') // mining visible: isJust('SM') // mining
}, },
{ {
@ -128,12 +132,22 @@
{ {
control: 'sector_of_economy', control: 'sector_of_economy',
showHide: '#manufacturing_questions', showHide: '.manufacturing_questions',
visible: isJust('MA') // manufacturing visible: isJust('MA') // manufacturing
}, },
// Socio-environmental tab // Socio-environmental tab
{
control: 'positive_or_negative',
showHide: '#div_id_positive_case_type',
visible: isNot('N')
},
{
control: 'positive_or_negative',
showHide: '#div_id_negative_case_reasons',
visible: isNot('P')
},
{ {
control: 'positive_or_negative', control: 'positive_or_negative',
showHide: '#div_id_obstacles_and_hindrances', showHide: '#div_id_obstacles_and_hindrances',