diff --git a/apps/map/migrations/0041_auto_20180328_0616.py b/apps/map/migrations/0041_auto_20180328_0616.py new file mode 100644 index 0000000..47fee04 --- /dev/null +++ b/apps/map/migrations/0041_auto_20180328_0616.py @@ -0,0 +1,21 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.6 on 2018-03-28 06:16 +from __future__ import unicode_literals + +from django.db import migrations +import multiselectfield.db.fields + + +class Migration(migrations.Migration): + + dependencies = [ + ('map', '0040_auto_20180328_0309'), + ] + + operations = [ + 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'), ('OTHR', 'Other reasons')], default=None, max_length=39, null=True, verbose_name='Reasons this is a negative case study'), + ), + ] diff --git a/apps/map/models.py b/apps/map/models.py index 168502c..170360e 100644 --- a/apps/map/models.py +++ b/apps/map/models.py @@ -161,6 +161,8 @@ class CaseStudy(models.Model): ('CORS', _('A case of responsible sourcing/supply chain/lifecycle management')), ) + 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')), @@ -172,7 +174,7 @@ class CaseStudy(models.Model): etc')), ('ALAB', _('Abusive labour practices')), ('CRUP', _('Corruption and/or irregular permitting or contracting, conflicts of interest etc')), - ('OTHR', _('Other reasons')) + ('OTHR', NEGATIVE_CASE_REASONS_OTHER_TEXT) ) # Dynamically generate a list of choices 40 years prior and after the current year. @@ -995,6 +997,15 @@ class CaseStudy(models.Model): """Gets the 11 character YouTube video ID from the video field.""" return parse.parse_qs(parse.urlparse(self.video).query)["v"][0] + 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() + + 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): """Prepend appropriate descriptive text when accessing renewable generation type.""" diff --git a/apps/map/templates/map/detail.html b/apps/map/templates/map/detail.html index 2df2ef5..0d08b4f 100644 --- a/apps/map/templates/map/detail.html +++ b/apps/map/templates/map/detail.html @@ -7,6 +7,7 @@ {% block stylesheets %} {{ super }} +{% leaflet_css %} {% endblock %} @@ -250,6 +254,281 @@ dd { margin-left: 2em; } {{ case_study.direct_comms | linebreaks }} {% endif %} +

Technical and economic analysis

+ + {% if case_study.sector_of_economy == 'RN' %} + + +
+ {% if case_study.generation_technology %} +
{% trans "Generation technology" %}: +
+ {{ case_study.get_renewable_generation_detail }} + {% endif %} + + {% if case_study.generation_technology == 'BIOG' or case_study.generation_technology == 'OTHB' %} +
{% trans "Feedstock" %}: +
+ {{ case_study.biomass_detail }} + {% endif %} + + {% if case_study.total_generation_capacity %} +
{% trans "Total generation capacity" %}: +
+ {{ case_study.total_generation_capacity }} kW + {% endif %} + + {% if case_study.generation_equipment_supplier %} +
{% trans "Generation equipment supplier" %}: +
+ {{ case_study.generation_equipment_supplier }} + {% endif %} + + {% if case_study.total_investment %} +
{% trans "Approximate total investment" %}: +
+ ${{ case_study.total_investment | intcomma }} (USD) + {% endif %} + + {% if case_study.technical_or_economic_details %} +
{% trans "Additional technical or economic details" %}: +
+ {{ case_study.technical_or_economic_details | linebreaks }} + {% endif %} +
+ + {% elif case_study.sector_of_economy == 'PG' %} + + +
+ {% 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 %} + {% endif %} + + {% if case_study.energy_storage_capacity %} +
{% trans "Energy storage capacity" %}: +
+ {{ 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" %} + {% endif %} + + {% if case_study.contractor_or_supplier_of_technology %} +
{% trans "Contractor and/or supplier of technology" %}: +
+ {{ case_study.contractor_or_supplier_of_technology }} + {% endif %} + + {% if case_study.approximate_total_investment %} +
{% trans "Approximate total investment" %}: +
+ ${{ case_study.approximate_total_investment | intcomma }} (USD) + {% endif %} + + {% if case_study.additional_technical_details %} +
{% trans "Additional technical or economic details" %}: +
+ {{ case_study.additional_technical_details | linebreaks }} + {% endif %} +
+ + {% elif case_study.sector_of_economy == 'SM' %} + + +
+ {% if case_study.minerals_or_commodities %} +
{% trans "Mineral commodity/commodities" %}: +
+ {% if case_study.minerals_or_commodities == 'OTR' %} + {{ case_study.minerals_or_commodities_other }} + {% else %} + {{ case_study.get_minerals_or_commodities_display }} + {% endif %} + {% 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 %} + {{ case_study.get_use_in_energy_economy_display }} + {% endif %} + {% endif %} + + {% if case_study.project_life_span %} +
{% trans "Project life span" %}: +
+ {{ case_study.project_life_span }} + {% endif %} + + {% if case_study.size_of_concessions %} +
{% trans "Size of concessions" %}: +
+ {{ case_study.size_of_concessions }} + {% endif %} + + {% if case_study.projected_production_of_commodities %} +
{% trans "Projected production of key commodities" %}: +
+ {{ case_study.projected_production_of_commodities }} + {% endif %} + + {% if case_study.type_of_extraction %} +
{% trans "Type of extraction" %}: +
+ {{ case_study.get_type_of_extraction_display }} + {% endif %} + + {% if case_study.associated_infrastructure %} +
{% trans "Type of extraction" %}: +
+ {{ case_study.associated_infrastructure }} + {% endif %} +
+ + {% endif %} + +

Socio-economic analysis

+ +
+
{% trans "Case type" %} +
{{ case_study.get_positive_or_negative_display }} + + {% if case_study.positive_or_negative == "P" %} + + + {% if case_study.positive_case_type %} +
{% trans "Type of positive case" %}: +
+ {{ case_study.get_positive_case_type_display }} + {% endif %} + + {% if case_study.socioeconomic_benefits %} +
{% trans "Socio-economic benefits" %}: +
+ {{ case_study.socioeconomic_benefits }} + {% endif %} + + {% if case_study.key_actors_involved %} +
{% trans "Key actors involved" %}: +
+ {{ case_study.key_actors_involved }} + {% endif %} + + {% if case_study.project_status_detail %} +
{% trans "Current status of project" %}: +
+ {{ case_study.project_status_detail }} + {% endif %} + + {% if case_study.obstacles_and_hindrances %} +
{% trans "Obstacles and hindrances" %}: +
+ {{ 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" %}: +
+ + {% endif %} + + {% if case_study.negative_socioenvironmental_impacts %} +
{% trans "Negative 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" %}: +
+ {{ case_study.when_did_organising_start }} + {% endif %} + + {% if case_study.who_has_been_involved %} +
{% trans "Communities, groups and organisations involved" %}: +
+ {{ case_study.who_has_been_involved }} + {% endif %} + + {% if case_study.potential_partnerships %} +
{% trans "Potential partnerships" %}: +
+ {{ case_study.potential_partnerships }} + {% endif %} + + {% endif %} + +
+ +

Related documents

+ + {% if case_study.official_project_documents %} +

Official documents: {{ case_study.official_project_documents.url }} + {% endif %} + + {% if case_study.other_documents %} +

Other documents: {{ case_study.other_documents.url }} + {% endif %} + + +

Location / GIS data

+ + {% leaflet_map "case_location" callback="window.map_init" %} + + {% if case_study.shapefiles %} +

Shapefiles: {{ case_study.shapefiles.url }} + {% endif %} + + {% if case_study.coordinate_reference_system %} +

Coordinate reference system: {{ coordinate_reference_system }} + {% endif %} + + {% if case_study.name_of_territory_or_area %} +

Name of territory or area: {{ case_study.name_of_territory_or_area }} + {% endif %} + @@ -259,7 +538,7 @@ dd { margin-left: 2em; }

@@ -269,3 +548,19 @@ dd { margin-left: 2em; } {% endblock %} + +{% block scripts %} +{% leaflet_js %} + +{% endblock %} diff --git a/apps/map/tests.py b/apps/map/tests.py index 0fa332d..9d32b85 100644 --- a/apps/map/tests.py +++ b/apps/map/tests.py @@ -23,3 +23,27 @@ class CaseStudyTests(TestCase): """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") + +# These tests are commented out because they are not working, but the code +# in production is. When running as a test, get_negative_case_reasons_no_other() +# is returning a list of coded options, like +# ['V', 'O', 'L', 'R', ',', 'A', 'L', 'A', 'B'] +# instead of a list of text like +# ['Violation of land rights', 'Abusive labour practices'] +#  I am too much of a Django newbie to know why. – Anna + +# 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' +# ])