2018-09-22 18:09:01 +00:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# Generated by Django 1.11.15 on 2018-09-22 17:43
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
import multiselectfield.db.fields
|
2019-08-19 21:53:34 +00:00
|
|
|
from django.db import migrations
|
|
|
|
from django.db import models
|
2018-09-22 18:09:01 +00:00
|
|
|
|
|
|
|
string_fields = [
|
2019-08-19 21:37:32 +00:00
|
|
|
"additional_technical_details",
|
|
|
|
"associated_infrastructure",
|
|
|
|
"biomass_detail",
|
|
|
|
"community_voices",
|
|
|
|
"contractor_or_supplier_of_technology",
|
|
|
|
"direct_comms",
|
|
|
|
"entry_name",
|
|
|
|
"full_description",
|
|
|
|
"generation_equipment_supplier",
|
|
|
|
"generation_technology",
|
|
|
|
"generation_technology_other",
|
|
|
|
"identified_partnerships",
|
|
|
|
"isolated_or_widespread",
|
|
|
|
"key_actors_involved",
|
|
|
|
"land_ownership",
|
|
|
|
"land_ownership_details",
|
|
|
|
"media_coverage_independent",
|
|
|
|
"media_coverage_mainstream",
|
|
|
|
"minerals_or_commodities",
|
|
|
|
"minerals_or_commodities_other",
|
|
|
|
"name_of_territory_or_area",
|
|
|
|
"negative_case_reasons",
|
|
|
|
"negative_case_reasons_other",
|
|
|
|
"negative_socioenvironmental_impacts",
|
|
|
|
"obstacles_and_hindrances",
|
|
|
|
"positive_case_type",
|
|
|
|
"potential_partnerships",
|
|
|
|
"power_technology",
|
|
|
|
"power_technology_other",
|
|
|
|
"project_status",
|
|
|
|
"project_status_detail",
|
|
|
|
"projected_production_of_commodities",
|
|
|
|
"sector_of_economy",
|
|
|
|
"size_of_concessions",
|
|
|
|
"social_media_links",
|
|
|
|
"socioeconomic_benefits",
|
|
|
|
"type_of_ecosystem",
|
|
|
|
"type_of_extraction",
|
|
|
|
"use_in_energy_economy",
|
|
|
|
"use_in_energy_economy_other",
|
|
|
|
"video_caption",
|
|
|
|
"video_credit",
|
|
|
|
"when_did_organising_start",
|
|
|
|
"who_has_been_involved",
|
2018-09-22 18:09:01 +00:00
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def remove_nulls(apps, schema_editor):
|
|
|
|
# We can't import the Person model directly as it may be a newer
|
|
|
|
# version than this migration expects. We use the historical version.
|
2019-08-19 21:37:32 +00:00
|
|
|
CaseStudy = apps.get_model("map", "CaseStudy")
|
2018-09-22 18:09:01 +00:00
|
|
|
for study in CaseStudy.objects.all():
|
|
|
|
for field in string_fields:
|
2018-10-05 13:29:24 +00:00
|
|
|
if getattr(study, field) == None:
|
2019-08-19 21:37:32 +00:00
|
|
|
setattr(study, field, "")
|
2018-09-22 18:09:01 +00:00
|
|
|
|
2018-11-20 17:59:28 +00:00
|
|
|
try:
|
|
|
|
study.save()
|
|
|
|
except:
|
2019-08-19 21:37:32 +00:00
|
|
|
from pdb import set_trace
|
2018-11-20 17:59:28 +00:00
|
|
|
|
2019-08-19 21:37:32 +00:00
|
|
|
set_trace()
|
2018-09-22 18:09:01 +00:00
|
|
|
|
|
|
|
|
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
2019-08-19 21:37:32 +00:00
|
|
|
dependencies = [("map", "0068_casestudydraft_created")]
|
2018-09-22 18:09:01 +00:00
|
|
|
|
2019-08-19 21:37:32 +00:00
|
|
|
operations = [migrations.RunPython(remove_nulls, migrations.RunPython.noop)]
|