person save method overload

This commit is contained in:
asamihassan 2022-09-08 22:44:24 +05:00
parent 2c4fb66176
commit 48a2585829

View file

@ -31,7 +31,8 @@ class Field(models.Model):
class FieldsPeople(models.Model):
id = models.AutoField(primary_key=True)
person = models.ForeignKey('Person', models.DO_NOTHING, blank=True, null=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:
@ -53,8 +54,10 @@ class Method(models.Model):
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)
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'
@ -92,10 +95,14 @@ class MountainRange(models.Model):
#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)
range_name_language = models.ForeignKey(Language, models.DO_NOTHING, blank=True, null=True, to_field='id')
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')
map_unit = models.TextField(blank=True, null=True, choices=MAP_UNIT_CHOICES)
range_name_language = models.ForeignKey(
Language, models.DO_NOTHING, blank=True, null=True, to_field='id')
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')
map_unit = models.TextField(
blank=True, null=True, choices=MAP_UNIT_CHOICES)
level = models.TextField(blank=True, null=True)
level_text = models.TextField(blank=True, null=True)
level_1 = models.TextField(blank=True, null=True)
@ -113,14 +120,16 @@ class MountainRange(models.Model):
comments = models.TextField(blank=True, null=True)
checked = models.BooleanField(default=False)
source = models.TextField(blank=True, null=True)
range_alternate_id = models.CharField(blank=True, null=True, max_length=128)
range_alternate_id = models.CharField(
blank=True, null=True, max_length=128)
geologic_region = models.TextField(blank=True, null=True)
gmba_v2_id = models.PositiveIntegerField(blank=True, null=True)
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)
select_300 = models.BooleanField(default=False)
gmba_narrow = models.BooleanField(default=False, verbose_name="GMBA Standard")
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)
@ -201,7 +210,8 @@ class Resource(models.Model):
PEGASuS_Check_map_with_author = models.BooleanField(default=False)
PEGASuS_polygon_ID = models.CharField(max_length=32, blank=True, null=True)
PEGASuS_Polygon_comments = models.TextField(blank=True, null=True)
PEGASuS_Assessment_ID = models.CharField(max_length=32, blank=True, null=True)
PEGASuS_Assessment_ID = models.CharField(
max_length=32, blank=True, null=True)
gloria = models.BooleanField(default=False)
gnomo = models.BooleanField(default=False)
lter = models.BooleanField(default=False)
@ -352,15 +362,20 @@ class GMBA_function(models.Model):
class Organisation(models.Model):
CATEGORY_CHOICES = (
('Independent', 'Independent'),
('Public administration > Research Institution', 'Public administration > Research Institution'),
('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'),
('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'),
('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'),
@ -384,7 +399,8 @@ class Organisation(models.Model):
('Culture / arts', 'Culture / arts'),
('Geography', 'Geography'),
('Zoology', 'Zoology'),
('Development / poverty / human rights', 'Development / poverty / human rights'),
('Development / poverty / human rights',
'Development / poverty / human rights'),
('Social Sciences', 'Social Sciences'),
('Earth Sciences', 'Earth Sciences'),
('Health', 'Health'),
@ -399,9 +415,12 @@ class Organisation(models.Model):
org_num1 = models.AutoField(primary_key=True, verbose_name='ID')
organisation_search = models.TextField(blank=True, null=True)
org_alpha_search = models.TextField(blank=True, null=True)
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')
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')
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)
@ -414,13 +433,16 @@ class Organisation(models.Model):
url = models.URLField(blank=True, null=True)
tel = models.CharField(max_length=128, blank=True, null=True)
email = models.EmailField(blank=True, null=True)
country = models.ForeignKey(Country, models.DO_NOTHING, blank=True, null=True, to_field='id')
country = models.ForeignKey(
Country, models.DO_NOTHING, blank=True, null=True, to_field='id')
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)
category = models.TextField(
blank=True, null=True, choices=CATEGORY_CHOICES)
subject = models.CharField(
max_length=128, blank=True, null=True, choices=SUBJECT_CHOICES)
def __str__(self):
if self.organisation_english:
@ -432,14 +454,12 @@ class Organisation(models.Model):
name = f"{self.organisation_english}"
name = f"{self.country} < {self.organisation_english} < {self.organisation_2} < {self.organisation_3} < {self.acronym}"
else:
name = ' ---'
return name
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
@ -456,8 +476,10 @@ class RangeOnlineInfo(models.Model):
class RangeNameTranslation(models.Model):
id = models.AutoField(primary_key=True)
range_name = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
language_translation = models.ForeignKey(Language, models.DO_NOTHING, blank=True, null=True)
range_name = models.ForeignKey(
MountainRange, models.DO_NOTHING, blank=True, null=True)
language_translation = models.ForeignKey(
Language, models.DO_NOTHING, blank=True, null=True)
range_name_translation = models.TextField(blank=True, null=True)
def __str__(self):
@ -510,8 +532,10 @@ class Keyword(models.Model):
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')
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')
def __str__(self):
return '%s - %s' % (self.resource.title, self.keyword.keyword)
@ -534,8 +558,10 @@ class NamesImport(models.Model):
class ResourceRange(models.Model):
id = models.AutoField(primary_key=True)
resource_title = models.ForeignKey(Resource, models.DO_NOTHING, blank=True, null=True)
range_name = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
resource_title = models.ForeignKey(
Resource, models.DO_NOTHING, blank=True, null=True)
range_name = models.ForeignKey(
MountainRange, models.DO_NOTHING, blank=True, null=True)
def __str__(self):
return '%s, %s' % (self.resource_title.title, self.range_name.name)
@ -543,7 +569,8 @@ class ResourceRange(models.Model):
class LanguageLink(models.Model):
id = models.AutoField(primary_key=True)
language_number_code = models.ForeignKey(Language, models.DO_NOTHING, blank=True, null=True)
language_number_code = models.ForeignKey(
Language, models.DO_NOTHING, blank=True, null=True)
language_letter_code = models.TextField(blank=True, null=True)
def __str__(self):
@ -565,8 +592,10 @@ class Peak(models.Model):
class Search(models.Model):
id = models.AutoField(primary_key=True)
range_name = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
repository = models.ForeignKey(Repository, models.DO_NOTHING, blank=True, null=True)
range_name = models.ForeignKey(
MountainRange, models.DO_NOTHING, blank=True, null=True)
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)
@ -605,7 +634,9 @@ Involved scientist''')
contact_email = models.EmailField(blank=True, null=True) # email_1
personal_url = models.URLField(blank=True, null=True) # url ?
biography = models.TextField(blank=True, null=True)
field_indexer = models.TextField(db_column='_indexer', blank=True, null=True) # Field renamed because it started with '_'.
# Field renamed because it started with '_'.
field_indexer = models.TextField(
db_column='_indexer', blank=True, null=True)
mr_mrs = models.TextField(blank=True, null=True, choices=MR_MRS_CHOICES)
full_name = models.CharField(blank=True, null=True, max_length=100)
@ -616,12 +647,16 @@ Involved scientist''')
mobile_number = models.CharField(blank=True, null=True, max_length=50)
url = models.URLField(blank=True, null=True)
field_of_expertise = models.TextField(blank=True, null=True)
status = models.ForeignKey(PeopleStatus, models.DO_NOTHING, blank=True, null=True, to_field='id')
status = models.ForeignKey(
PeopleStatus, models.DO_NOTHING, blank=True, null=True, to_field='id')
entry_date = models.TextField(blank=True, null=True)
gmba_function = models.TextField(blank=True, null=True, choices=GMBA_FUNCTION_CHOICES)
gmba_function = models.TextField(
blank=True, null=True, choices=GMBA_FUNCTION_CHOICES)
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)
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)
birds = models.BooleanField(default=False)
mammals = models.BooleanField(default=False)
reptiles = models.BooleanField(default=False)
@ -646,7 +681,8 @@ Involved scientist''')
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)"
# "Qualitative social science methods (interviews, surveys)"
qualitative_ssm = models.BooleanField(default=False)
genetic_analyses = models.BooleanField(default=False)
field_site = models.BooleanField(default=False)
transect = models.BooleanField(default=False)
@ -679,7 +715,7 @@ Involved scientist''')
self.position if self and self.position else "",
self.biography if self and self.biography else ""
] if self else "")
self.save()
# self.save()
return True
else:
return False
@ -704,11 +740,16 @@ Involved scientist''')
'biography': self.biography or '',
}
def save(self, *args, **kwargs):
self.index()
super(Person, self).save(*args, **kwargs)
class TaxaPeople(models.Model):
id = models.AutoField(primary_key=True)
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=True)
taxon = models.ForeignKey('Taxon', models.DO_NOTHING, blank=True, null=True)
taxon = models.ForeignKey(
'Taxon', models.DO_NOTHING, blank=True, null=True)
class Meta:
db_table = 'taxa_people'
@ -720,7 +761,8 @@ class TaxaPeople(models.Model):
class RangesPeople(models.Model):
id = models.AutoField(primary_key=True)
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=True)
range = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
range = models.ForeignKey(
MountainRange, models.DO_NOTHING, blank=True, null=True)
class Meta:
db_table = 'ranges_people'
@ -732,7 +774,8 @@ class RangesPeople(models.Model):
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)
resource = models.ForeignKey(
Resource, models.CASCADE, blank=True, null=True)
class Meta:
db_table = 'resources_people'
@ -743,7 +786,8 @@ class ResourcesPeople(models.Model):
class ScalesPeople(models.Model):
id = models.AutoField(primary_key=True)
person = models.ForeignKey(Person, models.DO_NOTHING, blank=True, null=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:
@ -767,7 +811,8 @@ class Species(models.Model):
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)
function = models.ForeignKey(
GMBA_function, models.DO_NOTHING, blank=True, null=True)
def __str__(self):
return self.person.full_name
@ -775,8 +820,10 @@ class PeopleFunction(models.Model):
class SpeciesRange(models.Model):
id = models.AutoField(primary_key=True)
scientific_name = models.ForeignKey(Species, models.DO_NOTHING, blank=True, null=True)
range = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
scientific_name = models.ForeignKey(
Species, models.DO_NOTHING, blank=True, null=True)
range = models.ForeignKey(
MountainRange, models.DO_NOTHING, blank=True, null=True)
endemic = models.TextField(blank=True, null=True)
source_url = models.TextField(blank=True, null=True)
@ -787,7 +834,8 @@ class SpeciesRange(models.Model):
class PeopleRange(models.Model):
id = models.AutoField(primary_key=True)
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=True)
range = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
range = models.ForeignKey(
MountainRange, models.DO_NOTHING, blank=True, null=True)
def __str__(self):
return str(self.id)
@ -795,7 +843,8 @@ class PeopleRange(models.Model):
class TaxonRange(models.Model):
id = models.AutoField(primary_key=True)
range = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
range = models.ForeignKey(
MountainRange, models.DO_NOTHING, blank=True, null=True)
taxon = models.TextField(blank=True, null=True)
subrange_or_region = models.TextField(blank=True, null=True)
taxon_status = models.TextField(blank=True, null=True)
@ -826,7 +875,8 @@ class PeopleResource(models.Model):
)
id = models.AutoField(primary_key=True)
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=True)
resource = models.ForeignKey(Resource, models.DO_NOTHING, blank=True, null=True)
resource = models.ForeignKey(
Resource, models.DO_NOTHING, blank=True, null=True)
role = models.TextField(blank=True, null=True, choices=ROLES_CHOICES)
def __str__(self):
@ -835,8 +885,10 @@ class PeopleResource(models.Model):
class RangeCountry(models.Model):
id = models.AutoField(primary_key=True)
range = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True)
country = models.ForeignKey(Country, models.DO_NOTHING, blank=True, null=True)
range = models.ForeignKey(
MountainRange, models.DO_NOTHING, blank=True, null=True)
country = models.ForeignKey(
Country, models.DO_NOTHING, blank=True, null=True)
def __str__(self):
return '%s --- %s' % (self.range.range_name if self.range else 'None', self.country.short_name if self.country else 'None')