Fix boolean fields of resources table

This commit is contained in:
PCoder 2021-11-26 17:34:02 +05:30
parent c28d46f9a1
commit 7fd0afb8b9
3 changed files with 69 additions and 8 deletions

View file

@ -413,6 +413,9 @@ class Command(BaseCommand):
def handle_object_dict(object_dict, model_name):
if model_name == 'Resource':
object_dict['url'] = object_dict['url'].strip("#")
for i in ['PEGASuS_Check_map_with_author', 'gloria', 'gnomo', 'lter', 'ltser', 'miren', 'team', 'inventory']:
if i in object_dict:
object_dict[i] = True if object_dict[i].lower().strip() == 'true' else False
if model_name == 'Range':
# Reinstate range_name key
object_dict['range_name'] = object_dict['range_name_id']

View file

@ -0,0 +1,58 @@
# Generated by Django 3.2.5 on 2021-11-26 12:03
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('app', '0025_alter_resource_url'),
]
operations = [
migrations.AlterField(
model_name='resource',
name='PEGASuS_Check_map_with_author',
field=models.BooleanField(blank=True, default=False, null=True),
),
migrations.AlterField(
model_name='resource',
name='gloria',
field=models.BooleanField(blank=True, default=False, null=True),
),
migrations.AlterField(
model_name='resource',
name='gnomo',
field=models.BooleanField(blank=True, default=False, null=True),
),
migrations.AlterField(
model_name='resource',
name='inventory',
field=models.BooleanField(blank=True, default=False, null=True),
),
migrations.AlterField(
model_name='resource',
name='lter',
field=models.BooleanField(blank=True, default=False, null=True),
),
migrations.AlterField(
model_name='resource',
name='ltser',
field=models.BooleanField(blank=True, default=False, null=True),
),
migrations.AlterField(
model_name='resource',
name='miren',
field=models.BooleanField(blank=True, default=False, null=True),
),
migrations.AlterField(
model_name='resource',
name='team',
field=models.BooleanField(blank=True, default=False, null=True),
),
migrations.AlterField(
model_name='resource',
name='type',
field=models.TextField(blank=True, choices=[('', ''), ('Atlas', 'Atlas'), ('Book', 'Book'), ('Book chapter', 'Book chapter'), ('Case study', 'Case study'), ('Conservation project', 'Conservation project'), ('Dataset', 'Dataset'), ('Development project', 'Development project'), ('Journal article', 'Journal article'), ('LTER', 'LTER'), ('Map', 'Map'), ('Network', 'Network'), ('PEGASuS', 'PEGASuS'), ('Presentation', 'Presentation'), ('Report', 'Report'), ('Research project', 'Research project'), ('Research Site', 'Research Site'), ('Thesis', 'Thesis'), ('Video', 'Video'), ('Website', 'Website'), ('Working Group', 'Working Group')], null=True),
),
]

View file

@ -192,17 +192,17 @@ class Resource(models.Model):
lat = models.TextField(blank=True, null=True)
lon = models.TextField(blank=True, null=True)
stars = models.TextField(blank=True, null=True, choices=STAR_CHOICES)
PEGASuS_Check_map_with_author = models.TextField(blank=True, null=True)
PEGASuS_Check_map_with_author = models.BooleanField(default=False, null=True, blank=True)
PEGASuS_polygon_ID = models.TextField(blank=True, null=True)
PEGASuS_Polygon_comments = models.TextField(blank=True, null=True)
PEGASuS_Assessment_ID = models.TextField(blank=True, null=True)
gloria = models.TextField(blank=True, null=True)
gnomo = models.TextField(blank=True, null=True)
lter = models.TextField(blank=True, null=True)
ltser = models.TextField(blank=True, null=True)
miren = models.TextField(blank=True, null=True)
team = models.TextField(blank=True, null=True)
inventory = models.TextField(blank=True, null=True)
gloria = models.BooleanField(default=False, null=True, blank=True)
gnomo = models.BooleanField(default=False, null=True, blank=True)
lter = models.BooleanField(default=False, null=True, blank=True)
ltser = models.BooleanField(default=False, null=True, blank=True)
miren = models.BooleanField(default=False, null=True, blank=True)
team = models.BooleanField(default=False, null=True, blank=True)
inventory = models.BooleanField(default=False, null=True, blank=True)
doi = models.TextField(blank=True, null=True)
wiki_data_id = models.TextField(blank=True, null=True)