Merge remote-tracking branch 'ungleich-public/master' into 10884-dockerify

This commit is contained in:
PCoder 2022-09-19 10:24:47 +05:30
commit 00c03e7bec
2 changed files with 160 additions and 76 deletions

View file

@ -9,27 +9,28 @@ from django.http import HttpResponse
import csv import csv
from django import forms from django import forms
from django.contrib.admin.widgets import AutocompleteSelect from django.contrib.admin.widgets import AutocompleteSelect
class autocomplete_fields_form(forms.ModelForm): class autocomplete_fields_form(forms.ModelForm):
"""This form overrides autocomplete """This form overrides autocomplete
organization field for Person class organization field for Person class
""" """
def __init__(self, *args, **kwargs): def __init__(self, *args, **kwargs):
super(autocomplete_fields_form, self).__init__(*args, **kwargs) super(autocomplete_fields_form, self).__init__(*args, **kwargs)
# self.fields['organization'].label = 'My new label' # self.fields['organization'].label = 'My new label'
class Meta: class Meta:
model = Person model = Person
fields = '__all__' fields = '__all__'
widgets={ widgets = {
'organization': forms.Select(attrs={'style': 'width:750px'}) 'organization': forms.Select(attrs={'style': 'width:750px'})
} }
def download_csv(modeladmin, request, queryset): def download_csv(modeladmin, request, queryset):
name = queryset[0].__class__.__name__ name = queryset[0].__class__.__name__
response = HttpResponse() response = HttpResponse()
response['Content-Disposition'] = "attachment; filename="+name+"_table.csv" response['Content-Disposition'] = "attachment; filename="+name+"_table.csv"
first_row = [] first_row = []
@ -40,12 +41,14 @@ def download_csv(modeladmin, request, queryset):
writer = csv.writer(response) writer = csv.writer(response)
writer.writerow(first_row) writer.writerow(first_row)
for dic in queryset.values(): for dic in queryset.values():
temp_list = (list(dic.values())) temp_list = (list(dic.values()))
writer.writerow(temp_list) writer.writerow(temp_list)
return response return response
download_csv.short_description = 'export (.csv)' download_csv.short_description = 'export (.csv)'
class PeopleResourceInline(admin.TabularInline): class PeopleResourceInline(admin.TabularInline):
autocomplete_fields = ['resource'] autocomplete_fields = ['resource']
model = PeopleResource model = PeopleResource
@ -64,12 +67,13 @@ class PersonAdmin(admin.ModelAdmin):
PeopleRangeInline PeopleRangeInline
] ]
readonly_fields = ['id'] readonly_fields = ['id']
search_fields = ['title', 'first_name', 'last_name', 'organisation', 'position', 'country__short_name', 'contact_email'] search_fields = ['title', 'first_name', 'last_name', 'organisation',
'position', 'country__short_name', 'contact_email']
fieldsets = ( fieldsets = (
(None, { (None, {
'fields': ( 'fields': (
('id', 'profile_on_web', 'news_letter'), ('id', 'profile_on_web', 'news_letter'),
('mr_mrs', 'title','full_name', 'position'), ('mr_mrs', 'title', 'full_name', 'position'),
('first_name', 'last_name', 'search_name', 'status'), ('first_name', 'last_name', 'search_name', 'status'),
('contact_email', 'email_2', 'skype', 'professional_phone'), ('contact_email', 'email_2', 'skype', 'professional_phone'),
'organization', 'organization',
@ -81,7 +85,7 @@ class PersonAdmin(admin.ModelAdmin):
('Research Scale', { ('Research Scale', {
'classes': ('collapse',), 'classes': ('collapse',),
'fields': (('field_site', 'transect', 'mountain_top', 'mountain_range', 'landscape', 'regional', 'national',), 'fields': (('field_site', 'transect', 'mountain_top', 'mountain_range', 'landscape', 'regional', 'national',),
'_global'), '_global'),
}), }),
('Methods and tools', { ('Methods and tools', {
'classes': ('collapse',), 'classes': ('collapse',),
@ -107,7 +111,7 @@ class PersonAdmin(admin.ModelAdmin):
list_display = ['id', 'full_name', 'organization'] list_display = ['id', 'full_name', 'organization']
#autocomplete_fields = ['organization'] #autocomplete_fields = ['organization']
form = autocomplete_fields_form # adjust width of autocomplete_fields organization form = autocomplete_fields_form # adjust width of autocomplete_fields organization
list_per_page = settings.ADMIN_LIST_PER_PAGE list_per_page = settings.ADMIN_LIST_PER_PAGE
ordering = ['full_name'] ordering = ['full_name']
@ -116,8 +120,11 @@ class PersonAdmin(admin.ModelAdmin):
def get_field_queryset(self, db, db_field, request): def get_field_queryset(self, db, db_field, request):
queryset = super().get_field_queryset(db, db_field, request) queryset = super().get_field_queryset(db, db_field, request)
if db_field.name == 'organization': if db_field.name == 'organization':
queryset = queryset.order_by('country','organisation_english','organisation_2','organisation_3', 'acronym') queryset = queryset.order_by(
'country', 'organisation_english', 'organisation_2', 'organisation_3', 'acronym')
return queryset return queryset
class ResourceKeywordInline(admin.TabularInline): class ResourceKeywordInline(admin.TabularInline):
autocomplete_fields = ['keyword'] autocomplete_fields = ['keyword']
model = ResourceKeyword model = ResourceKeyword
@ -139,10 +146,6 @@ class ResourcePeopleInline(admin.TabularInline):
} }
class ResourceAdmin(admin.ModelAdmin): class ResourceAdmin(admin.ModelAdmin):
inlines = [ inlines = [
ResourceKeywordInline, ResourceKeywordInline,
@ -182,8 +185,32 @@ class ResourceAdmin(admin.ModelAdmin):
}), }),
) )
list_per_page = settings.ADMIN_LIST_PER_PAGE list_per_page = settings.ADMIN_LIST_PER_PAGE
actions = [download_csv]
def get_actions(self, request):
actions = super().get_actions(request)
if 'delete_selected' in actions:
del actions['delete_selected']
return actions
def delete_resource(self, request, obj):
for o in obj.all():
resource_keyword = ResourceKeyword.objects.filter(resource=o.id)
for i in resource_keyword:
i.delete()
resource_range = ResourceRange.objects.filter(resource_title=o.id)
for i in resource_range:
i.delete()
resource_people = ResourcesPeople.objects.filter(resource=o.id)
for i in resource_people:
i.delete()
resource_people_resource = PeopleResource.objects.filter(
resource=o.id)
for i in resource_people_resource:
i.delete()
o.delete()
delete_resource.short_description = 'Delete Resource & Related Fields'
actions = [download_csv, delete_resource]
class RangeNameTranslationInline(admin.TabularInline): class RangeNameTranslationInline(admin.TabularInline):
@ -241,6 +268,7 @@ class RangeAdmin(admin.ModelAdmin):
actions = [download_csv] actions = [download_csv]
class PeopleOrganizationInline(admin.TabularInline): class PeopleOrganizationInline(admin.TabularInline):
model = Person model = Person
exclude = ['source_id', 'organisation', 'field_indexer'] exclude = ['source_id', 'organisation', 'field_indexer']
@ -252,15 +280,17 @@ class OrganizationAdmin(admin.ModelAdmin):
PeopleOrganizationInline, PeopleOrganizationInline,
] ]
readonly_fields = ('org_num1',) readonly_fields = ('org_num1',)
search_fields = ['organisation_search', 'org_alpha_search', 'organisation_2', 'organisation_3', 'subject','organisation_english'] search_fields = ['organisation_search', 'org_alpha_search',
list_display = ['org_num1', 'organisation_english', 'organisation_2', 'country'] 'organisation_2', 'organisation_3', 'subject', 'organisation_english']
list_display = ['org_num1', 'organisation_english',
'organisation_2', 'country']
fieldsets = ( fieldsets = (
(None, { (None, {
'fields': ( 'fields': (
'org_num1', 'org_num1',
('acronym', 'category', 'subject'), ('acronym', 'category', 'subject'),
'country', 'country',
('organisation_english','tel', 'email', 'url',), ('organisation_english', 'tel', 'email', 'url',),
('organisation_2', 'organisation_3'), ('organisation_2', 'organisation_3'),
'organisation_original', 'organisation_original',
) )
@ -275,8 +305,8 @@ class OrganizationAdmin(admin.ModelAdmin):
('Other details', { ('Other details', {
'classes': ('collapse',), 'classes': ('collapse',),
'fields': ( 'fields': (
'tags', 'tags',
), ),
}) })
) )
ordering = ['organisation_english'] ordering = ['organisation_english']
@ -373,7 +403,8 @@ class SpeciesAdmin(admin.ModelAdmin):
class TaxonRangeAdmin(admin.ModelAdmin): class TaxonRangeAdmin(admin.ModelAdmin):
model = TaxonRange model = TaxonRange
search_fields = ['range__range_name', 'taxon', 'subrange_or_region', 'distribution', 'source', 'remarks'] search_fields = ['range__range_name', 'taxon',
'subrange_or_region', 'distribution', 'source', 'remarks']
list_display = ['range_name', 'taxon'] list_display = ['range_name', 'taxon']
def range_name(self, obj): def range_name(self, obj):
@ -447,6 +478,7 @@ admin.site.register(Keyword, KeywordAdmin)
# admin.site.register(Scale) # admin.site.register(Scale)
# admin.site.register(Taxon) # admin.site.register(Taxon)
# admin.site.register(Field, FieldAdmin) # admin.site.register(Field, FieldAdmin)
admin.site.disable_action('delete_selected')
# LU models # LU models

View file

@ -31,7 +31,8 @@ class Field(models.Model):
class FieldsPeople(models.Model): class FieldsPeople(models.Model):
id = models.AutoField(primary_key=True) 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) field = models.ForeignKey(Field, models.DO_NOTHING, blank=True, null=True)
class Meta: class Meta:
@ -53,8 +54,10 @@ class Method(models.Model):
class MethodsPeople(models.Model): class MethodsPeople(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
person = models.ForeignKey('Person', models.DO_NOTHING, blank=True, null=True) person = models.ForeignKey(
method = models.ForeignKey(Method, models.DO_NOTHING, blank=True, null=True) 'Person', models.DO_NOTHING, blank=True, null=True)
method = models.ForeignKey(
Method, models.DO_NOTHING, blank=True, null=True)
class Meta: class Meta:
db_table = 'methods_people' 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_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 = models.CharField(blank=True, null=True, max_length=128)
range_name_ascii = 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') range_name_language = models.ForeignKey(
mother_range = models.ForeignKey("self", models.DO_NOTHING, blank=True, null=True, to_field='id') Language, models.DO_NOTHING, blank=True, null=True, to_field='id')
feature = models.ForeignKey(RangeType, models.DO_NOTHING, blank=True, null=True, to_field='id') mother_range = models.ForeignKey(
map_unit = models.TextField(blank=True, null=True, choices=MAP_UNIT_CHOICES) "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 = models.TextField(blank=True, null=True)
level_text = models.TextField(blank=True, null=True) level_text = models.TextField(blank=True, null=True)
level_1 = 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) comments = models.TextField(blank=True, null=True)
checked = models.BooleanField(default=False) checked = models.BooleanField(default=False)
source = models.TextField(blank=True, null=True) 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) geologic_region = models.TextField(blank=True, null=True)
gmba_v2_id = models.PositiveIntegerField(blank=True, null=True) gmba_v2_id = models.PositiveIntegerField(blank=True, null=True)
gmba_v2_id_str = models.TextField(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_id = models.CharField(blank=True, null=True, max_length=25)
wiki_data_url = models.URLField(blank=True, null=True) wiki_data_url = models.URLField(blank=True, null=True)
select_300 = models.BooleanField(default=False) 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_fr = models.CharField(blank=True, null=True, max_length=128)
name_de = 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_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_Check_map_with_author = models.BooleanField(default=False)
PEGASuS_polygon_ID = models.CharField(max_length=32, blank=True, null=True) PEGASuS_polygon_ID = models.CharField(max_length=32, blank=True, null=True)
PEGASuS_Polygon_comments = models.TextField(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) gloria = models.BooleanField(default=False)
gnomo = models.BooleanField(default=False) gnomo = models.BooleanField(default=False)
lter = models.BooleanField(default=False) lter = models.BooleanField(default=False)
@ -352,15 +362,20 @@ class GMBA_function(models.Model):
class Organisation(models.Model): class Organisation(models.Model):
CATEGORY_CHOICES = ( CATEGORY_CHOICES = (
('Independent', 'Independent'), ('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 > Institute', 'Academia > University > Institute'),
('Academia > University', 'Academia > University'), ('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)'), ('Private > NGO (not for profit)', 'Private > NGO (not for profit)'),
('Academia > Academy of Sciences', 'Academia > Academy of Sciences'), ('Academia > Academy of Sciences', 'Academia > Academy of Sciences'),
('Academia > Academy of Sciences > Institute', 'Academia > Academy of Sciences > Institute'), ('Academia > Academy of Sciences > Institute',
('Public administration > Government', 'Public administration > Government'), 'Academia > Academy of Sciences > Institute'),
('Intergovernmental Agency > Research Institution', 'Intergovernmental Agency > Research Institution'), ('Public administration > Government',
'Public administration > Government'),
('Intergovernmental Agency > Research Institution',
'Intergovernmental Agency > Research Institution'),
('Intergovernmental Agency', 'Intergovernmental Agency '), ('Intergovernmental Agency', 'Intergovernmental Agency '),
('Private > Research Institution', 'Private > Research Institution'), ('Private > Research Institution', 'Private > Research Institution'),
('Collection > Museum', 'Collection > Museum'), ('Collection > Museum', 'Collection > Museum'),
@ -384,7 +399,8 @@ class Organisation(models.Model):
('Culture / arts', 'Culture / arts'), ('Culture / arts', 'Culture / arts'),
('Geography', 'Geography'), ('Geography', 'Geography'),
('Zoology', 'Zoology'), ('Zoology', 'Zoology'),
('Development / poverty / human rights', 'Development / poverty / human rights'), ('Development / poverty / human rights',
'Development / poverty / human rights'),
('Social Sciences', 'Social Sciences'), ('Social Sciences', 'Social Sciences'),
('Earth Sciences', 'Earth Sciences'), ('Earth Sciences', 'Earth Sciences'),
('Health', 'Health'), ('Health', 'Health'),
@ -399,9 +415,12 @@ class Organisation(models.Model):
org_num1 = models.AutoField(primary_key=True, verbose_name='ID') org_num1 = models.AutoField(primary_key=True, verbose_name='ID')
organisation_search = models.TextField(blank=True, null=True) organisation_search = models.TextField(blank=True, null=True)
org_alpha_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_english = models.CharField(
organisation_2 = models.CharField(max_length=256, blank=True, null=True, verbose_name='Department 1') max_length=256, blank=True, null=True, verbose_name='Organisation')
organisation_3 = models.CharField(max_length=256, blank=True, null=True, verbose_name='Department 2') 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) organisation_original = models.TextField(blank=True, null=True)
acronym = models.CharField(max_length=128, blank=True, null=True) acronym = models.CharField(max_length=128, blank=True, null=True)
street = models.CharField(max_length=256, 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) url = models.URLField(blank=True, null=True)
tel = models.CharField(max_length=128, blank=True, null=True) tel = models.CharField(max_length=128, blank=True, null=True)
email = models.EmailField(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) tags = models.TextField(blank=True, null=True)
description = models.TextField(blank=True, null=True) description = models.TextField(blank=True, null=True)
northing = models.TextField(blank=True, null=True) northing = models.TextField(blank=True, null=True)
easting = models.TextField(blank=True, null=True) easting = models.TextField(blank=True, null=True)
category = models.TextField(blank=True, null=True, choices=CATEGORY_CHOICES) category = models.TextField(
subject = models.CharField(max_length=128, blank=True, null=True, choices=SUBJECT_CHOICES) blank=True, null=True, choices=CATEGORY_CHOICES)
subject = models.CharField(
max_length=128, blank=True, null=True, choices=SUBJECT_CHOICES)
def __str__(self): def __str__(self):
if self.organisation_english: if self.organisation_english:
@ -432,14 +454,12 @@ class Organisation(models.Model):
name = f"{self.organisation_english}" name = f"{self.organisation_english}"
name = f"{self.country} < {self.organisation_english} < {self.organisation_2} < {self.organisation_3} < {self.acronym}" name = f"{self.country} < {self.organisation_english} < {self.organisation_2} < {self.organisation_3} < {self.acronym}"
else: else:
name = ' ---' name = ' ---'
return name return name
class RangeOnlineInfo(models.Model): class RangeOnlineInfo(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
# This is supposed to be linked to MountainRange via range_name_map, but the range_name_map # 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): class RangeNameTranslation(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
range_name = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True) range_name = models.ForeignKey(
language_translation = models.ForeignKey(Language, models.DO_NOTHING, blank=True, null=True) 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) range_name_translation = models.TextField(blank=True, null=True)
def __str__(self): def __str__(self):
@ -510,8 +532,10 @@ class Keyword(models.Model):
class ResourceKeyword(models.Model): class ResourceKeyword(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
resource = models.ForeignKey(Resource, models.DO_NOTHING, blank=True, null=True) resource = models.ForeignKey(
keyword = models.ForeignKey(Keyword, models.DO_NOTHING, blank=True, null=True, to_field='keyword_id') 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): def __str__(self):
return '%s - %s' % (self.resource.title, self.keyword.keyword) return '%s - %s' % (self.resource.title, self.keyword.keyword)
@ -534,8 +558,10 @@ class NamesImport(models.Model):
class ResourceRange(models.Model): class ResourceRange(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
resource_title = models.ForeignKey(Resource, models.DO_NOTHING, blank=True, null=True) resource_title = models.ForeignKey(
range_name = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True) Resource, models.DO_NOTHING, blank=True, null=True)
range_name = models.ForeignKey(
MountainRange, models.DO_NOTHING, blank=True, null=True)
def __str__(self): def __str__(self):
return '%s, %s' % (self.resource_title.title, self.range_name.name) return '%s, %s' % (self.resource_title.title, self.range_name.name)
@ -543,7 +569,8 @@ class ResourceRange(models.Model):
class LanguageLink(models.Model): class LanguageLink(models.Model):
id = models.AutoField(primary_key=True) 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) language_letter_code = models.TextField(blank=True, null=True)
def __str__(self): def __str__(self):
@ -565,8 +592,10 @@ class Peak(models.Model):
class Search(models.Model): class Search(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
range_name = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True) range_name = models.ForeignKey(
repository = models.ForeignKey(Repository, models.DO_NOTHING, blank=True, null=True) 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_string = models.TextField(blank=True, null=True)
search_date = models.TextField(blank=True, null=True) search_date = models.TextField(blank=True, null=True)
result = models.TextField(blank=True, null=True) result = models.TextField(blank=True, null=True)
@ -589,12 +618,12 @@ class Person(models.Model):
('''Involved scientist ('''Involved scientist
Steering committee''', '''Involved scientist Steering committee''', '''Involved scientist
Steering committee'''), Steering committee'''),
('Network', 'Network'), ('Network', 'Network'),
('Newsletter only', 'Newsletter only'), ('Newsletter only', 'Newsletter only'),
('''Steering committee ('''Steering committee
Involved scientist''', '''Steering committee Involved scientist''', '''Steering committee
Involved scientist''') Involved scientist''')
) )
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
source_id = models.IntegerField(blank=True, null=True) source_id = models.IntegerField(blank=True, null=True)
title = models.CharField(blank=True, null=True, max_length=255) title = models.CharField(blank=True, null=True, max_length=255)
@ -605,7 +634,9 @@ Involved scientist''')
contact_email = models.EmailField(blank=True, null=True) # email_1 contact_email = models.EmailField(blank=True, null=True) # email_1
personal_url = models.URLField(blank=True, null=True) # url ? personal_url = models.URLField(blank=True, null=True) # url ?
biography = models.TextField(blank=True, null=True) 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) mr_mrs = models.TextField(blank=True, null=True, choices=MR_MRS_CHOICES)
full_name = models.CharField(blank=True, null=True, max_length=100) 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) mobile_number = models.CharField(blank=True, null=True, max_length=50)
url = models.URLField(blank=True, null=True) url = models.URLField(blank=True, null=True)
field_of_expertise = models.TextField(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) 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) news_letter = models.BooleanField(default=False)
country = models.ForeignKey(Country, models.DO_NOTHING, blank=True, null=True, to_field='id') country = models.ForeignKey(
organization = models.ForeignKey(Organisation, models.DO_NOTHING, blank=True, null=True) 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) birds = models.BooleanField(default=False)
mammals = models.BooleanField(default=False) mammals = models.BooleanField(default=False)
reptiles = models.BooleanField(default=False) reptiles = models.BooleanField(default=False)
@ -646,7 +681,8 @@ Involved scientist''')
assessment = models.BooleanField(default=False) assessment = models.BooleanField(default=False)
meta_analysis = models.BooleanField(default=False) meta_analysis = models.BooleanField(default=False)
synthesis = 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) genetic_analyses = models.BooleanField(default=False)
field_site = models.BooleanField(default=False) field_site = models.BooleanField(default=False)
transect = models.BooleanField(default=False) transect = models.BooleanField(default=False)
@ -679,7 +715,7 @@ Involved scientist''')
self.position if self and self.position else "", self.position if self and self.position else "",
self.biography if self and self.biography else "" self.biography if self and self.biography else ""
] if self else "") ] if self else "")
self.save() # self.save()
return True return True
else: else:
return False return False
@ -704,11 +740,16 @@ Involved scientist''')
'biography': self.biography or '', 'biography': self.biography or '',
} }
def save(self, *args, **kwargs):
self.index()
super(Person, self).save(*args, **kwargs)
class TaxaPeople(models.Model): class TaxaPeople(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=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: class Meta:
db_table = 'taxa_people' db_table = 'taxa_people'
@ -720,7 +761,8 @@ class TaxaPeople(models.Model):
class RangesPeople(models.Model): class RangesPeople(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=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: class Meta:
db_table = 'ranges_people' db_table = 'ranges_people'
@ -732,7 +774,8 @@ class RangesPeople(models.Model):
class ResourcesPeople(models.Model): class ResourcesPeople(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=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: class Meta:
db_table = 'resources_people' db_table = 'resources_people'
@ -743,7 +786,8 @@ class ResourcesPeople(models.Model):
class ScalesPeople(models.Model): class ScalesPeople(models.Model):
id = models.AutoField(primary_key=True) 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) scale = models.ForeignKey(Scale, models.DO_NOTHING, blank=True, null=True)
class Meta: class Meta:
@ -767,7 +811,8 @@ class Species(models.Model):
class PeopleFunction(models.Model): class PeopleFunction(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=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): def __str__(self):
return self.person.full_name return self.person.full_name
@ -775,8 +820,10 @@ class PeopleFunction(models.Model):
class SpeciesRange(models.Model): class SpeciesRange(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
scientific_name = models.ForeignKey(Species, models.DO_NOTHING, blank=True, null=True) scientific_name = models.ForeignKey(
range = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True) 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) endemic = models.TextField(blank=True, null=True)
source_url = 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): class PeopleRange(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=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): def __str__(self):
return str(self.id) return str(self.id)
@ -795,7 +843,8 @@ class PeopleRange(models.Model):
class TaxonRange(models.Model): class TaxonRange(models.Model):
id = models.AutoField(primary_key=True) 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) taxon = models.TextField(blank=True, null=True)
subrange_or_region = models.TextField(blank=True, null=True) subrange_or_region = models.TextField(blank=True, null=True)
taxon_status = 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) id = models.AutoField(primary_key=True)
person = models.ForeignKey(Person, models.CASCADE, blank=True, null=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) role = models.TextField(blank=True, null=True, choices=ROLES_CHOICES)
def __str__(self): def __str__(self):
@ -835,8 +885,10 @@ class PeopleResource(models.Model):
class RangeCountry(models.Model): class RangeCountry(models.Model):
id = models.AutoField(primary_key=True) id = models.AutoField(primary_key=True)
range = models.ForeignKey(MountainRange, models.DO_NOTHING, blank=True, null=True) range = models.ForeignKey(
country = models.ForeignKey(Country, models.DO_NOTHING, blank=True, null=True) MountainRange, models.DO_NOTHING, blank=True, null=True)
country = models.ForeignKey(
Country, models.DO_NOTHING, blank=True, null=True)
def __str__(self): def __str__(self):
return '%s --- %s' % (self.range.range_name if self.range else 'None', self.country.short_name if self.country else 'None') return '%s --- %s' % (self.range.range_name if self.range else 'None', self.country.short_name if self.country else 'None')