From 5c4e9c330d41fb824a3d6ae515973b7fd8e736ad Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Sat, 24 Nov 2018 16:54:39 +0000 Subject: [PATCH 01/19] Through to row 87 --- apps/map/forms.py | 39 +++++-- apps/map/models.py | 120 +++++++++++++------- apps/map/templates/map/form-case_study.html | 35 ++++++ 3 files changed, 146 insertions(+), 48 deletions(-) diff --git a/apps/map/forms.py b/apps/map/forms.py index 0ef783b..6779fa7 100644 --- a/apps/map/forms.py +++ b/apps/map/forms.py @@ -100,8 +100,7 @@ class ShortCaseStudyForm(BaseCaseStudyForm): 'location_context', 'type_of_ecosystem', 'describe_ecosystem', - 'people_affected_indigenous', - 'people_affected_other', + 'affected_communities', 'project_status', 'synopsis', 'full_description', @@ -210,17 +209,40 @@ class LongCaseStudyForm(BaseCaseStudyForm): in host countries."), } + SECTOR_HELP = { + 'RN': _("including electricity, heat or combined heat and power generation"), + 'PG': "", + 'SM': _("including supply of minerals and/or manufacturing/processing of equipment used in the renewable energy economy") + } + + def add_explanatory_text(self, model_choices, explanatory_text): + return [ + ( + choice[0], + mark_safe('%s
%s' % + (choice[1], explanatory_text[choice[0]]) + ) + ) for choice in model_choices + ] + def __init__(self, *args, **kwargs): super(LongCaseStudyForm, self).__init__(*args, **kwargs) - POSITIVE_CASE_TYPE_CHOICES = [ - (choice[0], mark_safe('%s
%s' % (choice[1], self.POSITIVE_CASE_TYPE_HELP[choice[0]]))) - for choice in CaseStudy.POSITIVE_CASE_TYPE_CHOICES - ] - self.fields['positive_case_type'] = forms.ChoiceField( widget=forms.RadioSelect(), - choices=POSITIVE_CASE_TYPE_CHOICES, + choices=self.add_explanatory_text( + CaseStudy.POSITIVE_CASE_TYPE_CHOICES, + self.POSITIVE_CASE_TYPE_HELP, + ), + required=False + ) + + self.fields['sector_of_economy'] = forms.ChoiceField( + widget=forms.RadioSelect(), + choices=self.add_explanatory_text( + CaseStudy.SECTOR_CHOICES, + self.SECTOR_HELP + ), required=False ) @@ -253,6 +275,7 @@ class LongCaseStudyForm(BaseCaseStudyForm): Fieldset( _("Ownership and finance"), 'project_owners', + 'consultants_contractors', 'shareholders', 'financial_institutions', 'financial_institutions_other', diff --git a/apps/map/models.py b/apps/map/models.py index 7a56e12..f6220f9 100644 --- a/apps/map/models.py +++ b/apps/map/models.py @@ -54,20 +54,23 @@ class CaseStudy(models.Model): # Choice lists for drop-downs SECTOR_CHOICES = ( - ('RN', _('Renewable Energy Generation')), - ('PG', _('Power Grids')), - ('SM', _('Supply of Minerals')), + ('RN', _('Renewable energy generation project')), + ('PG', _('Energy networks and energy storage facilities')), + ('SM', _('Supply chain and lifecycle management')), ) POSITIVE_NEGATIVE_CHOICES = ( - ('P', _('Positive')), - ('N', _('Negative')) + ('P', _('There is/was an organising process in favour of the project')), + ('N', _('There is/was an organising process against the project')), + ('X', _('There is/was no organising process')), + ('U', _('Unsure/unknown')) ) LAND_OWNERSHIP_CHOICES = ( - ('PRI', _('Private Land')), - ('PUB', _('Public Land')), - ('COM', _('Community Land')), + ('PRI', _('Private land')), + ('PUB', _('Public/state land')), + ('COM', _('Community/communal/customary land')), + ('CON', _('Contested/in conflict')), ('OTH', _('Other')), ) @@ -88,10 +91,22 @@ class CaseStudy(models.Model): ('URBAN', _('Urban')) ) + AFFECTED_COMMUNITIES_CHOICES = ( + ('INDIG', _('Indigenous')), + ('AFRO', _('Afro-descendants')), + ('MIG', _('Migrants')), + ('REF', _('Refugees')), + ('OTHER', _('Other communities or identities')), + ) + PROJECT_STATUS_CHOICES = ( - ('EXSTNG', _('Existing Project')), - ('UCONST', _('Under Construction')), - ('PROJCD', _('Projected Project')), + ('INIT', _('Initiation/ideation')), + ('PROJCD', _('In planning and design')), + ('FAIL', _('Failed')), + ('UCONST', _('Under construction')), + ('EXSTNG', _('In operation')), + ('DECOMM', _('Undergoing decommissioning')), + ('END', _('Decommissioned]')), ) FINANCIAL_INSTITUTIONS = ( @@ -265,8 +280,10 @@ class CaseStudy(models.Model): # 1.1 entry_name = models.CharField( verbose_name=_("Entry Name"), - help_text=_("Enter the name of the entry. This should usually be the\ - name of project."), + help_text=_("This should usually be the name of the project. \ + If you are writing this case study in a language not used \ + in the locale of its project, you should provide its local name \ + first, as well as any translated name."), max_length=128 ) @@ -286,8 +303,8 @@ class CaseStudy(models.Model): # 1.3 positive_or_negative = models.CharField( - verbose_name=_("Positive or negative?"), - help_text=_("Is the case study a positive case or a negative case?"), + verbose_name=_("What is the relationship of local community organization(s) to this project?"), + help_text=_("Please reflect the perspective of the organization(s) or person(s) describing the case."), max_length=1, choices=POSITIVE_NEGATIVE_CHOICES ) @@ -306,16 +323,22 @@ class CaseStudy(models.Model): # 1.5.2 land_ownership = models.CharField( - verbose_name=_("Land ownership"), + verbose_name=_("Land ownership / tenure"), help_text=_("What type of ownership does the land fall under?"), max_length=3, choices=LAND_OWNERSHIP_CHOICES ) # 1.5.3 - land_ownership_details = models.CharField( + land_ownership_details = models.TextField( verbose_name=_("Land ownership details"), - help_text=_("Please specify details about land ownership"), + help_text=_("

Please specify details about land ownership, including \ + conflicting claims, unrecognized customary rights, conflicts \ + around land lease or purchase contracts, etc.\ + \ +

We understand this is a difficult question, so \ + please try to provide just the information you know. \ + If we have any major questions we will ask them in the moderation process.

"), max_length=256, blank=True, ) @@ -323,8 +346,7 @@ class CaseStudy(models.Model): # 1.5.4 location_context = models.CharField( verbose_name=_("Location"), - help_text=_("Select the context that is most applicable to this case\ - study."), + help_text=_("Select the context that is most applicable to this case study."), max_length=3, choices=LOCATION_CONTEXT_CHOICES ) @@ -332,7 +354,6 @@ class CaseStudy(models.Model): # 1.5.5 type_of_ecosystem = MultiSelectField( verbose_name=_("Type(s) of ecosystem"), - help_text=_("Select the most relevant type(s)."), max_length=56, choices=TYPE_OF_ECOSYSTEM_CHOICES, blank=True @@ -341,10 +362,16 @@ class CaseStudy(models.Model): # 1.5.5.3 describe_ecosystem = models.TextField( verbose_name=_("Describe the ecosystem"), - help_text=_("In your own words, add more detail about the ecosystem."), ) - # Was 1.5.6; spec not being followed here after request from client + affected_communities = MultiSelectField( + verbose_name=_("Communities or identities present in the project area"), + max_length=50, + choices=AFFECTED_COMMUNITIES_CHOICES, + blank=True + ) + + # XXX Delete after migration people_affected_indigenous = models.TextField( verbose_name=_("Indigenous people affected"), help_text=_("What group or groups of indigenous people are affected by this project? \ @@ -352,6 +379,7 @@ class CaseStudy(models.Model): blank=True ) + # XXX Delete after migration people_affected_other = models.TextField( verbose_name=_("Non-indigenous people affected"), help_text=_("What other group or groups of people are affected by this project? \ @@ -361,17 +389,17 @@ class CaseStudy(models.Model): # 1.6 project_status = models.CharField( - verbose_name=_("Status of Project"), - help_text=_("What is the status of the current project?"), + verbose_name=_("Status of project"), max_length=6, choices=PROJECT_STATUS_CHOICES ) # 1.7 start_year = models.IntegerField( - verbose_name=_("Start year"), - help_text=_("Select the year the project was started. \ - If the project hasn't begun, select the projected start year."), + verbose_name=_("Construction start year"), + help_text=_("Select the year project construction began. If the project is not yet \ + in construction, select the assumed start year as detailed in company \ + information or media."), choices=YEAR_CHOICES, blank=True, null=True @@ -379,9 +407,10 @@ class CaseStudy(models.Model): # 1.8 completion_year = models.IntegerField( - verbose_name=_("Completion year"), - help_text=_("Select the year the project was completed. \ - If the project hasn't finished, select the projected completion year."), + verbose_name=_("Operation start year"), + help_text=_("Select the year the project's operation and maintenance (O&M) phase began. \ + If the project is not yet in operation, select the year operation is expected \ + to begin as detailed in company information or media."), choices=YEAR_CHOICES, default=None, null=True, @@ -399,18 +428,26 @@ class CaseStudy(models.Model): # 1.10 full_description = models.TextField( verbose_name=_("Full Description"), - help_text=_("Describe the project in full. Separate paragraphs with a\ - new line Please add as much detail as you feel is necessary\ + help_text=_("Describe the project in full. Separate paragraphs with two\ + new lines. Please add as much detail as you feel is necessary\ here.") ) # 1.11 project_owners = models.TextField( verbose_name=_("Project and facility owners"), - help_text=_("List companies or organisations that own the project and/or facilities. Separate with a new line."), + help_text=_("List companies or organisations that own the project and/or facilities. \ + Provide company numbers etc. if available. Separate with a new line."), blank=True ) + consultants_contractors = models.TextField( + verbose_name=_("Consultants and contractors"), + help_text=_("List consultants, planners or organisations that are doing the planning, \ + construction, operation or maintenance work relating to the project \ + and/or facilities. Separate each with a new line."), + ) + # 1.12 shareholders = models.TextField( verbose_name=_("Shareholders of the project owners"), @@ -421,8 +458,8 @@ class CaseStudy(models.Model): # 1.13.1 financial_institutions = MultiSelectField( verbose_name=_("Financial institutions"), - help_text=_("Select any financial institutions that have or are considering extending \ - loans or guarantees to the project."), + help_text=_("Select any financial institutions (public or private) that have, \ + or are considering, extending loans or guarantees to the project."), choices=FINANCIAL_INSTITUTIONS, blank=True ) @@ -437,9 +474,11 @@ class CaseStudy(models.Model): # 1.14 energy_customers = models.TextField( - verbose_name=_("Energy consumers"), - help_text=_("List any wholesale energy customers that take energy from the development. E.g. 'national \ - grids' or private energy suppliers. Please separate with a newline."), + 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 ) @@ -500,7 +539,8 @@ class CaseStudy(models.Model): direct_comms = models.TextField( verbose_name=_("Reports of direct communications"), help_text=_("Add any reports of direct communication between community members and \ - representatives of developers/companies/investors."), + representatives of developers/companies/investors. If you have files \ + to upload, you can do this in 'other documents' on the 'uploads' tab."), blank=True, ) diff --git a/apps/map/templates/map/form-case_study.html b/apps/map/templates/map/form-case_study.html index 33b9269..6827b31 100644 --- a/apps/map/templates/map/form-case_study.html +++ b/apps/map/templates/map/form-case_study.html @@ -137,6 +137,34 @@ }); } + 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(); @@ -180,6 +208,13 @@ conditionalCheckboxes.forEach(function(item){ $(item.checkbox).change(); }); + + for (const option of analysisToggles) { + const input = document.getElementById(option.input) + + $(input).on('change', showAnalysisSection); + $(input).trigger('change'); + } }); From 857634d1f10f4ba2f8bc81eed7d7b8a723b41d3d Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Sat, 24 Nov 2018 17:58:08 +0000 Subject: [PATCH 02/19] Through to row 101 --- apps/map/forms.py | 23 +++- apps/map/models.py | 104 ++++++++++++------ apps/map/templates/map/form-case_study.html | 111 +++++++++++--------- 3 files changed, 148 insertions(+), 90 deletions(-) diff --git a/apps/map/forms.py b/apps/map/forms.py index 6779fa7..471d8d1 100644 --- a/apps/map/forms.py +++ b/apps/map/forms.py @@ -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', diff --git a/apps/map/models.py b/apps/map/models.py index f6220f9..69ff021 100644 --- a/apps/map/models.py +++ b/apps/map/models.py @@ -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=_("
\ +

Please describe the source of the fuel and how it is processed/used. \ + Please consider:\ +

    \ +
  • where the fuel came from e.g. corn, forestry, algae, commercial food waste, \ + landfill gas, sewage, livestock farm, etc. \ +
  • 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. \ +
\ + \ +

We do not expect users to know this information, but if you do \ + it may be useful to give a fuller picture.\ +

"), 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 ) diff --git a/apps/map/templates/map/form-case_study.html b/apps/map/templates/map/form-case_study.html index 6827b31..a0a4ea6 100644 --- a/apps/map/templates/map/form-case_study.html +++ b/apps/map/templates/map/form-case_study.html @@ -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(); + }); }); From 2fb4f8771cb4bde9aa1e288802e273a01f8a29b3 Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Sat, 24 Nov 2018 18:30:58 +0000 Subject: [PATCH 03/19] Through row 116 --- apps/map/forms.py | 1 + apps/map/models.py | 35 ++++++------------- apps/map/templates/map/detail.html | 14 +++----- apps/map/templates/map/form-case_study.html | 38 +++++++++++++++------ 4 files changed, 43 insertions(+), 45 deletions(-) diff --git a/apps/map/forms.py b/apps/map/forms.py index 471d8d1..f2df2df 100644 --- a/apps/map/forms.py +++ b/apps/map/forms.py @@ -329,6 +329,7 @@ class LongCaseStudyForm(BaseCaseStudyForm): 'power_technology', 'power_technology_other', 'energy_storage_capacity', + 'energy_transmission_capacity', 'maximum_power_output', 'discharge_time', 'contractor_or_supplier_of_technology', diff --git a/apps/map/models.py b/apps/map/models.py index 69ff021..d01df0f 100644 --- a/apps/map/models.py +++ b/apps/map/models.py @@ -661,37 +661,22 @@ class CaseStudy(models.Model): # 2.2.1.4 power_technology_other = models.CharField( - verbose_name=_("Other power technology"), - help_text=_("Please specify the power technology."), + verbose_name=_("Further information about power technology"), max_length=128, blank=True ) - # 2.2.2 energy_storage_capacity = models.DecimalField( - verbose_name=_("Energy storage capacity"), - help_text=_("Enter the total capacity of the energy storage system in kilowatt-hours (kWh)."), + verbose_name=_("Total storage capacity (kWh)"), max_digits=20, decimal_places=3, blank=True, null=True, ) - # 2.2.2.1 - maximum_power_output = models.DecimalField( - verbose_name=_('Maximum power output'), - help_text=_('Enter the maximum power output of the storage system in kilowatts (kW).'), - max_digits=12, - decimal_places=3, - blank=True, - null=True, - ) - - # 2.2.2.2 - discharge_time = models.DecimalField( - 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).'), - max_digits=6, + energy_transmission_capacity = models.DecimalField( + verbose_name=_("Total transmission capacity (kW)"), + max_digits=20, decimal_places=3, blank=True, null=True, @@ -700,7 +685,7 @@ class CaseStudy(models.Model): # 2.2.3 contractor_or_supplier_of_technology = models.CharField( verbose_name=_('Contractor and/or supplier of technology'), - help_text=_('List companies that act as contractors or suppliers of technology related to energy storage.'), + 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 ) @@ -715,10 +700,12 @@ class CaseStudy(models.Model): ) # 2.2.5 - additional_technical_details = models.CharField( + additional_technical_details = models.TextField( verbose_name=_("Additional technical or economic details"), - help_text=_("Add any additional details such as: length, from-to, voltage, substations etc"), - max_length=512, + help_text=_("Add any additional details such as: length, from-to, voltage, \ + substations, power output, (dis)charge rates, how this technology or \ + project interacts with the energy system (e.g. provides reactive power \ + to ensure power supply in phase etc.)"), blank=True ) diff --git a/apps/map/templates/map/detail.html b/apps/map/templates/map/detail.html index 2e04fca..b061b90 100644 --- a/apps/map/templates/map/detail.html +++ b/apps/map/templates/map/detail.html @@ -301,16 +301,10 @@ dd ul { padding-left: 0; margin-left: 0; } {{ case_study.energy_storage_capacity }} TODO UNITS? {% endif %} - {% if case_study.maximum_power_output %} -
{% trans "Maximum power output" %}: -
- {{ case_study.maximum_power_output | intcomma }} W - {% endif %} - - {% if case_study.discharge_time %} -
{% trans "Time for discharge from full capacity" %}: -
- {{ case_study.discharge_time | intcomma }} {% trans "seconds" %} + {% if case_study.energy_transmission_capacity %} +
{% trans "Energy transmission capacity" %}: +
+ {{ case_study.energy_transmission_capacity }} TODO UNITS? {% endif %} {% if case_study.contractor_or_supplier_of_technology %} diff --git a/apps/map/templates/map/form-case_study.html b/apps/map/templates/map/form-case_study.html index a0a4ea6..e7b96bf 100644 --- a/apps/map/templates/map/form-case_study.html +++ b/apps/map/templates/map/form-case_study.html @@ -40,6 +40,14 @@ - {% endblock %} From aac22da18c377c241f27820892d9a0db09dccda6 Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Mon, 26 Nov 2018 21:14:18 +0000 Subject: [PATCH 09/19] Make better use of horizontal space --- apps/map/forms.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/map/forms.py b/apps/map/forms.py index a259702..6b23479 100644 --- a/apps/map/forms.py +++ b/apps/map/forms.py @@ -63,8 +63,8 @@ class BaseCaseStudyForm(forms.models.ModelForm): self.helper.form_class = 'form-horizontal' self.helper.form_method = 'post' self.helper.form_action = 'add' - self.helper.label_class = 'col-lg-2' - self.helper.field_class = 'col-lg-8' + self.helper.label_class = 'col-md-3' + self.helper.field_class = 'col-md-9' self.helper.include_media = False class Meta: From 04b8ae7bf9267ef16bef011c06613d81c6dad228 Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Mon, 26 Nov 2018 22:34:06 +0000 Subject: [PATCH 10/19] Implement Tom's emailed suggestions --- apps/map/forms.py | 85 ++++++++------ apps/map/models.py | 120 +++++++++----------- apps/map/templates/map/form-case_study.html | 46 +++++--- 3 files changed, 133 insertions(+), 118 deletions(-) diff --git a/apps/map/forms.py b/apps/map/forms.py index 6b23479..c6275a9 100644 --- a/apps/map/forms.py +++ b/apps/map/forms.py @@ -179,17 +179,19 @@ class LongCaseStudyForm(BaseCaseStudyForm): SECTOR_HELP = { 'RN': _("including electricity, heat or combined heat and power generation"), 'PG': '', + 'ST': _('Biological, chemical, electrical, electromagnetic, electrochemical, mechanical including gravitational potential, thermal etc.'), 'SM': _("including supply of minerals"), 'MA': '', } 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': '', } + # TODO: Allow explanatory_text to not contain text for every option + # TODO: Only output if there is explanatory text def add_explanatory_text(self, model_choices, explanatory_text): return [ ( @@ -203,11 +205,8 @@ class LongCaseStudyForm(BaseCaseStudyForm): def __init__(self, *args, **kwargs): super(LongCaseStudyForm, self).__init__(*args, **kwargs) - self.fields['positive_case_type'] = forms.ChoiceField( - widget=forms.RadioSelect(), - choices=CaseStudy.POSITIVE_CASE_TYPE_CHOICES, - required=False - ) + self.fields['positive_case_type'].label = "" + self.fields['negative_case_reasons'].label = "" self.fields['sector_of_economy'] = forms.ChoiceField( widget=forms.RadioSelect(), @@ -282,6 +281,7 @@ class LongCaseStudyForm(BaseCaseStudyForm): 'type_of_ecosystem', 'describe_ecosystem', 'affected_communities', + 'people_affected_other', 'project_status', 'synopsis', 'full_description', @@ -297,7 +297,6 @@ class LongCaseStudyForm(BaseCaseStudyForm): 'shareholders', 'financial_institutions', 'financial_institutions_other', - 'energy_customers' ), Fieldset( _("Media reports and other communications"), @@ -314,31 +313,41 @@ class LongCaseStudyForm(BaseCaseStudyForm): Tab( _("Technical and economic analysis"), 'sector_of_economy', - Fieldset( - '', + Div( 'generation_type', 'generation_technology', - 'biomass_detail', - 'generation_technology_other', - 'total_generation_capacity', - 'generation_equipment_supplier', - PrependedText('total_investment', 'USD$'), - 'technical_or_economic_details', - css_id="power_generation_questions" + css_class='power_generation_questions' ), - Fieldset( - '', + Div( 'power_technology', - 'power_technology_other', - '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" + css_class='energy_network_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_other', 'use_in_energy_economy', @@ -348,17 +357,16 @@ class LongCaseStudyForm(BaseCaseStudyForm): 'projected_production_of_commodities', 'type_of_extraction', 'associated_infrastructure', - css_id="mineral_commodity_questions" + css_class="mineral_commodity_questions" ), - Fieldset( - '', + Div( 'manufacturing_type', 'manufacturing_description', 'manufacturing_related_tech', 'manufacturing_factors', 'manufacturing_factors_description', 'manufacturing_ownership', - css_id="manufacturing_questions" + css_class="manufacturing_questions" ), FormActions( HTML(""+_("Previous")+""), @@ -369,9 +377,15 @@ class LongCaseStudyForm(BaseCaseStudyForm): _("Socio-environmental analysis"), HTML("

" + _("In the following, we expect the analysis to reflect the perspective of the organization(s) or person(s) describing the case.") + "

"), 'positive_or_negative', - HTML("What kind of case is this entry about?"), - 'positive_case_type', - 'negative_case_reasons', + Div( + HTML(""), + Div( + 'positive_case_type', + 'negative_case_reasons', + css_class='col-md-9', + ), + css_class='form-group', + ), 'negative_case_reasons_other', 'socioeconomic_benefits', 'isolated_or_widespread', @@ -383,10 +397,9 @@ class LongCaseStudyForm(BaseCaseStudyForm): 'who_has_been_involved', 'participation_mechanisms', 'identified_partnerships', - 'potential_partnerships', 'wants_conversation_with_ojuso', Div( - css_id="common_questions" + css_class="common_questions" ), FormActions( HTML(""+_("Previous")+""), diff --git a/apps/map/models.py b/apps/map/models.py index 17a0097..54cae60 100644 --- a/apps/map/models.py +++ b/apps/map/models.py @@ -53,13 +53,6 @@ class CaseStudy(models.Model): approved = models.BooleanField(default=False) # 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 = ( ('P', _('There is/was an organising process in favour of the project')), ('N', _('There is/was an organising process against the project')), @@ -139,6 +132,14 @@ class CaseStudy(models.Model): ('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 = ( ('POW', _('Power')), ('HOT', _('Heat/Cool')), @@ -177,7 +178,6 @@ class CaseStudy(models.Model): POWER_TECHNOLOGY_CHOICES = ( ('PT', _('Electrical power transmission')), - ('ES', _('Energy storage')), ('HN', _('Heat networks')), ('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')), ('PSEP', _('Public/state (federal, state, municipal) project')), ('CORS', _('Reuse / Recycling / Circular economy project')), - ('OTHR', _('Other(s)')) ) - NEGATIVE_CASE_REASONS_OTHER_TEXT = _('Other reasons') - NEGATIVE_CASE_REASONS_CHOICES = ( ('VOLR', _('Violation of land rights')), ('VOHR', _('Violation of fundamental human rights, indigenous rights and/or other collective rights')), @@ -291,14 +288,6 @@ class CaseStudy(models.Model): etc')), ('ALAB', _('Abusive labour practices')), ('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. @@ -378,13 +367,6 @@ class CaseStudy(models.Model): max_length=128 ) - # 1.2 - sector_of_economy = models.CharField( - verbose_name=_("Sector of economy"), - max_length=3, - choices=SECTOR_CHOICES - ) - # 1.4 country = CountryField( verbose_name=_("Country"), @@ -447,7 +429,7 @@ class CaseStudy(models.Model): blank=True ) - # XXX Delete after migration + # XXX Delete after migration - merge into affected_communities people_affected_indigenous = models.TextField( verbose_name=_("Indigenous people affected"), help_text=_("What group or groups of indigenous people are affected by this project? \ @@ -455,11 +437,10 @@ class CaseStudy(models.Model): blank=True ) - # XXX Delete after migration people_affected_other = models.TextField( - verbose_name=_("Non-indigenous people affected"), - help_text=_("What other group or groups of people are affected by this project? \ - Please separate by newline."), + verbose_name=_("Communities or identities – further detail"), + help_text=_("Please describe further the communities or identities present \ + in the project area."), blank=True ) @@ -548,16 +529,6 @@ class CaseStudy(models.Model): 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 images = models.ManyToManyField( 'files.ImageFile', @@ -632,6 +603,19 @@ class CaseStudy(models.Model): # 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 generation_type = models.CharField( @@ -649,15 +633,6 @@ class CaseStudy(models.Model): 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 biomass_detail = models.CharField( verbose_name=_("Bio-energy feedstock"), @@ -679,6 +654,16 @@ class CaseStudy(models.Model): 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 total_generation_capacity = models.PositiveIntegerField( verbose_name=_("Total generation capacity (in kW)"), @@ -687,8 +672,7 @@ class CaseStudy(models.Model): null=True ) - # 2.1.3 - # TODO: Auto-completion based on previous entries so we can query case-studies with the same answer. + # XXX Delete after migration - merge into contractor_or_supplier_of_technology generation_equipment_supplier = models.TextField( 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.)"), @@ -698,12 +682,12 @@ class CaseStudy(models.Model): # 2.1.4 total_investment = models.IntegerField( 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, null=True ) - # 2.1.5 + # XXX Delete after migration - merge into additional_technical_details technical_or_economic_details = models.TextField( verbose_name=_("Additional technical or economic details"), help_text=_("Specify any additional technical or economic details relating to the project."), @@ -742,7 +726,7 @@ class CaseStudy(models.Model): null=True, ) - # XXX Delete after migration + # XXX Delete after migration - no merge maximum_power_output = models.DecimalField( verbose_name=_('Maximum power output'), help_text=_('Enter the maximum power output of the storage system in kilowatts (kW).'), @@ -752,7 +736,7 @@ class CaseStudy(models.Model): null=True, ) - # XXX Delete after migration + # XXX Delete after migration - no merge discharge_time = models.DecimalField( 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).'), @@ -762,15 +746,14 @@ class CaseStudy(models.Model): null=True ) - # 2.2.3 - contractor_or_supplier_of_technology = models.CharField( + # TODO: Auto-completion based on previous entries so we can query case-studies with the same answer. + contractor_or_supplier_of_technology = models.TextField( 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'), - max_length=256, blank=True, ) - # 2.2.4 + # XXX Delete after migration - merge into total_investment approximate_total_investment = models.PositiveIntegerField( verbose_name=_('Approximate total investment'), help_text=_('Enter the approximate total investment in USD ($).'), @@ -910,11 +893,10 @@ class CaseStudy(models.Model): choices=POSITIVE_NEGATIVE_CHOICES ) - positive_case_type = models.CharField( + positive_case_type = MultiSelectField( 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, - max_length=4, + max_length=32, blank=True, ) @@ -1007,6 +989,15 @@ class CaseStudy(models.Model): 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 wants_conversation_with_ojuso = models.BooleanField( 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)""" 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 def get_renewable_generation_detail(self): diff --git a/apps/map/templates/map/form-case_study.html b/apps/map/templates/map/form-case_study.html index 992b056..f64e785 100644 --- a/apps/map/templates/map/form-case_study.html +++ b/apps/map/templates/map/form-case_study.html @@ -63,6 +63,10 @@ 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` function isOneOf(conditions) { return elem => conditions.includes(elem.value) @@ -84,7 +88,7 @@ // Technical/economic tab { control: 'sector_of_economy', - showHide: '#power_generation_questions', + showHide: '.power_generation_questions', visible: isJust('RN') // Energy generation project }, { @@ -95,29 +99,29 @@ { control: 'sector_of_economy', - showHide: '#power_grids_energy_storage_questions', - visible: isJust('PG') // Energy networks or storage (stands for 'power grid') + showHide: '.energy_network_questions', + visible: isJust('PG') // Energy networks (PG = power grid) }, - { control: 'power_technology', showHide: '#div_id_power_technology_other', visible: isJust('OT') }, - { - control: 'power_technology', - showHide: '#div_id_energy_storage_capacity', - visible: isOneOf(['ES', 'OT']) // Storage / other - }, - { - control: 'power_technology', - showHide: '#div_id_energy_transmission_capacity', - visible: isOneOf(['PT', 'HN', 'OT']) // Transmission / heat / other - }, + + { + control: 'sector_of_economy', + showHide: '.energy_storage_questions', + visible: isJust('ST') // Storage + }, + { + control: 'sector_of_economy', + showHide: '.energy_generation_network_and_storage_questions', + visible: isOneOf(['RN', 'ST', 'PG']) // Generation (RN), Storage (ST) and networks (PG) + }, { control: 'sector_of_economy', - showHide: '#mineral_commodity_questions', + showHide: '.mineral_commodity_questions', visible: isJust('SM') // mining }, { @@ -128,12 +132,22 @@ { control: 'sector_of_economy', - showHide: '#manufacturing_questions', + showHide: '.manufacturing_questions', visible: isJust('MA') // manufacturing }, // 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', showHide: '#div_id_obstacles_and_hindrances', From 4e86794a6cbec47be98fb0a9d7e3ad0e5d4d0382 Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Mon, 26 Nov 2018 23:32:31 +0000 Subject: [PATCH 11/19] Some design improvements --- apps/map/templates/map/form-case_study.html | 7 ++++++- assets/css/ojuso.css | 4 ++++ ojusomap/templates/base_page.html | 8 ++++---- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/map/templates/map/form-case_study.html b/apps/map/templates/map/form-case_study.html index f64e785..1be9d25 100644 --- a/apps/map/templates/map/form-case_study.html +++ b/apps/map/templates/map/form-case_study.html @@ -4,9 +4,14 @@ {% block stylesheets %} {{ block.super }} {% leaflet_css %} + {% endblock %} -{% block page_title %}{% trans "Submit a Case Study" %} - {{ block.super }}{% endblock %} +{% block page_title %}{% trans "New Case Study" %} - {{ block.super }}{% endblock %} +{% block title %}{% trans "New Case Study" %}{% endblock %} + {% block description %}{% trans "Here you can submit a case study for review and it will be added to the map." %}{% endblock %} {% block inner %} diff --git a/assets/css/ojuso.css b/assets/css/ojuso.css index ec1717c..345f519 100644 --- a/assets/css/ojuso.css +++ b/assets/css/ojuso.css @@ -1,3 +1,7 @@ +h1 { + font-weight: bold; +} + /* Make sure that the footer doesn't have space after it */ .container { min-height: 60vh; } diff --git a/ojusomap/templates/base_page.html b/ojusomap/templates/base_page.html index 99b138a..335072b 100644 --- a/ojusomap/templates/base_page.html +++ b/ojusomap/templates/base_page.html @@ -5,8 +5,8 @@ {{ block.super }} {% endblock %} @@ -16,8 +16,8 @@
-

{% block title %}{% endblock %}

-

{% block description %}{% endblock %}

+

{% block title %}{% endblock %}

+

{% block description %}{% endblock %}

{% block inner %} From 8745800af675e32198cd88c35ed0d69a7eab95d6 Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Mon, 26 Nov 2018 23:35:29 +0000 Subject: [PATCH 12/19] Add note about writing policy/technology analysis --- apps/map/templates/map/form-selector.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/map/templates/map/form-selector.html b/apps/map/templates/map/form-selector.html index 9bc1875..882d5e6 100644 --- a/apps/map/templates/map/form-selector.html +++ b/apps/map/templates/map/form-selector.html @@ -80,6 +80,8 @@
+

If you are interested in writing a technology assessment or policy analysis to appear on this site, please email info@ojuso.org.

+ From dd54a7a2f96055d71d2b0b79cb16638dd59a2d48 Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Mon, 26 Nov 2018 23:56:36 +0000 Subject: [PATCH 13/19] Ask for start and completion years --- apps/map/forms.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/apps/map/forms.py b/apps/map/forms.py index c6275a9..afa02bf 100644 --- a/apps/map/forms.py +++ b/apps/map/forms.py @@ -283,6 +283,8 @@ class LongCaseStudyForm(BaseCaseStudyForm): 'affected_communities', 'people_affected_other', 'project_status', + 'start_year', + 'completion_year', 'synopsis', 'full_description', 'images', From e1ff5b64cf495cee422e4953ea40e1a011023b14 Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Mon, 26 Nov 2018 23:56:58 +0000 Subject: [PATCH 14/19] Make conditional form logic more terse --- apps/map/templates/map/form-case_study.html | 134 ++++++++------------ 1 file changed, 50 insertions(+), 84 deletions(-) diff --git a/apps/map/templates/map/form-case_study.html b/apps/map/templates/map/form-case_study.html index 1be9d25..e1c276a 100644 --- a/apps/map/templates/map/form-case_study.html +++ b/apps/map/templates/map/form-case_study.html @@ -58,16 +58,23 @@ $(thingToShow).hide() } } + + // Constructor function to make list below more terse + function show(condition, selector) { + return { showHide: selector, visible: condition } + } + // Returns true if checkbox is checked function isChecked(elem) { return elem.checked } // Returns a function that returns true if its parameter matches `condition` - function isJust(condition) { + function isEqual(condition) { return elem => elem.value === condition } + // Inverse of the above function isNot(condition) { return elem => elem.value !== condition } @@ -82,95 +89,51 @@ // TODO: Move this knowledge out of the template // - var showHideFields = [ + var showHideFields = { // 'Basic information' tab - { - control: 'location_context', - showHide: '#div_id_type_of_ecosystem', - visible: isJust('RUR') // Rural - }, + 'location_context': [ + show(isEqual('RUR'), '#div_id_type_of_ecosystem'), // Rural + ], // Technical/economic tab - { - control: 'sector_of_economy', - showHide: '.power_generation_questions', - visible: isJust('RN') // Energy generation project - }, - { - control: 'generation_technology', - showHide: '#div_id_biomass_detail', - visible: isJust('BIO') // Bio-energy - }, + 'sector_of_economy': [ + show(isEqual('RN'), '.power_generation_questions'), // Energy generation project + show(isEqual('PG'), '.energy_network_questions'), // Energy networks (PG = power grid) + show(isEqual('ST'), '.energy_storage_questions'), // Storage + show(isOneOf(['RN', 'ST', 'PG']), + '.energy_generation_network_and_storage_questions'), + show(isEqual('SM'), '.mineral_commodity_questions'), // Mining + show(isEqual('MA'), '.manufacturing_questions'), // Manufacturing + ], - { - control: 'sector_of_economy', - showHide: '.energy_network_questions', - visible: isJust('PG') // Energy networks (PG = power grid) - }, - { - control: 'power_technology', - showHide: '#div_id_power_technology_other', - visible: isJust('OT') - }, + 'use_in_energy_economy': [ + show(isEqual('OTR'), '#div_id_use_in_energy_economy_other'), + ], - { - control: 'sector_of_economy', - showHide: '.energy_storage_questions', - visible: isJust('ST') // Storage - }, - { - control: 'sector_of_economy', - showHide: '.energy_generation_network_and_storage_questions', - visible: isOneOf(['RN', 'ST', 'PG']) // Generation (RN), Storage (ST) and networks (PG) - }, - - { - control: 'sector_of_economy', - showHide: '.mineral_commodity_questions', - visible: isJust('SM') // mining - }, - { - control: 'use_in_energy_economy', - showHide: '#div_id_use_in_energy_economy_other', - visible: isJust('OTR') - }, - - { - control: 'sector_of_economy', - showHide: '.manufacturing_questions', - visible: isJust('MA') // manufacturing - }, + 'power_technology': [ + show(isEqual('OT'), '#div_id_power_technology_other'), + ], + 'generation_technology': [ + show(isEqual('BIO'), '#div_id_biomass_detail'), // Bio-energy + ], // 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', - showHide: '#div_id_obstacles_and_hindrances', - visible: isOneOf(['P', 'N']) // positive/negative (process pro / vs) - }, - { - control: 'negative_case_reasons', - showHide: '#div_id_negative_case_reasons_other', - visible: isJust('OTHR') - }, + 'positive_or_negative': [ + show(isNot('N'), '#div_id_positive_case_type'), + show(isNot('P'), '#div_id_negative_case_reasons'), + show(isOneOf([ 'P', 'N' ]), '#div_id_obstacles_and_hindrances'), + ], + + 'negative_case_reasons': [ + show(isEqual('OTHR'), '#div_id_negative_case_reasons_other'), + ], // Contact tab - { - control: 'shown_on_other_platforms', - showHide: '#div_id_shown_on_other_platforms_detail', - visible: isChecked - }, - ]; + 'shown_on_other_platforms': [ + show(isChecked, '#div_id_shown_on_other_platforms_detail'), + ], + }; // // Fields that require their own more advanced logic @@ -244,12 +207,15 @@ $('form').attr('novalidate', 'novalidate'); // Add conditional form show/hide logic - for (const item of showHideFields) { - const control = document.forms['case-study-form'][item.control] + for (const field of Object.keys(showHideFields)) { + const control = document.forms['case-study-form'][field] $(control).change(() => { - // Check the value matches any of the conditions. - showIf(item.showHide, item.visible(control)) + + for (const row of showHideFields[field]) { + // Check the value matches any of the conditions. + showIf(row.showHide, row.visible(control)) + } }); $(control).change(); From b240a110b3bfe7333167d5678b7e1bf81b1aaff4 Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Sun, 2 Dec 2018 00:30:38 +0000 Subject: [PATCH 15/19] Fix many-to-many field saving for Django 2.1 --- apps/map/views.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/apps/map/views.py b/apps/map/views.py index 0a34a95..4dffba6 100644 --- a/apps/map/views.py +++ b/apps/map/views.py @@ -75,18 +75,18 @@ class BaseForm(LoginRequiredMixin, CreateView): self.object = form.save() - self.object.official_project_documents = form.cleaned_data.get( + self.object.official_project_documents.set(form.cleaned_data.get( 'official_project_documents_files', [] - ) - self.object.other_documents = form.cleaned_data.get( + )) + self.object.other_documents.set(form.cleaned_data.get( 'other_documents_files', [] - ) - self.object.shapefiles = form.cleaned_data.get( + )) + self.object.shapefiles.set(form.cleaned_data.get( 'shapefiles_files', [] - ) - self.object.images = form.cleaned_data.get( + )) + self.object.images.set(form.cleaned_data.get( 'images_files', [] - ) + )) self.object.author = self.request.user self.object.save() From 5c7d4005f0a31760430dcb0af6e115634186bd8c Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Sun, 2 Dec 2018 00:31:04 +0000 Subject: [PATCH 16/19] Add migration --- .../migrations/0007_auto_20181201_2315.py | 25 ++ .../map/migrations/0072_auto_20181201_2315.py | 309 ++++++++++++++++++ apps/map/models.py | 1 + 3 files changed, 335 insertions(+) create mode 100644 apps/files/migrations/0007_auto_20181201_2315.py create mode 100644 apps/map/migrations/0072_auto_20181201_2315.py diff --git a/apps/files/migrations/0007_auto_20181201_2315.py b/apps/files/migrations/0007_auto_20181201_2315.py new file mode 100644 index 0000000..b7c4247 --- /dev/null +++ b/apps/files/migrations/0007_auto_20181201_2315.py @@ -0,0 +1,25 @@ +# Generated by Django 2.1.1 on 2018-12-01 23:15 + +from django.conf import settings +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('files', '0006_auto_20180928_1323'), + ] + + operations = [ + migrations.AlterField( + model_name='file', + name='user', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='file', to=settings.AUTH_USER_MODEL), + ), + migrations.AlterField( + model_name='imagefile', + name='user', + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, related_name='imagefile', to=settings.AUTH_USER_MODEL), + ), + ] diff --git a/apps/map/migrations/0072_auto_20181201_2315.py b/apps/map/migrations/0072_auto_20181201_2315.py new file mode 100644 index 0000000..5ea22bd --- /dev/null +++ b/apps/map/migrations/0072_auto_20181201_2315.py @@ -0,0 +1,309 @@ +# Generated by Django 2.1.1 on 2018-12-01 23:15 + +from django.db import migrations, models +import django.db.models.deletion +import django_extensions.db.fields +import multiselectfield.db.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('map', '0071_point_of_interest'), + ] + + operations = [ + migrations.AlterModelOptions( + name='pointofinterest', + options={'verbose_name_plural': 'points of interest'}, + ), + migrations.RemoveField( + model_name='casestudy', + name='generation_technology_other', + ), + migrations.AddField( + model_name='casestudy', + name='affected_communities', + field=multiselectfield.db.fields.MultiSelectField(blank=True, choices=[('INDIG', 'Indigenous'), ('AFRO', 'Afro-descendants'), ('MIG', 'Migrants'), ('REF', 'Refugees'), ('OTHER', 'Other communities or identities')], max_length=50, verbose_name='Communities or identities present in the project area'), + ), + migrations.AddField( + model_name='casestudy', + name='consultants_contractors', + field=models.TextField(blank=True, help_text='List consultants, planners or organisations that are doing the planning, construction, operation or maintenance work relating to the project and/or facilities. Separate each with a new line.', verbose_name='Consultants and contractors'), + ), + migrations.AddField( + model_name='casestudy', + name='energy_details', + field=models.CharField(blank=True, help_text='Please give more information about the transmission, network or storage technology.', max_length=200, verbose_name='Further details'), + ), + migrations.AddField( + model_name='casestudy', + name='energy_transmission_capacity', + field=models.DecimalField(blank=True, decimal_places=3, max_digits=20, null=True, verbose_name='Total transmission capacity (kW)'), + ), + migrations.AddField( + model_name='casestudy', + name='generation_type', + field=models.CharField(blank=True, choices=[('POW', 'Power'), ('HOT', 'Heat/Cool'), ('CHP', 'Combined Heat/Cool and Power (CHP)')], max_length=4, verbose_name='What is being generated?'), + ), + migrations.AddField( + model_name='casestudy', + name='manufacturing_description', + field=models.TextField(blank=True, help_text='Briefly describe manufacturing process and components/outputs. (less than 500 characters, about 2 tweets).', max_length=500, verbose_name='Description'), + ), + migrations.AddField( + model_name='casestudy', + name='manufacturing_factors', + field=multiselectfield.db.fields.MultiSelectField(blank=True, choices=[('LAND', 'Land use'), ('LABOR', 'Labor rights'), ('ENVIRO', 'Environmental factors'), ('LIFECYCLE', 'Lifecycle management'), ('OWN', 'Ownership'), ('OTHER', 'Other(s)')], max_length=128, verbose_name='Choose the factors that make this case remarkable, in a positive or negative way'), + ), + migrations.AddField( + model_name='casestudy', + name='manufacturing_factors_description', + field=models.TextField(blank=True, verbose_name='Describe these factors'), + ), + migrations.AddField( + model_name='casestudy', + name='manufacturing_ownership', + field=models.TextField(blank=True, verbose_name='Describe the ownership structure of the project and its relation with the local community'), + ), + migrations.AddField( + model_name='casestudy', + name='manufacturing_related_tech', + field=multiselectfield.db.fields.MultiSelectField(blank=True, choices=[('PV', 'Solar PV'), ('CSP', 'CSP'), ('WIND', 'Wind power'), ('HYDRO', 'Hydropower'), ('GEO', 'Geothermal'), ('TRANSMIT', 'Electrical power transmission infrastructure'), ('STORE', 'Energy storage'), ('HEAT', 'Heat networks'), ('OTHER', 'Other'), ('IDK', 'Unknown')], max_length=128, verbose_name='What technology is this case related to?'), + ), + migrations.AddField( + model_name='casestudy', + name='manufacturing_type', + field=models.CharField(blank=True, choices=[('GENERATE', 'Manufacturing of renewable energy generation equipment'), ('TRANSSTORE', 'Manufacturing of energy transmission or storage equipment'), ('RECYCLE', 'Recycling / reusing equipment or raw materials'), ('DISPOSAL', 'Disposal of equipment'), ('OTHER', 'Other')], max_length=16, verbose_name='Which of the following options best describes this case?'), + ), + migrations.AlterField( + model_name='casestudy', + name='additional_technical_details', + field=models.TextField(blank=True, help_text='Add any additional details such as: length, from-to, voltage, substations, power output, (dis)charge rates, how this technology or project interacts with the energy system (e.g. provides reactive power to ensure power supply in phase etc.)', verbose_name='Additional technical or economic details'), + ), + migrations.AlterField( + model_name='casestudy', + name='biomass_detail', + field=models.CharField(blank=True, help_text="

Please describe the source of the fuel and how it is processed/used. Please consider:

  • where the fuel came from e.g. corn, forestry, algae, commercial food waste, landfill gas, sewage, livestock farm, etc.
  • 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.

We do not expect users to know this information, but if you do it may be useful to give a fuller picture.

", max_length=200, verbose_name='Bio-energy feedstock'), + ), + migrations.AlterField( + model_name='casestudy', + name='completion_year', + field=models.IntegerField(blank=True, choices=[(1978, 1978), (1979, 1979), (1980, 1980), (1981, 1981), (1982, 1982), (1983, 1983), (1984, 1984), (1985, 1985), (1986, 1986), (1987, 1987), (1988, 1988), (1989, 1989), (1990, 1990), (1991, 1991), (1992, 1992), (1993, 1993), (1994, 1994), (1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024), (2025, 2025), (2026, 2026), (2027, 2027), (2028, 2028), (2029, 2029), (2030, 2030), (2031, 2031), (2032, 2032), (2033, 2033), (2034, 2034), (2035, 2035), (2036, 2036), (2037, 2037), (2038, 2038), (2039, 2039), (2040, 2040), (2041, 2041), (2042, 2042), (2043, 2043), (2044, 2044), (2045, 2045), (2046, 2046), (2047, 2047), (2048, 2048), (2049, 2049), (2050, 2050), (2051, 2051), (2052, 2052), (2053, 2053), (2054, 2054), (2055, 2055), (2056, 2056), (2057, 2057), (2058, 2058)], default=None, help_text="Select the year the project's operation and maintenance (O&M) phase began. If the project is not yet in operation, select the year operation is expected to begin as detailed in company information or media.", null=True, verbose_name='Operation start year'), + ), + migrations.AlterField( + model_name='casestudy', + name='contractor_or_supplier_of_technology', + field=models.TextField(blank=True, help_text='List companies that act as contractors or suppliers –\xa0e.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', verbose_name='Contractor and/or supplier of technology'), + ), + migrations.AlterField( + model_name='casestudy', + name='coordinate_reference_system', + field=models.ForeignKey(blank=True, default=4326, null=True, on_delete=django.db.models.deletion.PROTECT, to='map.SpatialRefSys'), + ), + migrations.AlterField( + model_name='casestudy', + name='describe_ecosystem', + field=models.TextField(verbose_name='Describe the ecosystem'), + ), + migrations.AlterField( + model_name='casestudy', + name='direct_comms', + field=models.TextField(blank=True, help_text="Add any reports of direct communication between community members and representatives of developers/companies/investors. If you have files to upload, you can do this in 'other documents' on the 'uploads' tab.", verbose_name='Reports of direct communications'), + ), + migrations.AlterField( + model_name='casestudy', + name='energy_customers', + field=models.TextField(blank=True, 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.", verbose_name='Energy service consumers/off-takers'), + ), + migrations.AlterField( + model_name='casestudy', + name='energy_storage_capacity', + field=models.DecimalField(blank=True, decimal_places=3, max_digits=20, null=True, verbose_name='Total storage capacity (kWh)'), + ), + migrations.AlterField( + model_name='casestudy', + name='entry_name', + field=models.CharField(help_text='This should usually be the name of the project. If you are writing this case study in a language not used in the locale of its project, you should provide its local name first, as well as any translated name.', max_length=128, verbose_name='Entry Name'), + ), + migrations.AlterField( + model_name='casestudy', + name='financial_institutions', + field=multiselectfield.db.fields.MultiSelectField(blank=True, choices=[('AfDB', 'African Development Bank (AfDB)'), ('BADEA', 'Arab Bank for Economic Development in Africa (BADEA)'), ('ADB', 'Asian Development Bank (ADB)'), ('AIIB', 'Asian Infrastructure Investment Bank (AIIB)'), ('BSTDB', 'Black Sea Trade and Development Bank (BSTDB)'), ('CAF', 'Corporacion Andina de Fomento / Development Bank of Latin America (CAF)'), ('CDB', 'Caribbean Development Bank (CDB)'), ('CABEI', 'Central American Bank for Economic Integration (CABEI)'), ('EADB', 'East African Development Bank (EADB)'), ('ETDB', 'Economic Cooperation Organization Trade and Development Bank (ETDB)'), ('EDB', 'Eurasian Development Bank (EDB)'), ('EBRD', 'European Bank for Reconstruction and Development (EBRD)'), ('EC', 'European Commission (EC)'), ('EIB', 'European Investment Bank (EIB)'), ('IADB', 'Inter-American Development Bank Group (IDB, IADB)'), ('IFFIm', 'International Finance Facility for Immunisation (IFFIm)'), ('IFAD', 'International Fund for Agricultural Development (IFAD)'), ('IIB', 'International Investment Bank (IIB)'), ('IsDB', 'Islamic Development Bank (IsDB)'), ('FMO', 'Nederlandse Financieringsmaatschappij voor Ontwikkelingslanden NV (FMO)'), ('NDB', 'New Development Bank (NDB) (formerly BRICS Development Bank)'), ('NDF', 'The Nordic Development Fund'), ('NIB', 'Nordic Investment Bank (NIB)'), ('OFID', 'OPEC Fund for International Development (OFID)'), ('BOAD', 'West African Development Bank (BOAD)'), ('WB', 'World Bank')], help_text='Select any financial institutions (public or private) that have, or are considering, extending loans or guarantees to the project.', max_length=119, verbose_name='Financial institutions'), + ), + migrations.AlterField( + model_name='casestudy', + name='full_description', + field=models.TextField(help_text='Describe the project in full. Separate paragraphs with two new lines. Please add as much detail as you feel is necessary here.', verbose_name='Full Description'), + ), + migrations.AlterField( + model_name='casestudy', + name='generation_equipment_supplier', + field=models.TextField(blank=True, 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.)', verbose_name='Generation equipment supplier(s)'), + ), + migrations.AlterField( + model_name='casestudy', + name='generation_technology', + field=models.CharField(blank=True, choices=[('BIO', 'Bio-energy'), ('GEOT', 'Geothermal electricity'), ('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)')], help_text='Select the type of renewable energy generation that most applies to this case study.', max_length=4, verbose_name='Generation technology'), + ), + migrations.AlterField( + model_name='casestudy', + name='identified_partnerships', + field=models.CharField(blank=True, help_text='Are you, or the organizing process that you represent, looking for partnerships, or have any clearly identified need? If so, please describe and we will try to connect you to appropriate partners.', max_length=256, verbose_name='Identified partnerships'), + ), + migrations.AlterField( + model_name='casestudy', + name='isolated_or_widespread', + field=models.TextField(blank=True, help_text='Is this an isolated project or are there similar projects in the same geographic area? If so, can you describe them? Is there an analysis of cumulative or synergetic effects?', verbose_name='Is the project part of developments which are causing a cumulative effect?'), + ), + migrations.AlterField( + model_name='casestudy', + name='land_ownership', + field=models.CharField(choices=[('PRI', 'Private land'), ('PUB', 'Public/state land'), ('COM', 'Community/communal/customary land'), ('CON', 'Contested/in conflict'), ('OTH', 'Other')], help_text='What type of ownership does the land fall under?', max_length=3, verbose_name='Land ownership / tenure'), + ), + migrations.AlterField( + model_name='casestudy', + name='land_ownership_details', + field=models.TextField(blank=True, help_text="

Please specify details about land ownership, including conflicting claims, unrecognized customary rights, conflicts around land lease or purchase contracts, etc.

We understand this is a difficult question, so please try to provide just the information you know. If we have any major questions we will ask them in the moderation process.

", max_length=256, verbose_name='Land ownership details'), + ), + migrations.AlterField( + model_name='casestudy', + name='location_context', + field=models.CharField(choices=[('RUR', 'Rural'), ('URB', 'Urban'), ('MIX', 'Mixed')], help_text='Select the context that is most applicable to this case study.', max_length=3, verbose_name='Location'), + ), + migrations.AlterField( + model_name='casestudy', + name='minerals_or_commodities', + field=models.CharField(blank=True, choices=[('ALU', 'Aluminium (Bauxite)'), ('ARS', 'Arsenic'), ('BER', 'Beryllium'), ('CAD', 'Cadmium'), ('CHR', 'Chromium'), ('COK', 'Coking'), ('COA', 'Coal (for steel)'), ('COP', 'Copper'), ('GAL', 'Gallium'), ('GER', 'Germanium'), ('GLD', 'Gold'), ('HRE', 'Heavy Rare Earth Elements (Gadolinium, Terbium, Dysprosium, Holmium, Erbium, Thulium, Ytterbium, Lutetium, Yttrium, Scandium)'), ('IRN', 'Iron'), ('LRE', 'Light Rare Earth Elements (Lanthanum, Cerium, Praseodymium, Neodymium, Promethium, Samarium, Europium)'), ('LED', 'Lead'), ('LIT', 'Lithium'), ('MAN', 'Manganese'), ('MER', 'Mercury'), ('MOL', 'Molybdenum'), ('NIC', 'Nickel'), ('NIO', 'Niobium'), ('PGM', 'Platinum group metals (ruthenium, rhodium, palladium, osmium, iridium, and platinum)'), ('RHE', 'Rhenium'), ('SIL', 'Silicon'), ('SIV', 'Silver'), ('TAN', 'Tantalum'), ('TEL', 'Tellurium'), ('THA', 'Thallium'), ('TIN', 'Tin'), ('TIT', 'Titanium'), ('TUN', 'Tungsten'), ('VAN', 'Vanadium'), ('ZNC', 'Zinc'), ('OTR', 'Other')], help_text='What mineral commodity is primarily mined in this project?', max_length=3, verbose_name='Primary mineral mined'), + ), + migrations.AlterField( + model_name='casestudy', + name='minerals_or_commodities_other', + field=models.TextField(blank=True, help_text='Enter any mineral commodities not in the list. Separate each with a new line.', verbose_name='Other mineral commodities'), + ), + migrations.AlterField( + model_name='casestudy', + name='negative_case_reasons', + field=multiselectfield.db.fields.MultiSelectField(blank=True, choices=[('VOLR', 'Violation of land rights'), ('VOHR', 'Violation of fundamental human rights, indigenous rights and/or other collective rights'), ('EIMP', 'Environmental impacts (severe impacts on ecosystems / violation of laws, plans or programs of environmental conservation or territorial governance systems etc.'), ('NCUL', 'Negative cultural impacts (erosion/destruction of bio-cultural heritage, impacts on sacred land etc)'), ('AGGR', 'Aggression/threats to community members opposed to the project, collaboration with organized crime etc'), ('ALAB', 'Abusive labour practices'), ('CRUP', 'Corruption and/or irregular permitting or contracting, conflicts of interest etc')], max_length=34, verbose_name='What kind of case is this entry about?'), + ), + migrations.AlterField( + model_name='casestudy', + name='negative_socioenvironmental_impacts', + field=models.TextField(blank=True, help_text='Provide a detailed description of the socio-environmental impacts (please provide all relevant details, such as type of ecosystem and presence of any existing reserve in the area, land to have increased biodiversity as a result of the project, new protection of lands/waters, specific communities affected by the project, total geographic footprint of the project, and tenure system affected in the case of land grabs, kind of permits that were irregularly issued if this is the case.', verbose_name='Describe the socio-environmental impacts (positive and negative):'), + ), + migrations.AlterField( + model_name='casestudy', + name='obstacles_and_hindrances', + field=models.TextField(blank=True, help_text='Please describe the status of the organizing process, including the obstacles and hindrances faced.', max_length=512, verbose_name='Current status of the organizing process around this case'), + ), + migrations.AlterField( + model_name='casestudy', + name='official_project_documents', + field=models.ManyToManyField(blank=True, help_text='Attach any legal or official documents that relate to the project. Hold down Control, or Command on a Mac, to select more than one.', related_name='official_project_document_for', to='files.File', verbose_name='Official project documents'), + ), + migrations.AlterField( + model_name='casestudy', + name='other_documents', + field=models.ManyToManyField(blank=True, help_text='Attach any other documents that relate to the project. Hold down Control, or Command on a Mac, to select more than one.', related_name='other_document_for', to='files.File', verbose_name='Other documents'), + ), + migrations.AlterField( + model_name='casestudy', + name='people_affected_other', + field=models.TextField(blank=True, help_text='Please describe further the communities or identities present in the project area.', verbose_name='Communities or identities – further detail'), + ), + migrations.AlterField( + model_name='casestudy', + name='positive_case_type', + field=multiselectfield.db.fields.MultiSelectField(blank=True, choices=[('CREP', 'Community project (co-)owned by individuals'), ('EACP', 'Community project owned by not-for-profit organizations and/or serving the public interest'), ('PSEP', 'Public/state (federal, state, municipal) project'), ('CORS', 'Reuse / Recycling / Circular economy project')], max_length=32, verbose_name='What kind of case is this entry about?'), + ), + migrations.AlterField( + model_name='casestudy', + name='positive_or_negative', + field=models.CharField(choices=[('P', 'There is/was an organising process in favour of the project'), ('N', 'There is/was an organising process against the project'), ('X', 'There is/was no organising process'), ('U', 'Unsure/unknown')], max_length=1, verbose_name='What is the relationship of local community organization(s) to this project?'), + ), + migrations.AlterField( + model_name='casestudy', + name='power_technology', + field=models.CharField(blank=True, choices=[('PT', 'Electrical power transmission'), ('HN', 'Heat networks'), ('OT', 'Other')], max_length=2, verbose_name='Power technology'), + ), + migrations.AlterField( + model_name='casestudy', + name='power_technology_other', + field=models.CharField(blank=True, max_length=128, verbose_name='Further information about power technology'), + ), + migrations.AlterField( + model_name='casestudy', + name='project_owners', + field=models.TextField(blank=True, help_text='List companies or organisations that own the project and/or facilities. Provide company numbers etc. if available. Separate with a new line.', verbose_name='Project and facility owners'), + ), + migrations.AlterField( + model_name='casestudy', + name='project_status', + field=models.CharField(choices=[('INIT', 'Initiation/ideation'), ('PROJCD', 'In planning and design'), ('FAIL', 'Failed'), ('UCONST', 'Under construction'), ('EXSTNG', 'In operation'), ('DECOMM', 'Undergoing decommissioning'), ('END', 'Decommissioned')], max_length=6, verbose_name='Status of project'), + ), + migrations.AlterField( + model_name='casestudy', + name='project_status_detail', + field=models.TextField(blank=True, help_text='Describe the current situation and likely future scenarios.', verbose_name='Current status of the case'), + ), + migrations.AlterField( + model_name='casestudy', + name='projected_production_of_commodities', + field=models.CharField(blank=True, help_text='Describe the projected production of commodities per annum and overall.
For example, "40 million tonnes of iron ore per year", "200 million tonnes over 5 year life of mine"', max_length=256, verbose_name='Estimated production of key commodities'), + ), + migrations.AlterField( + model_name='casestudy', + name='sector_of_economy', + field=models.CharField(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')], max_length=3, verbose_name='Sector of economy'), + ), + migrations.AlterField( + model_name='casestudy', + name='shapefiles', + field=models.ManyToManyField(blank=True, help_text='If you have territory that you would like to show in relation to this project - e.g. Bienes Comunales de Ixtepec etc. This is a set of 3 or more (often 5-6) files with file extensions like .cpg, .dbf, .prj, .qpj, .shp, .shx. Hold down Control, or Command on a Mac, to select more than one. Let us know (database@ojuso.org) if you have other file types or need help and we can work out how to import it. You may have data as GeoPackage (gpkg), GeoJSON, KML, GML, etc. or have data in PostGIS or another spatial database management system already.', related_name='shapefile_for', to='files.File', verbose_name='Geographic data'), + ), + migrations.AlterField( + model_name='casestudy', + name='size_of_concessions', + field=models.CharField(blank=True, help_text="Describe the size of concession(s) granted to company/companies (e.g. 'one concession of 2,300 hectares')", max_length=200, verbose_name='Size of concessions (land/marine area)'), + ), + migrations.AlterField( + model_name='casestudy', + name='socioeconomic_benefits', + field=models.TextField(blank=True, verbose_name='Socio-economic impacts'), + ), + migrations.AlterField( + model_name='casestudy', + name='start_year', + field=models.IntegerField(blank=True, choices=[(1978, 1978), (1979, 1979), (1980, 1980), (1981, 1981), (1982, 1982), (1983, 1983), (1984, 1984), (1985, 1985), (1986, 1986), (1987, 1987), (1988, 1988), (1989, 1989), (1990, 1990), (1991, 1991), (1992, 1992), (1993, 1993), (1994, 1994), (1995, 1995), (1996, 1996), (1997, 1997), (1998, 1998), (1999, 1999), (2000, 2000), (2001, 2001), (2002, 2002), (2003, 2003), (2004, 2004), (2005, 2005), (2006, 2006), (2007, 2007), (2008, 2008), (2009, 2009), (2010, 2010), (2011, 2011), (2012, 2012), (2013, 2013), (2014, 2014), (2015, 2015), (2016, 2016), (2017, 2017), (2018, 2018), (2019, 2019), (2020, 2020), (2021, 2021), (2022, 2022), (2023, 2023), (2024, 2024), (2025, 2025), (2026, 2026), (2027, 2027), (2028, 2028), (2029, 2029), (2030, 2030), (2031, 2031), (2032, 2032), (2033, 2033), (2034, 2034), (2035, 2035), (2036, 2036), (2037, 2037), (2038, 2038), (2039, 2039), (2040, 2040), (2041, 2041), (2042, 2042), (2043, 2043), (2044, 2044), (2045, 2045), (2046, 2046), (2047, 2047), (2048, 2048), (2049, 2049), (2050, 2050), (2051, 2051), (2052, 2052), (2053, 2053), (2054, 2054), (2055, 2055), (2056, 2056), (2057, 2057), (2058, 2058)], help_text='Select the year project construction began. If the project is not yet in construction, select the assumed start year as detailed in company information or media.', null=True, verbose_name='Construction start year'), + ), + migrations.AlterField( + model_name='casestudy', + name='total_investment', + field=models.IntegerField(blank=True, help_text='The approximate total investment for the project in US dollars.', null=True, verbose_name='Total investment (in USD)'), + ), + migrations.AlterField( + model_name='casestudy', + name='type_of_ecosystem', + field=multiselectfield.db.fields.MultiSelectField(blank=True, choices=[('MARINE', 'Marine (e.g. Ocean, Sea)'), ('FRESH', 'Freshwater (e.g. Freshwater, Lake)'), ('FOREST', 'Forest/Jungle'), ('AGRI', 'Agricultural Land'), ('GRASS', 'Grassland'), ('DESERT', 'Desert (Tundra, Ice or Sand)'), ('WETLND', 'Wetland (Marsh, Mangrove, Peat Soil)'), ('URBAN', 'Urban')], max_length=56, verbose_name='Type(s) of ecosystem'), + ), + migrations.AlterField( + model_name='casestudy', + name='use_in_energy_economy', + field=multiselectfield.db.fields.MultiSelectField(blank=True, choices=[('CPV', 'Concentrated solar power (CSP)'), ('EPT', 'Electrical power transmission infrastructure'), ('ESS', 'Energy storage'), ('GGM', 'Geothermal'), ('HGM', 'Hydropower'), ('HNT', 'Heat networks'), ('SPM', 'Solar PV'), ('STM', 'Solar thermal systems'), ('WTM', 'Wind power'), ('ESS', "Don't know"), ('OTR', 'Other')], max_length=128, verbose_name='Potential use in renewable energy economy'), + ), + migrations.AlterField( + model_name='casestudy', + name='use_in_energy_economy_other', + field=models.CharField(blank=True, max_length=128, verbose_name='Other'), + ), + migrations.AlterField( + model_name='casestudy', + name='when_did_organising_start', + field=models.CharField(blank=True, help_text='Before the project started? During project implementation? After project implementation? Describe in your own words.', max_length=512, verbose_name='When did local organising efforts begin?'), + ), + migrations.AlterField( + model_name='pointofinterest', + name='slug', + field=django_extensions.db.fields.AutoSlugField(blank=True, editable=False, populate_from=['title']), + ), + ] diff --git a/apps/map/models.py b/apps/map/models.py index 54cae60..f136e07 100644 --- a/apps/map/models.py +++ b/apps/map/models.py @@ -503,6 +503,7 @@ class CaseStudy(models.Model): help_text=_("List consultants, planners or organisations that are doing the planning, \ construction, operation or maintenance work relating to the project \ and/or facilities. Separate each with a new line."), + blank=True ) # 1.12 From 23c1279f6114ee24ee23d23740e9bc1d0037e86d Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Sun, 2 Dec 2018 00:31:26 +0000 Subject: [PATCH 17/19] Update case study display --- apps/map/models.py | 24 --- apps/map/templates/map/detail.html | 231 +++++++++++++++++------------ 2 files changed, 136 insertions(+), 119 deletions(-) diff --git a/apps/map/models.py b/apps/map/models.py index f136e07..90c33d4 100644 --- a/apps/map/models.py +++ b/apps/map/models.py @@ -1115,30 +1115,6 @@ class CaseStudy(models.Model): """Gets the 11 number video ID from the video field.""" return parse.urlparse(self.video).path - def get_negative_case_reasons_no_other(self): - """Return a list of negative case reasons, minus the 'other' choice (if selected)""" - choices = self.get_negative_case_reasons_list() - - return choices - - def get_renewable_generation_detail(self): - """Prepend appropriate descriptive text when accessing renewable generation type.""" - - if self.generation_technology: - if self.generation_technology.endswith('WE'): - return _('Wind energy') + " – " + self.get_generation_technology_display() - elif self.generation_technology.endswith('PV'): - return _('Photovoltaic electricity') + " – " + self.get_generation_technology_display() - elif self.generation_technology.endswith('HYD'): - return _('Hydroelectric') + " – " + self.get_generation_technology_display() - elif self.generation_technology == 'OTHR': - return self.generation_technology_other - else: - return self.get_generation_technology_display() - - else: - return "" - class Meta: verbose_name_plural = 'case studies' diff --git a/apps/map/templates/map/detail.html b/apps/map/templates/map/detail.html index b061b90..1f6036f 100644 --- a/apps/map/templates/map/detail.html +++ b/apps/map/templates/map/detail.html @@ -117,12 +117,13 @@ dd ul { padding-left: 0; margin-left: 0; } {% endif %} {% if case_study.land_ownership %} -
{% trans "Land ownership" %}: - {% if case_study.land_ownership == 'OTH' %} -
{{ case_study.land_ownership_details }} - {% else %} -
{{ case_study.get_land_ownership_display }} - {% endif %} +
{% trans "Land ownership and tenure" %}: +
+ {% if case_study.land_ownership != 'OTH' %} + {{ case_study.get_land_ownership_display }} + {% endif %} + + {{ case_study.land_ownership_details | linebreaks }} {% endif %} {% if case_study.type_of_ecosystem %} @@ -137,13 +138,10 @@ dd ul { padding-left: 0; margin-left: 0; } - {% if case_study.affects_indigenous %} + {% if case_study.affected_communities %}

{% trans "Affected groups of people" %}

-

{% trans "Indigenous people" %}

- {{ case_study.people_affected_indigenous | linebreaks }} - -

{% trans "Non-indigenous people" %}

+ {{ case_study.get_affected_communities_display }} {{ case_study.people_affected_other | linebreaks }} {% endif %} @@ -156,12 +154,12 @@ dd ul { padding-left: 0; margin-left: 0; } {% endif %} {% if case_study.start_year %} -
{% trans "Start year" %}: +
{% trans "Construction start year" %}:
{{ case_study.start_year }} {% endif %} {% if case_study.completion_year %} -
{% trans "Completion year" %}: +
{% trans "Operation start year" %}:
{{ case_study.completion_year }} {% endif %} @@ -170,6 +168,11 @@ dd ul { padding-left: 0; margin-left: 0; }
{{ case_study.project_owners }} {% endif %} + {% if case_study.consultants_contractors %} +
{% trans "Consultants and contractors" %}: +
{{ case_study.consultants_contractors }} + {% endif %} + {% if case_study.shareholders %}
{% trans "Shareholders of the project owners" %}:
{{ case_study.shareholders }} @@ -177,7 +180,9 @@ dd ul { padding-left: 0; margin-left: 0; } {% if case_study.financial_institutions %}
{% trans "Financial institutions" %}: -
{{ case_study.financial_institutions }} +
+ {{ case_study.get_financial_institutions_display }} + {{ case_study.financial_institutions_other }} {% endif %} {% if case_study.energy_customers %} @@ -241,17 +246,24 @@ dd ul { padding-left: 0; margin-left: 0; }

Technical and economic analysis

{% if case_study.sector_of_economy == 'RN' %} - +
+ {% if case_study.generation_type %} +
{% trans "What is being generated?" %}: +
+ {{ case_study.get_generation_type_detail }} + {% endif %} + {% if case_study.generation_technology %}
{% trans "Generation technology" %}:
- {{ case_study.get_renewable_generation_detail }} +

{{ case_study.get_generation_technology_display }} +

{{ case_study.energy_details }} {% endif %} - {% if case_study.generation_technology == 'BIOG' or case_study.generation_technology == 'OTHB' %} -

{% trans "Feedstock" %}: + {% if case_study.generation_technology == 'BIO' %} +
{% trans "Bio-energy feedstock" %}:
{{ case_study.biomass_detail }} {% endif %} @@ -274,49 +286,45 @@ dd ul { padding-left: 0; margin-left: 0; } ${{ case_study.total_investment | intcomma }} (USD) {% endif %} - {% if case_study.technical_or_economic_details %} + {% if case_study.additional_technical_details %}
{% trans "Additional technical or economic details" %}: -
- {{ case_study.technical_or_economic_details | linebreaks }} +
+ {{ case_study.additional_technical_details | linebreaks }} {% endif %} -
- {% elif case_study.sector_of_economy == 'PG' %} - + {% elif case_study.sector_of_economy == 'PG' or case_study.sector_of_economy == 'ST' %} +
{% if case_study.power_technology %}
{% trans "Generation technology" %}:
- {% if case_study.power_technology == 'OT' %} - {{ case_study.power_technology_other }} - {% else %} - {{ case_study.power_technology }} - {% endif %} +

{{ case_study.power_technology }} +

{{ case_study.power_technology_other }} {% endif %} {% if case_study.energy_storage_capacity %}

{% trans "Energy storage capacity" %}:
- {{ case_study.energy_storage_capacity }} TODO UNITS? + {{ case_study.energy_storage_capacity }} kWh {% endif %} {% if case_study.energy_transmission_capacity %}
{% trans "Energy transmission capacity" %}:
- {{ case_study.energy_transmission_capacity }} TODO UNITS? + {{ case_study.energy_transmission_capacity }} kW {% endif %} - {% if case_study.contractor_or_supplier_of_technology %} -
{% trans "Contractor and/or supplier of technology" %}: -
- {{ case_study.contractor_or_supplier_of_technology }} + {% if case_study.generation_equipment_supplier %} +
{% trans "Generation equipment supplier" %}: +
+ {{ case_study.generation_equipment_supplier }} {% endif %} - {% if case_study.approximate_total_investment %} + {% if case_study.total_investment %}
{% trans "Approximate total investment" %}: -
- ${{ case_study.approximate_total_investment | intcomma }} (USD) +
+ ${{ case_study.total_investment | intcomma }} (USD) {% endif %} {% if case_study.additional_technical_details %} @@ -324,30 +332,33 @@ dd ul { padding-left: 0; margin-left: 0; }
{{ case_study.additional_technical_details | linebreaks }} {% endif %} +
{% elif case_study.sector_of_economy == 'SM' %} - +
{% if case_study.minerals_or_commodities %} -
{% trans "Mineral commodity/commodities" %}: +
{% trans "Primary mineral mined" %}:
- {% if case_study.minerals_or_commodities == 'OTR' %} - {{ case_study.minerals_or_commodities_other }} - {% else %} - {{ case_study.get_minerals_or_commodities_display }} + {% if case_study.minerals_or_commodities != 'OTR' %} +

{{ case_study.get_minerals_or_commodities_display }} {% endif %} + + {{ case_study.minerals_or_commodities_other | linebreaks }} {% endif %} {% if case_study.use_in_energy_economy %}

{% trans "Potential use in renewable energy economy" %}:
- {% if case_study.use_in_energy_economy == 'OTR' %} - {{ case_study.use_in_energy_economy_other }} - {% else %} + {% if case_study.use_in_energy_economy != 'OTR' %} {{ case_study.get_use_in_energy_economy_display }} {% endif %} + + {% if case_study.use_in_energy_economy_other %} + {{ case_study.use_in_energy_economy_other }} + {% endif %} {% endif %} {% if case_study.project_life_span %} @@ -363,7 +374,7 @@ dd ul { padding-left: 0; margin-left: 0; } {% endif %} {% if case_study.projected_production_of_commodities %} -
{% trans "Projected production of key commodities" %}: +
{% trans "Estimated production of key commodities" %}:
{{ case_study.projected_production_of_commodities }} {% endif %} @@ -381,29 +392,85 @@ dd ul { padding-left: 0; margin-left: 0; } {% endif %}
+ {% elif case_study.sector_of_economy == 'MA' %} + + +
+ {% if case_study.manufacturing_type %} +
{% trans "Manufacturing process" %}: +
+ {{ case_study.get_manufacturing_type_display }} + {% endif %} + + {% if case_study.manufacturing_description %} +
{% trans "Description" %}: +
+ {{ case_study.manufacturing_description }} + {% endif %} + + {% if case_study.manufacturing_related_tech %} +
{% trans "Related technology" %}: +
{% trans "Remarkable factors" %}: +
+ {{ case_study.get_manufacturing_factors_display }} + {% endif %} + + {% if case_study.manufacturing_factors_description %} +
{% trans "More info" %}: +
+ {{ case_study.manufacturing_factors_description }} + {% endif %} + + {% if case_study.manufacturing_factors_ownership %} +
{% trans "Ownership information" %}: +
+ {{ case_study.manufacturing_factors_ownership }} + {% endif %} +
+ {% endif %}

Socio-economic analysis

-
{% trans "Case type" %} +
{% trans "Kind of organising process around this project" %}
{{ case_study.get_positive_or_negative_display }} - {% if case_study.positive_or_negative == "P" %} - +
{% trans "This is case is about" %}: +
+
    - {% if case_study.positive_case_type %} -
    {% trans "Type of positive case" %}: -
    - {{ case_study.get_positive_case_type_display }} - {% endif %} + {% if case_study.positive_case_type %} + {% for text in case_study.get_positive_case_type_list %} +
  • {{ text }} + {% endfor %} + {% endif %} + + {% if case_study.negative_case_reasons %} + {% for text in case_study.get_negative_case_reasons_list %} +
  • {{ text }} + {% endfor %} + {% endif %} + +
{% if case_study.socioeconomic_benefits %} -
{% trans "Socio-economic benefits" %}: +
{% trans "Socio-economic impacts" %}
{{ case_study.socioeconomic_benefits }} {% endif %} + {% if case_study.isolated_or_widespread %} +
{% trans "Is the project part of developments which are causing a cumulative effect?" %} +
+ {{ case_study.isolated_or_widespread }} + {% endif %} + {% if case_study.key_actors_involved %}
{% trans "Key actors involved" %}:
@@ -411,53 +478,23 @@ dd ul { padding-left: 0; margin-left: 0; } {% endif %} {% if case_study.project_status_detail %} -
{% trans "Current status of project" %}: +
{% trans "Current status of the case" %}:
{{ case_study.project_status_detail }} {% endif %} {% if case_study.obstacles_and_hindrances %} -
{% trans "Obstacles and hindrances" %}: +
{% trans "Current status of the organizing process around this case" %}:
{{ case_study.obstacles_and_hindrances }} {% endif %} - {% if case_study.identified_partnerships %} -
{% trans "Identified partnerships" %}: -
- {{ case_study.identified_partnerships }} - {% endif %} - - - {% else %} - - - {% if case_study.negative_case_reasons %} -
{% trans "Reasons this is a negative case study" %}: -
-
    - {% for text in case_study.get_negative_case_reasons_no_other %} -
  • {{ text }} - {% endfor %} - - {% if case_study.negative_case_reasons_other %} -
  • {{ case_study.negative_case_reasons_other }} - {% endif %} -
- {% endif %} - {% if case_study.negative_socioenvironmental_impacts %} -
{% trans "Negative socio-environmental impacts" %}: +
{% trans "Socio-environmental impacts" %}:
{{ case_study.negative_socioenvironmental_impacts }} {% endif %} - {% if case_study.isolated_or_widespread %} -
{% trans "Isolated or commonplace" %}: -
- {{ case_study.isolated_or_widespread }} - {% endif %} - {% if case_study.when_did_organising_start %}
{% trans "Local organising efforts began" %}:
@@ -470,13 +507,17 @@ dd ul { padding-left: 0; margin-left: 0; } {{ case_study.who_has_been_involved }} {% endif %} - {% if case_study.potential_partnerships %} -
{% trans "Potential partnerships" %}: -
- {{ case_study.potential_partnerships }} + {% if case_study.participation_mechanisms %} +
{% trans "Mechanisms of participation" %}: +
+ {{ case_study.participation_mechanisms }} {% endif %} - {% endif %} + {% if case_study.identified_partnerships %} +
{% trans "Identified partnerships" %}: +
+ {{ case_study.identified_partnerships }} + {% endif %}
From 0a47ea3724f8ba9fe4b73e9d9dfd7c1c8d9e2572 Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Sun, 2 Dec 2018 00:38:15 +0000 Subject: [PATCH 18/19] Nuke no longer needed tests, add youtube one --- apps/map/tests.py | 38 +++++--------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/apps/map/tests.py b/apps/map/tests.py index d8ff558..77367c0 100644 --- a/apps/map/tests.py +++ b/apps/map/tests.py @@ -83,38 +83,10 @@ class CaseStudyDraftAPITests(TestCase): class CaseStudyTests(TestCase): - def test_get_renewable_generation_detail_when_empty(self): - """get_renewable_generation_detail() should return the empty string.""" + def test_youtube(self): case_study = CaseStudy() - self.assertIs(case_study.get_renewable_generation_detail(), "") + case_study.video = "https://www.youtube.com/watch?v=h2V4-UP7ML0" + self.assertIs(case_study.is_video_youtube(), True) - def test_get_renewable_generation_detail_with_geo(self): - """get_renewable_generation_detail() should return just the description""" - case_study = CaseStudy(generation_technology='GEOT') - self.assertEqual(case_study.get_renewable_generation_detail(), "Geothermal electricity") - - def test_get_renewable_generation_detail_with_wind(self): - """get_renewable_generation_detail() should return the description prefixed with 'wind power'""" - case_study = CaseStudy(generation_technology='SSWE') - self.assertTrue(case_study.get_renewable_generation_detail().startswith("Wind energy")) - - def test_get_renewable_generation_detail_with_other(self): - """get_renewable_generation_detail() should return the detail provided in .generation_technology_other""" - case_study = CaseStudy(generation_technology='OTHR', generation_technology_other='Warp drive') - self.assertEqual(case_study.get_renewable_generation_detail(), "Warp drive") - - def test_get_negative_case_reasons_no_other_1(self): - """Test with case having no 'other' entry""" - case_study = CaseStudy(negative_case_reasons=['VOLR','ALAB']) - self.assertEqual(case_study.get_negative_case_reasons_no_other(), - [ 'Violation of land rights' - , 'Abusive labour practices' - ]) - - def test_get_negative_case_reasons_no_other_2(self): - """Test with case having an 'other' entry""" - case_study = CaseStudy(negative_case_reasons=['VOLR','ALAB','OTHR']) - self.assertEqual(case_study.get_negative_case_reasons_no_other(), - [ 'Violation of land rights' - , 'Abusive labour practices' - ]) + # case_study.video = "https://youtu.be/h2V4-UP7ML0" + # self.assertIs(case_study.is_video_youtube(), True) From 73a746d83e157ba4f2c63ba2ef41737ec2dbd722 Mon Sep 17 00:00:00 2001 From: Anna Sidwell Date: Sun, 2 Dec 2018 01:10:12 +0000 Subject: [PATCH 19/19] Tests pass, woohoo --- apps/map/forms.py | 70 +++++++++++++++++++++++++++-------------------- ojusomap/tests.py | 16 +++++------ 2 files changed, 48 insertions(+), 38 deletions(-) diff --git a/apps/map/forms.py b/apps/map/forms.py index afa02bf..147adca 100644 --- a/apps/map/forms.py +++ b/apps/map/forms.py @@ -15,6 +15,32 @@ from .models import CaseStudy, SpatialRefSys, PointOfInterest from .widgets import JSONFileListWidget +SECTOR_HELP = { + 'RN': _("including electricity, heat or combined heat and power generation"), + 'PG': '', + 'ST': _('Biological, chemical, electrical, electromagnetic, electrochemical, mechanical including gravitational potential, thermal etc.'), + 'SM': _("including supply of minerals"), + 'MA': '', +} + +POWER_TECHNOLOGY_HELP = { + 'PT': _('Lines, transformers, machinery etc.'), + 'HN': _('District heating/cooling, etc.'), + 'OT': '', +} + +def add_explanatory_text(model_choices, explanatory_text): + return [ + ( + choice[0], + mark_safe('%s
%s' % + (choice[1], explanatory_text[choice[0]]) + ) + ) for choice in model_choices + ] + + + class MinimumZoomWidget(LeafletWidget): geometry_field_class = 'MinimumZoomField' @@ -87,6 +113,16 @@ class ShortCaseStudyForm(BaseCaseStudyForm): self.helper.form_action = reverse('short-form') self.helper.add_input(Submit('submit', _('Submit'), css_class='btn-success center-block')) + # Duplicate code from long form, below... + self.fields['sector_of_economy'] = forms.ChoiceField( + widget=forms.RadioSelect(), + choices=add_explanatory_text( + CaseStudy.SECTOR_CHOICES, + SECTOR_HELP + ), + required=False + ) + class Meta(BaseCaseStudyForm.Meta): fields = [ 'entry_name', @@ -176,32 +212,6 @@ class LongCaseStudyForm(BaseCaseStudyForm): initial=4326, ) - SECTOR_HELP = { - 'RN': _("including electricity, heat or combined heat and power generation"), - 'PG': '', - 'ST': _('Biological, chemical, electrical, electromagnetic, electrochemical, mechanical including gravitational potential, thermal etc.'), - 'SM': _("including supply of minerals"), - 'MA': '', - } - - POWER_TECHNOLOGY_HELP = { - 'PT': _('Lines, transformers, machinery etc.'), - 'HN': _('District heating/cooling, etc.'), - 'OT': '', - } - - # TODO: Allow explanatory_text to not contain text for every option - # TODO: Only output if there is explanatory text - def add_explanatory_text(self, model_choices, explanatory_text): - return [ - ( - choice[0], - mark_safe('%s
%s' % - (choice[1], explanatory_text[choice[0]]) - ) - ) for choice in model_choices - ] - def __init__(self, *args, **kwargs): super(LongCaseStudyForm, self).__init__(*args, **kwargs) @@ -210,18 +220,18 @@ class LongCaseStudyForm(BaseCaseStudyForm): self.fields['sector_of_economy'] = forms.ChoiceField( widget=forms.RadioSelect(), - choices=self.add_explanatory_text( + choices=add_explanatory_text( CaseStudy.SECTOR_CHOICES, - self.SECTOR_HELP + SECTOR_HELP ), required=False ) self.fields['power_technology'] = forms.ChoiceField( widget=forms.RadioSelect(), - choices=self.add_explanatory_text( + choices=add_explanatory_text( CaseStudy.POWER_TECHNOLOGY_CHOICES, - self.POWER_TECHNOLOGY_HELP + POWER_TECHNOLOGY_HELP ), required=False ) diff --git a/ojusomap/tests.py b/ojusomap/tests.py index d9d377f..ee7f3d5 100644 --- a/ojusomap/tests.py +++ b/ojusomap/tests.py @@ -119,14 +119,14 @@ class MapTest(SeleniumTest): self.sl.find_element_by_id('id_entry_name').send_keys('Short Entry'); Select(self.sl.find_element_by_id('id_country')).select_by_visible_text('Albania'); self.sl.find_element_by_id('id_area_of_land').send_keys('123'); - Select(self.sl.find_element_by_id('id_land_ownership')).select_by_visible_text('Private Land'); + Select(self.sl.find_element_by_id('id_land_ownership')).select_by_visible_text('Private land'); Select(self.sl.find_element_by_id('id_location_context')).select_by_visible_text('Urban'); self.sl.find_element_by_id('id_describe_ecosystem').send_keys('test'); - Select(self.sl.find_element_by_id('id_project_status')).select_by_visible_text('Existing Project'); - Select(self.sl.find_element_by_id('id_sector_of_economy')).select_by_visible_text('Power Grids'); + Select(self.sl.find_element_by_id('id_project_status')).select_by_visible_text('In planning and design'); + self.sl.find_element_by_css_selector('[name=sector_of_economy][value=ST]').click() self.sl.find_element_by_id('id_synopsis').send_keys('test'); self.sl.find_element_by_id('id_full_description').send_keys('test'); - Select(self.sl.find_element_by_id('id_positive_or_negative')).select_by_visible_text('Positive'); + Select(self.sl.find_element_by_id('id_positive_or_negative')).select_by_visible_text('There is/was an organising process in favour of the project'); # you can submit the form on any field. Using this one because the submit button sometimes isn't visible self.sl.find_element_by_id('id_area_of_land').submit(); self.assertTrue("Thanks!" in self.sl.page_source, "Success message not shown") @@ -140,18 +140,18 @@ class MapTest(SeleniumTest): self.sl.find_element_by_id('id_entry_name').send_keys('Long Entry'); Select(self.sl.find_element_by_id('id_country')).select_by_visible_text('Albania'); self.sl.find_element_by_id('id_area_of_land').send_keys('123'); - Select(self.sl.find_element_by_id('id_land_ownership')).select_by_visible_text('Private Land'); + Select(self.sl.find_element_by_id('id_land_ownership')).select_by_visible_text('Private land'); Select(self.sl.find_element_by_id('id_location_context')).select_by_visible_text('Urban'); self.sl.find_element_by_id('id_describe_ecosystem').send_keys('test'); - Select(self.sl.find_element_by_id('id_project_status')).select_by_visible_text('Existing Project'); + Select(self.sl.find_element_by_id('id_project_status')).select_by_visible_text('In planning and design'); self.sl.find_element_by_id('id_synopsis').send_keys('test'); self.sl.find_element_by_id('id_full_description').send_keys('test'); self.sl.find_element_by_id('id_project_owners').send_keys('test'); self.sl.find_element_by_id('id_shareholders').send_keys('test'); self.sl.find_element_by_css_selector('a[href="#technical-and-economic-analysis"]').click() - Select(self.sl.find_element_by_id('id_sector_of_economy')).select_by_visible_text('Power Grids'); + self.sl.find_element_by_css_selector('[name=sector_of_economy][value=ST]').click() self.sl.find_element_by_css_selector('a[href="#socio-environmental-analysis"]').click() - Select(self.sl.find_element_by_id('id_positive_or_negative')).select_by_visible_text('Positive'); + Select(self.sl.find_element_by_id('id_positive_or_negative')).select_by_visible_text('There is/was an organising process in favour of the project'); self.sl.find_element_by_css_selector('a[href="#uploads"]').click() # you can submit the form on any field. Using this one because the submit button sometimes isn't visible self.sl.find_element_by_id('id_name_of_territory_or_area').submit();