gmba_django/app/models.py

843 lines
32 KiB
Python
Raw Normal View History

# This is an auto-generated Django model module.
# You'll have to do the following manually to clean this up:
# * Rearrange models' order
# * Make sure each model has one field with primary_key=True
# * Make sure each ForeignKey and OneToOneField has `on_delete` set to the desired behavior
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from django.db import models
class AlembicVersion(models.Model):
version_num = models.TextField()
class Meta:
managed = False
db_table = 'alembic_version'
class Field(models.Model):
id = models.AutoField(primary_key=True)
name = models.TextField(blank=True, null=True)
class Meta:
db_table = 'field'
def __str__(self): return self.name
def dict(self):
return {'id': self.id, 'name': self.name}
class FieldsPeople(models.Model):
id = models.AutoField(primary_key=True)
person = models.ForeignKey('Person', models.DO_NOTHING, blank=True, null=True)
field = models.ForeignKey(Field, models.DO_NOTHING, blank=True, null=True)
class Meta:
db_table = 'fields_people'
class Method(models.Model):
id = models.AutoField(primary_key=True)
name = models.TextField(blank=True, null=True)
class Meta:
db_table = 'method'
def __str__(self): return self.name
def dict(self):
return {'id': self.id, 'name': self.name}
class MethodsPeople(models.Model):
id = models.AutoField(primary_key=True)
person = models.ForeignKey('Person', models.DO_NOTHING, blank=True, null=True)
method = models.ForeignKey(Method, models.DO_NOTHING, blank=True, null=True)
class Meta:
db_table = 'methods_people'
2021-11-23 09:53:27 +00:00
class Language(models.Model):
id = models.AutoField(primary_key=True)
language = models.TextField(blank=True, null=True)
def __str__(self):
return self.language
class RangeType(models.Model):
id = models.AutoField(primary_key=True)
range_type = models.TextField(blank=True, null=True)
def __str__(self):
return self.range_type
2021-11-28 06:51:08 +00:00
class MountainRange(models.Model):
2021-11-28 06:58:23 +00:00
MAP_UNIT_CHOICES = (
('Aggregated', 'Aggregated'),
('Basic', 'Basic'),
('No', 'No'),
)
id = models.AutoField(primary_key=True)
source_id = models.IntegerField(blank=True, null=True)
gmba_id = models.TextField(blank=True, null=True)
name = models.TextField(blank=True, null=True)
countries = models.TextField(blank=True, null=True)
range_name_map = models.CharField(blank=True, null=True, max_length=128)
#range_name_map = models.CharField(blank=True, null=True, unique=True, max_length=128)
range_name = models.CharField(blank=True, null=True, max_length=128)
range_name_ascii = models.CharField(blank=True, null=True, max_length=128)
2021-11-23 09:53:27 +00:00
range_name_language = models.ForeignKey(Language, models.DO_NOTHING, blank=True, null=True, to_field='id')
2021-11-25 05:35:12 +00:00
mother_range = models.ForeignKey("self", models.DO_NOTHING, blank=True, null=True, to_field='id')
feature = models.ForeignKey(RangeType, models.DO_NOTHING, blank=True, null=True, to_field='id')
2021-11-28 06:58:23 +00:00
map_unit = models.TextField(blank=True, null=True, choices=MAP_UNIT_CHOICES)
2021-10-30 04:23:49 +00:00
level = models.TextField(blank=True, null=True)
level_text = models.TextField(blank=True, null=True)
level_1 = models.TextField(blank=True, null=True)
level_2 = models.TextField(blank=True, null=True)
level_3 = models.TextField(blank=True, null=True)
2021-11-28 11:41:32 +00:00
latitude = models.CharField(blank=True, null=True, max_length=128)
longitude = models.CharField(blank=True, null=True, max_length=128)
2021-10-30 04:23:49 +00:00
orogeny = models.TextField(blank=True, null=True)
2021-11-29 04:05:36 +00:00
area = models.FloatField(default=-1)
GMBA_v1_id = models.CharField(blank=True, null=True, max_length=25)
2021-10-30 04:23:49 +00:00
peak_elevation = models.TextField(blank=True, null=True)
peak_name = models.TextField(blank=True, null=True)
peak_latitude = models.TextField(blank=True, null=True)
peak_longitude = models.TextField(blank=True, null=True)
comments = models.TextField(blank=True, null=True)
2021-11-26 12:56:59 +00:00
checked = models.BooleanField(default=False)
2021-10-30 04:23:49 +00:00
source = models.TextField(blank=True, null=True)
range_alternate_id = models.CharField(blank=True, null=True, max_length=128)
2021-10-30 04:23:49 +00:00
geologic_region = models.TextField(blank=True, null=True)
gmba_v2_id = models.PositiveIntegerField(blank=True, null=True)
2021-10-30 04:23:49 +00:00
gmba_v2_id_str = models.TextField(blank=True, null=True)
wiki_data_id = models.CharField(blank=True, null=True, max_length=25)
wiki_data_url = models.URLField(blank=True, null=True)
2022-01-13 04:15:40 +00:00
select_300 = models.BooleanField(default=False)
2022-01-13 04:37:06 +00:00
gmba_narrow = models.BooleanField(default=False, verbose_name="GMBA Standard")
name_fr = models.CharField(blank=True, null=True, max_length=128)
name_de = models.CharField(blank=True, null=True, max_length=128)
name_es = models.CharField(blank=True, null=True, max_length=128)
name_pt = models.CharField(blank=True, null=True, max_length=128)
name_cn = models.CharField(blank=True, null=True, max_length=128)
name_ru = models.CharField(blank=True, null=True, max_length=128)
name_tr = models.CharField(blank=True, null=True, max_length=128)
2021-10-30 04:23:49 +00:00
perimeter = models.TextField(blank=True, null=True)
color_all = models.TextField(blank=True, null=True)
color_basic = models.TextField(blank=True, null=True)
color_300 = models.TextField(blank=True, null=True)
elev_low = models.TextField(blank=True, null=True)
elev_high = models.TextField(blank=True, null=True)
elev_range = models.TextField(blank=True, null=True)
elev_avg = models.TextField(blank=True, null=True)
class Meta:
db_table = 'range'
def __str__(self):
2021-11-25 08:28:57 +00:00
return self.range_name if self and self.range_name else '--'
def dict(self):
return {
'id': self.id,
2021-11-25 08:28:57 +00:00
'name': self.range_name,
'gmba_id': self.gmba_id,
'countries': self.countries,
}
class Resource(models.Model):
2021-11-26 08:13:42 +00:00
STAR_CHOICES = (
("", ""),
("-", "-"),
("*", "*"),
("**", "**"),
("***", "***"),
("****", "****"),
("*****", "*****"),
)
2021-11-26 11:56:50 +00:00
TYPE_CHOICES = (
("", ""),
("Atlas", "Atlas"),
2021-11-28 13:20:51 +00:00
("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"),
2021-11-26 11:56:50 +00:00
)
id = models.AutoField(primary_key=True)
source_id = models.IntegerField(blank=True, null=True)
title = models.TextField(blank=True, null=True)
2021-11-26 11:17:09 +00:00
url = models.URLField(blank=True, null=True)
citation = models.TextField(blank=True, null=True)
abstract = models.TextField(blank=True, null=True)
2021-11-26 11:56:50 +00:00
type = models.TextField(blank=True, null=True, choices=TYPE_CHOICES)
2021-10-30 04:23:49 +00:00
author_keywords = models.TextField(blank=True, null=True)
2021-11-28 13:48:07 +00:00
lat = models.CharField(blank=True, null=True, max_length=128)
lon = models.CharField(blank=True, null=True, max_length=128)
2021-11-26 08:13:42 +00:00
stars = models.TextField(blank=True, null=True, choices=STAR_CHOICES)
2021-11-26 12:56:59 +00:00
PEGASuS_Check_map_with_author = models.BooleanField(default=False)
2021-11-28 13:48:07 +00:00
PEGASuS_polygon_ID = models.CharField(max_length=32, blank=True, null=True)
2021-10-30 04:23:49 +00:00
PEGASuS_Polygon_comments = models.TextField(blank=True, null=True)
2021-11-28 13:48:07 +00:00
PEGASuS_Assessment_ID = models.CharField(max_length=32, blank=True, null=True)
2021-11-26 12:56:59 +00:00
gloria = models.BooleanField(default=False)
gnomo = models.BooleanField(default=False)
lter = models.BooleanField(default=False)
ltser = models.BooleanField(default=False)
miren = models.BooleanField(default=False)
team = models.BooleanField(default=False)
inventory = models.BooleanField(default=False)
2021-11-28 13:48:07 +00:00
doi = models.CharField(max_length=128, blank=True, null=True)
wiki_data_id = models.CharField(max_length=128, blank=True, null=True)
2021-10-30 04:23:49 +00:00
class Meta:
db_table = 'resource'
def __str__(self):
return self.title
def dict(self):
return {
'id': self.id,
'title': self.title or '',
'citation': self.citation or '',
'url': self.url or '',
'abstract': self.abstract or '',
}
class Scale(models.Model):
id = models.AutoField(primary_key=True)
name = models.TextField(blank=True, null=True)
class Meta:
db_table = 'scale'
2021-10-11 03:03:49 +00:00
def __str__(self):
return self.name
class Taxon(models.Model):
id = models.AutoField(primary_key=True)
name = models.TextField(blank=True, null=True)
class Meta:
db_table = 'taxon'
def __str__(self): return self.name
def dict(self):
return {'id': self.id, 'name': self.name}
2021-10-29 02:33:55 +00:00
# LU models
class Country(models.Model):
id = models.AutoField(primary_key=True)
short_name = models.TextField(blank=True, null=True)
formal_name = models.TextField(blank=True, null=True)
membership_within_un_system = models.TextField(blank=True, null=True)
continent = models.TextField(blank=True, null=True)
eu_ms = models.TextField(blank=True, null=True)
eea_ms = models.TextField(blank=True, null=True)
iso3 = models.TextField(blank=True, null=True)
iso2 = models.TextField(blank=True, null=True)
def __str__(self):
return self.short_name if self else '--'
2021-10-29 02:33:55 +00:00
class GMBA_SpeciesGroup(models.Model):
id = models.AutoField(primary_key=True)
species_group = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return self.species_group
2021-10-29 02:33:55 +00:00
class PeopleStatus(models.Model):
id = models.AutoField(primary_key=True)
status = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return self.status
2021-10-29 02:33:55 +00:00
class RedListCategory(models.Model):
id = models.AutoField(primary_key=True)
red_list_category = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return self.red_list_category
2021-10-29 02:33:55 +00:00
class TaxonStatus(models.Model):
id = models.AutoField(primary_key=True)
taxon_status = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return self.taxon_status
2021-10-29 02:33:55 +00:00
class TaxonUnit(models.Model):
id = models.AutoField(primary_key=True)
taxon_unit = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return self.taxon_unit
2021-10-29 02:33:55 +00:00
class TrendsQuality(models.Model):
id = models.AutoField(primary_key=True)
trend = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return self.trend
2021-10-29 02:33:55 +00:00
class TrendsQuantity(models.Model):
id = models.AutoField(primary_key=True)
trend = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return self.trend
2021-10-29 02:33:55 +00:00
class Source(models.Model):
id = models.AutoField(primary_key=True)
2021-10-30 04:23:49 +00:00
source = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return self.source
2021-10-30 04:23:49 +00:00
class Repository(models.Model):
id = models.AutoField(primary_key=True)
repository_name = models.TextField(blank=True, null=True)
repository_url = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return '%s --- %s' % (self.repository_name, self.repository_url)
2021-10-30 04:23:49 +00:00
class GMBA_function(models.Model):
id = models.AutoField(primary_key=True)
gmba_function = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return self.gmba_function
2021-10-30 04:23:49 +00:00
class Organisation(models.Model):
CATEGORY_CHOICES = (
('Independent', 'Independent'),
('Public administration > Research Institution', 'Public administration > Research Institution'),
('Academia > University > Institute', 'Academia > University > Institute'),
('Academia > University', 'Academia > University'),
('Public administration > Other Agency', 'Public administration > Other Agency'),
('Private > NGO (not for profit)', 'Private > NGO (not for profit)'),
('Academia > Academy of Sciences', 'Academia > Academy of Sciences'),
('Academia > Academy of Sciences > Institute', 'Academia > Academy of Sciences > Institute'),
('Public administration > Government', 'Public administration > Government'),
('Intergovernmental Agency > Research Institution', 'Intergovernmental Agency > Research Institution'),
('Intergovernmental Agency', 'Intergovernmental Agency '),
('Private > Research Institution', 'Private > Research Institution'),
('Collection > Museum', 'Collection > Museum'),
('Private > Business', 'Private > Business'),
('Education > Graduate', 'Education > Graduate'),
('Collection > Botanical Garden', 'Collection > Botanical Garden'),
('Other', 'Other'),)
SUBJECT_CHOICES = (
('Other', 'Other'),
('Environment', 'Environment'),
('Ecology', 'Ecology'),
('Agriculture', 'Agriculture'),
('Botany', 'Botany'),
('Science and technology', 'Science and technology'),
('Biodiversity', 'Biodiversity'),
('Climate / Global Change', 'Climate / Global Change'),
('Mountains', 'Mountains'),
('Biology', 'Biology'),
('Forestry', 'Forestry'),
('Conservation', 'Conservation'),
('Culture / arts', 'Culture / arts'),
('Geography', 'Geography'),
('Zoology', 'Zoology'),
('Development / poverty / human rights', 'Development / poverty / human rights'),
('Social Sciences', 'Social Sciences'),
('Earth Sciences', 'Earth Sciences'),
('Health', 'Health'),
('Hydrology / Water', 'Hydrology / Water'),
('Sustainability', 'Sustainability'),
('Economy / finance', 'Economy / finance'),
('Natural Resources', 'Natural Resources'),
('Education', 'Education'),
('Architecture, planning & design', 'Architecture, planning & design'),
('', ''),
)
2021-11-28 16:33:34 +00:00
org_num1 = models.AutoField(primary_key=True, verbose_name='ID')
2021-10-30 04:23:49 +00:00
organisation_search = models.TextField(blank=True, null=True)
org_alpha_search = models.TextField(blank=True, null=True)
2021-11-28 16:37:17 +00:00
organisation_english = models.CharField(max_length=256, blank=True, null=True, verbose_name='Organisation')
organisation_2 = models.CharField(max_length=256, blank=True, null=True, verbose_name='Department 1')
organisation_3 = models.CharField(max_length=256, blank=True, null=True, verbose_name='Department 2')
2021-10-30 04:23:49 +00:00
organisation_original = models.TextField(blank=True, null=True)
acronym = models.CharField(max_length=128, blank=True, null=True)
street = models.CharField(max_length=256, blank=True, null=True)
po_box = models.CharField(max_length=128, blank=True, null=True)
postcode = models.CharField(max_length=64, blank=True, null=True)
city = models.CharField(max_length=64, blank=True, null=True)
2021-10-30 04:23:49 +00:00
region = models.TextField(blank=True, null=True)
search_url = models.TextField(blank=True, null=True)
lat_long = models.CharField(max_length=128, blank=True, null=True)
url = models.URLField(blank=True, null=True)
tel = models.CharField(max_length=128, blank=True, null=True)
email = models.EmailField(blank=True, null=True)
2021-11-26 06:48:13 +00:00
country = models.ForeignKey(Country, models.DO_NOTHING, blank=True, null=True, to_field='id')
2021-10-30 04:23:49 +00:00
tags = models.TextField(blank=True, null=True)
description = models.TextField(blank=True, null=True)
northing = models.TextField(blank=True, null=True)
easting = models.TextField(blank=True, null=True)
category = models.TextField(blank=True, null=True, choices=CATEGORY_CHOICES)
subject = models.CharField(max_length=128, blank=True, null=True, choices=SUBJECT_CHOICES)
2021-10-30 04:23:49 +00:00
2021-11-10 17:13:10 +00:00
def __str__(self):
if self.organisation_english:
if self.organisation_2:
name = f"{self.organisation_english} ({self.organisation_2})"
2022-04-12 07:47:17 +00:00
name = f"{self.country} < {self.organisation_english} < {self.organisation_2} < {self.organisation_3} < {self.acronym}"
else:
name = f"{self.organisation_english}"
2022-04-12 07:47:17 +00:00
name = f"{self.country} < {self.organisation_english} < {self.organisation_2} < {self.organisation_3} < {self.acronym}"
else:
name = ' ---'
return name
2021-11-10 17:13:10 +00:00
2021-10-30 04:23:49 +00:00
class RangeOnlineInfo(models.Model):
id = models.AutoField(primary_key=True)
# This is supposed to be linked to MountainRange via range_name_map, but the range_name_map
# is not itself unique. Are we missing something? TODO: Investigate
#range_name = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True, to_field='range_name_map')
#range_name = models.ForeignKey(MountainRange, blank=True, null=True, to_field='range_name_map', on_delete=models.CASCADE)
range_name = models.TextField(blank=True, null=True)
2021-10-30 04:23:49 +00:00
info_source = models.TextField(blank=True, null=True)
url = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return self.range_name
2021-10-30 04:23:49 +00:00
class RangeNameTranslation(models.Model):
id = models.AutoField(primary_key=True)
2021-11-28 06:51:08 +00:00
range_name = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
2021-10-30 04:23:49 +00:00
language_translation = models.ForeignKey(Language, models.DO_NOTHING, blank=True, null=True)
range_name_translation = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return '%s - %s' % (self.range_name, self.language_translation.language)
2021-10-30 04:23:49 +00:00
class AddElevation(models.Model):
id = models.AutoField(primary_key=True)
gmba_v2_id = models.TextField(blank=True, null=True)
2021-10-30 04:23:49 +00:00
elev_min = models.TextField(blank=True, null=True)
elev_max = models.TextField(blank=True, null=True)
elev_range = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return '%s - %s' % (self.gmba_v2_id, self.elev_range)
2021-10-30 04:23:49 +00:00
class GMBA_V2_Centroid(models.Model):
id = models.AutoField(primary_key=True)
gridcode = models.TextField(blank=True, null=True)
area = models.TextField(blank=True, null=True)
latitude = models.TextField(blank=True, null=True)
longitude = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return '%s - %s, %s' % (self.gridcode, self.latitude, self.longitude)
2021-10-30 04:23:49 +00:00
class ImportGeom210915(models.Model):
id = models.AutoField(primary_key=True)
gmba_v2_id = models.TextField(blank=True, null=True)
2021-10-30 04:23:49 +00:00
area = models.TextField(blank=True, null=True)
perimeter = models.TextField(blank=True, null=True)
color_all = models.TextField(blank=True, null=True)
color_basic = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return self.gmba_v2_id
2021-10-30 04:23:49 +00:00
class Keyword(models.Model):
keyword_id = models.AutoField(primary_key=True)
mother = models.ForeignKey("self", models.DO_NOTHING, blank=True, null=True, to_field='keyword_id',
related_name='mother_keyword')
2021-10-30 04:23:49 +00:00
keyword = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
2021-11-29 02:46:13 +00:00
return '%s > %s' % (self.mother, self.keyword) if self.mother.keyword != '->' else self.keyword
2021-10-30 04:23:49 +00:00
class ResourceKeyword(models.Model):
id = models.AutoField(primary_key=True)
resource = models.ForeignKey(Resource, models.DO_NOTHING, blank=True, null=True)
keyword = models.ForeignKey(Keyword, models.DO_NOTHING, blank=True, null=True, to_field='keyword_id')
2021-11-10 17:13:10 +00:00
def __str__(self):
return '%s - %s' % (self.resource.title, self.keyword.keyword)
2021-10-30 04:23:49 +00:00
class NamesImport(models.Model):
id = models.AutoField(primary_key=True)
gmba_v2_id = models.TextField(blank=True, null=True)
2021-10-30 04:23:49 +00:00
cn = models.TextField(blank=True, null=True)
de = models.TextField(blank=True, null=True)
es = models.TextField(blank=True, null=True)
fr = models.TextField(blank=True, null=True)
pt = models.TextField(blank=True, null=True)
ru = models.TextField(blank=True, null=True)
tr = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return '%s - %s - %s - %s' % (self.gmba_v2_id, self.cn, self.de, self.fr)
2021-10-30 04:23:49 +00:00
class ResourceRange(models.Model):
id = models.AutoField(primary_key=True)
2021-11-01 04:06:49 +00:00
resource_title = models.ForeignKey(Resource, models.DO_NOTHING, blank=True, null=True)
2021-11-28 06:51:08 +00:00
range_name = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
2021-10-30 04:23:49 +00:00
2021-11-10 17:13:10 +00:00
def __str__(self):
return '%s, %s' % (self.resource_title.title, self.range_name.name)
2021-10-30 04:23:49 +00:00
class LanguageLink(models.Model):
id = models.AutoField(primary_key=True)
language_number_code = models.ForeignKey(Language, models.DO_NOTHING, blank=True, null=True)
language_letter_code = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return '%s - %s' % (self.language_number_code.language, self.language_letter_code)
2021-10-30 04:23:49 +00:00
2021-11-01 04:06:49 +00:00
class Peak(models.Model):
2021-10-30 04:23:49 +00:00
id = models.AutoField(primary_key=True)
2021-11-01 04:06:49 +00:00
point_name = models.TextField(blank=True, null=True)
latitude = models.TextField(blank=True, null=True)
longitude = models.TextField(blank=True, null=True)
type = models.TextField(blank=True, null=True)
elevation = models.TextField(blank=True, null=True)
link = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return self.point_name
2021-11-01 04:06:49 +00:00
class Search(models.Model):
id = models.AutoField(primary_key=True)
2021-11-28 06:51:08 +00:00
range_name = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
2021-11-01 04:06:49 +00:00
repository = models.ForeignKey(Repository, models.DO_NOTHING, blank=True, null=True)
search_string = models.TextField(blank=True, null=True)
search_date = models.TextField(blank=True, null=True)
result = models.TextField(blank=True, null=True)
number_of_records = models.TextField(blank=True, null=True)
stored = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
2021-11-11 17:45:04 +00:00
return self.search_string if self else ' -- '
2021-11-10 17:13:10 +00:00
2021-11-01 04:06:49 +00:00
class Person(models.Model):
MR_MRS_CHOICES = (
('', ''),
('Ms', 'Ms'),
('Mr', 'Mr'),
)
2021-11-28 06:28:57 +00:00
GMBA_FUNCTION_CHOICES = (
('', ''),
('Involved scientist', 'Involved scientist'),
('''Involved scientist
Steering committee''', '''Involved scientist
Steering committee'''),
('Network', 'Network'),
('Newsletter only', 'Newsletter only'),
('''Steering committee
Involved scientist''', '''Steering committee
Involved scientist''')
)
2021-11-01 04:06:49 +00:00
id = models.AutoField(primary_key=True)
source_id = models.IntegerField(blank=True, null=True)
title = models.CharField(blank=True, null=True, max_length=255)
first_name = models.CharField(blank=True, null=True, max_length=50)
last_name = models.CharField(blank=True, null=True, max_length=50)
2021-11-01 04:06:49 +00:00
organisation = models.TextField(blank=True, null=True)
position = models.CharField(blank=True, null=True, max_length=255)
contact_email = models.EmailField(blank=True, null=True) # email_1
personal_url = models.URLField(blank=True, null=True) # url ?
2021-11-01 04:06:49 +00:00
biography = models.TextField(blank=True, null=True)
field_indexer = models.TextField(db_column='_indexer', blank=True, null=True) # Field renamed because it started with '_'.
mr_mrs = models.TextField(blank=True, null=True, choices=MR_MRS_CHOICES)
full_name = models.CharField(blank=True, null=True, max_length=100)
2021-11-28 05:20:51 +00:00
search_name = models.CharField(blank=True, null=True, max_length=100)
email_2 = models.EmailField(blank=True, null=True)
skype = models.CharField(blank=True, null=True, max_length=50)
professional_phone = models.CharField(blank=True, null=True, max_length=50)
mobile_number = models.CharField(blank=True, null=True, max_length=50)
url = models.URLField(blank=True, null=True)
2021-11-01 04:06:49 +00:00
field_of_expertise = models.TextField(blank=True, null=True)
2021-11-22 07:52:01 +00:00
status = models.ForeignKey(PeopleStatus, models.DO_NOTHING, blank=True, null=True, to_field='id')
2021-11-22 10:19:10 +00:00
entry_date = models.TextField(blank=True, null=True)
2021-11-28 06:28:57 +00:00
gmba_function = models.TextField(blank=True, null=True, choices=GMBA_FUNCTION_CHOICES)
2021-11-19 03:57:57 +00:00
news_letter = models.BooleanField(default=False)
country = models.ForeignKey(Country, models.DO_NOTHING, blank=True, null=True, to_field='id')
organization = models.ForeignKey(Organisation, models.DO_NOTHING, blank=True, null=True)
2021-11-19 02:02:47 +00:00
birds = models.BooleanField(default=False)
mammals = models.BooleanField(default=False)
reptiles = models.BooleanField(default=False)
amphibians = models.BooleanField(default=False)
fish = models.BooleanField(default=False)
insects = models.BooleanField(default=False)
molluscs = models.BooleanField(default=False)
crustaceans = models.BooleanField(default=False)
arachnids = models.BooleanField(default=False)
angiosperms = models.BooleanField(default=False)
gymnosperms = models.BooleanField(default=False)
fungi = models.BooleanField(default=False)
algae = models.BooleanField(default=False)
microbes = models.BooleanField(default=False)
biological_field_sampling = models.BooleanField(default=False)
data_mining = models.BooleanField(default=False)
remote_sensing = models.BooleanField(default=False)
gis = models.BooleanField(default=False)
spatial_analysis = models.BooleanField(default=False)
statistical_analysis = models.BooleanField(default=False)
modelling = models.BooleanField(default=False)
assessment = models.BooleanField(default=False)
meta_analysis = models.BooleanField(default=False)
synthesis = models.BooleanField(default=False)
qualitative_ssm = models.BooleanField(default=False) #"Qualitative social science methods (interviews, surveys)"
genetic_analyses = models.BooleanField(default=False)
field_site = models.BooleanField(default=False)
transect = models.BooleanField(default=False)
mountain_top = models.BooleanField(default=False)
mountain_range = models.BooleanField(default=False)
landscape = models.BooleanField(default=False)
regional = models.BooleanField(default=False)
national = models.BooleanField(default=False)
_global = models.BooleanField(default=False)
2021-11-01 04:06:49 +00:00
geographic_area_of_expertise = models.TextField(blank=True, null=True)
2021-11-19 03:57:57 +00:00
profile_on_web = models.BooleanField(default=False)
updated = models.BooleanField(default=False)
2021-11-01 04:06:49 +00:00
orcid = models.TextField(blank=True, null=True)
web_of_science = models.TextField(blank=True, null=True)
twitter = models.TextField(blank=True, null=True)
instagram = models.TextField(blank=True, null=True)
class Meta:
db_table = 'person'
2021-11-19 03:57:57 +00:00
def get_regional(self):
return False
2021-11-01 04:06:49 +00:00
def index(self):
2022-03-04 19:14:07 +00:00
if self:
self.field_indexer = " ".join([
self.first_name if self and self.first_name else "",
self.last_name if self and self.last_name else "",
self.organisation if self and self.organisation else "",
self.position if self and self.position else "",
self.biography if self and self.biography else ""
2022-03-11 11:23:15 +00:00
] if self else "")
self.save()
2022-03-04 19:14:07 +00:00
return True
else:
return False
2021-11-01 04:06:49 +00:00
def fullname(self):
return " ".join([self.title if self.title else '',
self.first_name if self.first_name else '',
self.last_name if self.last_name else ''])
2021-11-01 04:06:49 +00:00
def __str__(self):
2021-11-29 05:11:18 +00:00
return self.fullname() if self.fullname() else ""
2021-11-01 04:06:49 +00:00
def dict(self):
return {
'id': self.id,
'fullname': self.fullname(),
'organisation': self.organisation or '',
'position': self.position or '',
'country': self.country.short_name or '',
2021-11-01 04:06:49 +00:00
'personal_url': self.personal_url or '',
'personal_urls': [] if self.personal_url is None else self.personal_url.split(';'),
2021-11-01 04:06:49 +00:00
'biography': self.biography or '',
}
class TaxaPeople(models.Model):
id = models.AutoField(primary_key=True)
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=True)
2021-11-01 04:06:49 +00:00
taxon = models.ForeignKey('Taxon', models.DO_NOTHING, blank=True, null=True)
class Meta:
db_table = 'taxa_people'
2021-11-10 17:13:10 +00:00
def __str__(self):
return self.person.full_name
2021-11-01 04:06:49 +00:00
class RangesPeople(models.Model):
id = models.AutoField(primary_key=True)
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=True)
2021-11-28 06:51:08 +00:00
range = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
2021-11-01 04:06:49 +00:00
class Meta:
db_table = 'ranges_people'
2021-11-10 17:13:10 +00:00
def __str__(self):
return self.person.full_name
2021-11-01 04:06:49 +00:00
class ResourcesPeople(models.Model):
id = models.AutoField(primary_key=True)
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=True)
resource = models.ForeignKey(Resource, models.CASCADE, blank=True, null=True)
2021-11-01 04:06:49 +00:00
class Meta:
db_table = 'resources_people'
2021-11-10 17:13:10 +00:00
def __str__(self):
return self.person.full_name
2021-11-01 04:06:49 +00:00
class ScalesPeople(models.Model):
id = models.AutoField(primary_key=True)
person = models.ForeignKey(Person, models.DO_NOTHING, blank=True, null=True)
scale = models.ForeignKey(Scale, models.DO_NOTHING, blank=True, null=True)
class Meta:
db_table = 'scales_people'
2021-11-10 17:13:10 +00:00
def __str__(self):
return self.person.full_name
2021-11-01 04:06:49 +00:00
class Species(models.Model):
id = models.AutoField(primary_key=True)
scientific_name = models.TextField(blank=True, null=True)
2021-11-01 04:13:51 +00:00
_class = models.TextField(blank=True, null=True)
2021-11-01 04:06:49 +00:00
english_name = models.TextField(blank=True, null=True)
url = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return '%s, %s, %s' % (self.scientific_name, self._class, self.english_name)
2021-11-01 04:06:49 +00:00
class PeopleFunction(models.Model):
id = models.AutoField(primary_key=True)
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=True)
function = models.ForeignKey(GMBA_function, models.DO_NOTHING, blank=True, null=True)
2021-11-01 04:06:49 +00:00
2021-11-10 17:13:10 +00:00
def __str__(self):
return self.person.full_name
2021-11-01 04:06:49 +00:00
class SpeciesRange(models.Model):
id = models.AutoField(primary_key=True)
scientific_name = models.ForeignKey(Species, models.DO_NOTHING, blank=True, null=True)
2021-11-28 06:51:08 +00:00
range = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
2021-11-01 04:06:49 +00:00
endemic = models.TextField(blank=True, null=True)
source_url = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
2021-11-11 17:57:43 +00:00
return self.scientific_name.scientific_name if self and self.scientific_name else ' -- '
2021-11-10 17:13:10 +00:00
2021-11-01 04:06:49 +00:00
class PeopleRange(models.Model):
id = models.AutoField(primary_key=True)
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=True)
2021-11-28 06:51:08 +00:00
range = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
2021-11-01 04:06:49 +00:00
2021-11-10 17:13:10 +00:00
def __str__(self):
return str(self.id)
2021-11-10 17:13:10 +00:00
2021-11-01 04:06:49 +00:00
class TaxonRange(models.Model):
id = models.AutoField(primary_key=True)
2021-11-28 06:51:08 +00:00
range = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
taxon = models.TextField(blank=True, null=True)
2021-11-01 04:06:49 +00:00
subrange_or_region = models.TextField(blank=True, null=True)
taxon_status = models.TextField(blank=True, null=True)
distribution = models.TextField(blank=True, null=True)
redlist = models.TextField(blank=True, null=True)
count_unit = models.TextField(blank=True, null=True)
number_of_units = models.TextField(blank=True, null=True)
source = models.TextField(blank=True, null=True)
remarks = models.TextField(blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
2021-11-11 18:06:40 +00:00
return self.taxon if self.taxon else '--'
2021-11-10 17:13:10 +00:00
2021-11-01 04:06:49 +00:00
class PeopleResource(models.Model):
2021-11-28 05:51:58 +00:00
ROLES_CHOICES = (
('', ''),
('Author', 'Author'),
('Chair', 'Chair'),
('Contributor', 'Contributor'),
('Coordinator', 'Coordinator'),
('Co - Chair', 'Co - Chair'),
('Editor', 'Editor'),
('Head', 'Head'),
('Member', 'Member'),
('Project partner', 'Project partner'),
('SSC', 'SSC'),
)
2021-11-01 04:06:49 +00:00
id = models.AutoField(primary_key=True)
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=True)
2021-11-01 04:06:49 +00:00
resource = models.ForeignKey(Resource, models.DO_NOTHING, blank=True, null=True)
2021-11-28 05:51:58 +00:00
role = models.TextField(blank=True, null=True, choices=ROLES_CHOICES)
2021-11-01 04:06:49 +00:00
2021-11-10 17:13:10 +00:00
def __str__(self):
return self.person.full_name if self.person else ' -- '
2021-11-10 17:13:10 +00:00
2021-11-01 04:06:49 +00:00
class RangeCountry(models.Model):
id = models.AutoField(primary_key=True)
2021-11-28 06:51:08 +00:00
range = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
2021-11-01 04:06:49 +00:00
country = models.ForeignKey(Country, models.DO_NOTHING, blank=True, null=True)
2021-11-10 17:13:10 +00:00
def __str__(self):
return '%s --- %s' % (self.range.range_name if self.range else 'None', self.country.short_name if self.country else 'None')