diff --git a/Changelog.md b/Changelog.md index da1cfc5..f099f2b 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,40 +1,5 @@ # CHANGELOG.md -## 2.1 (2022-09-29) -- issue#11013: non-public entries appearing as public - -## 2.0 (2022-09-19) Dockerify https://redmine.ungleich.ch/issues/10884 - -Steps: - - Create .env.prod and .env.prod.db files - -#### .env.prod -``` -DEBUG=0 -SECRET_KEY=secret_key_here -DJANGO_SETTINGS_MODULE=gmba_django.settings.production -ALLOWED_HOSTS=localhost,127.0.0.1,[::1] -POSTGRES_USER=user -POSTGRES_PASSWORD=password -POSTGRES_DB=app -POSTGRES_HOST=db -POSTGRES_PORT=5432 -``` - -Building containers - - docker-compose -f docker-compose.prod.yml down -v --remove-orphans - - docker-compose -f docker-compose.prod.yml up -d --build - -Copy db and adust - - docker cp gd.sql gmba_django_db_1:/gd.sql - - docker-compose exec db psql --username=psql_username_name --dbname=psql_db_name < /gd.sql - -Migrate / check - - docker-compose exec web python manage.py migrate --noinput - -Static resources - - docker-compose -f docker-compose.prod.yml exec web python manage.py collectstatic --no-input --clear - ## 1.12 (2022-01-19) Bugfixes: diff --git a/Dockerfile.prod b/Dockerfile.prod deleted file mode 100644 index a67b632..0000000 --- a/Dockerfile.prod +++ /dev/null @@ -1,85 +0,0 @@ -########### -# BUILDER # -########### - -# pull official base image -FROM python:3.9.6-alpine as builder - -# set work directory -WORKDIR /usr/src/gmba_django - -# set environment variables -ENV PYTHONDONTWRITEBYTECODE 1 -ENV PYTHONUNBUFFERED 1 - -# install psycopg2 dependencies -RUN apk update \ - && apk add postgresql-dev gcc python3-dev musl-dev - -# lint -RUN pip install --upgrade pip -RUN pip install flake8==3.9.2 -COPY . . -#RUN flake8 --ignore=E501,F401 . - -# install dependencies -COPY ./requirements.txt . -RUN pip wheel --no-cache-dir --no-deps --wheel-dir /usr/src/gmba_django/wheels -r requirements.txt - - -######### -# FINAL # -######### - -# pull official base image -FROM python:3.9.6-alpine - -# create directory for the app user -RUN mkdir -p /home/app - -# create the app user -RUN addgroup -S app && adduser -S app -G app - -# create the appropriate directories -ENV HOME=/home/app -ENV APP_HOME=/home/app/gmba_django -RUN mkdir $APP_HOME -RUN mkdir $APP_HOME/static -RUN mkdir $APP_HOME/media - -#ADD gmba_django /data/app - -#WORKDIR /data/app/gmba_django - -# install dependencies -RUN apk update && apk add libpq -COPY --from=builder /usr/src/gmba_django/wheels /wheels -COPY --from=builder /usr/src/gmba_django/requirements.txt . -RUN pip install --no-cache /wheels/* - -# copy entrypoint.prod.sh -COPY ./entrypoint.prod.sh /entrypoint.prod.sh -COPY ./init.sh /init.sh -RUN sed -i 's/\r$//g' /entrypoint.prod.sh -RUN chmod +x /entrypoint.prod.sh - -# copy project -#COPY . $APP_HOME - -ADD . /home/app/gmba_django -WORKDIR /home/app/gmba_django - -# chown all the files to the app user -RUN chown -R app:app $APP_HOME - -# change to the app user -USER app - -#RUN python manage.py collectstatic --noinput - -# run entrypoint.prod.sh -ENTRYPOINT ["/entrypoint.prod.sh"] - -EXPOSE 8000 - -CMD ["gunicorn", "--bind", "[::]:8000", "--chdir", "/home/app/gmba_django", "--workers", "3", "gmba_django.wsgi:application"] diff --git a/app/admin.py b/app/admin.py index 5df424f..471efd5 100644 --- a/app/admin.py +++ b/app/admin.py @@ -1,53 +1,8 @@ -from re import A -from unicodedata import name from django.contrib import admin from django.utils.html import format_html from .models import * from django.forms import TextInput from django.conf import settings -from django.http import HttpResponse -import csv -from django import forms -from django.contrib.admin.widgets import AutocompleteSelect -from django.contrib import messages # import messages - - -class autocomplete_fields_form(forms.ModelForm): - """This form overrides autocomplete - organization field for Person class - """ - - def __init__(self, *args, **kwargs): - super(autocomplete_fields_form, self).__init__(*args, **kwargs) - - # self.fields['organization'].label = 'My new label' - - class Meta: - model = Person - fields = '__all__' - widgets = { - 'organization': forms.Select(attrs={'style': 'width:750px'}) - } - - -def download_csv(modeladmin, request, queryset): - name = queryset[0].__class__.__name__ - response = HttpResponse() - response['Content-Disposition'] = "attachment; filename="+name+"_table.csv" - first_row = [] - for i in queryset[0]._meta.__dict__.get("fields"): - temp = str(i).split('.') - first_row.append(temp[-1]) - - writer = csv.writer(response) - writer.writerow(first_row) - for dic in queryset.values(): - temp_list = (list(dic.values())) - writer.writerow(temp_list) - return response - - -download_csv.short_description = 'export (.csv)' class PeopleResourceInline(admin.TabularInline): @@ -68,13 +23,12 @@ class PersonAdmin(admin.ModelAdmin): PeopleRangeInline ] 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 = ( (None, { 'fields': ( ('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'), ('contact_email', 'email_2', 'skype', 'professional_phone'), 'organization', @@ -86,7 +40,7 @@ class PersonAdmin(admin.ModelAdmin): ('Research Scale', { 'classes': ('collapse',), 'fields': (('field_site', 'transect', 'mountain_top', 'mountain_range', 'landscape', 'regional', 'national',), - '_global'), + '_global'), }), ('Methods and tools', { 'classes': ('collapse',), @@ -110,95 +64,10 @@ class PersonAdmin(admin.ModelAdmin): }), ) list_display = ['id', 'full_name', 'organization'] - - #autocomplete_fields = ['organization'] - form = autocomplete_fields_form # adjust width of autocomplete_fields organization - + autocomplete_fields = ['organization'] list_per_page = settings.ADMIN_LIST_PER_PAGE ordering = ['full_name'] - actions = [download_csv] - - def get_field_queryset(self, db, db_field, request): - queryset = super().get_field_queryset(db, db_field, request) - if db_field.name == 'organization': - queryset = queryset.order_by( - 'country', 'organisation_english', 'organisation_2', 'organisation_3', 'acronym') - return queryset - - def get_actions(self, request): - actions = super().get_actions(request) - if 'delete_selected' in actions: - del actions['delete_selected'] - return actions - - def delete_model(self, request, obj): - self.delete_person(request, obj) - return super(PersonAdmin, self).delete_model(request, obj) - - def delete_person(self, request, obj): - taxa_people = TaxaPeople.objects.filter(person=obj.id) - for i in taxa_people: - i.delete() - ranges_people = RangesPeople.objects.filter(person=obj.id) - for i in ranges_people: - i.delete() - resources_people = ResourcesPeople.objects.filter(person=obj.id) - for i in resources_people: - i.delete() - scales_people = ScalesPeople.objects.filter(person=obj.id) - for i in scales_people: - i.delete() - people_function = PeopleFunction.objects.filter(person=obj.id) - for i in people_function: - i.delete() - people_range = PeopleRange.objects.filter(person=obj.id) - for i in people_range: - i.delete() - people_resources = PeopleResource.objects.filter(person=obj.id) - for i in people_resources: - i.delete() - fields_people = FieldsPeople.objects.filter(person=obj.id) - for i in fields_people: - i.delete() - methods_people = MethodsPeople.objects.filter(person=obj.id) - for i in methods_people: - i.delete() - - def delete_persons(self, request, obj): - for o in obj.all(): - taxa_people = TaxaPeople.objects.filter(person=o.id) - for i in taxa_people: - i.delete() - ranges_people = RangesPeople.objects.filter(person=o.id) - for i in ranges_people: - i.delete() - resources_people = ResourcesPeople.objects.filter(person=o.id) - for i in resources_people: - i.delete() - scales_people = ScalesPeople.objects.filter(person=o.id) - for i in scales_people: - i.delete() - people_function = PeopleFunction.objects.filter(person=o.id) - for i in people_function: - i.delete() - people_range = PeopleRange.objects.filter(person=o.id) - for i in people_range: - i.delete() - people_resources = PeopleResource.objects.filter(person=o.id) - for i in people_resources: - i.delete() - fields_people = FieldsPeople.objects.filter(person=o.id) - for i in fields_people: - i.delete() - methods_people = MethodsPeople.objects.filter(person=o.id) - for i in methods_people: - i.delete() - o.delete() - messages.success(request, "Successfully deleted") - - delete_persons.short_description = 'Delete Person & Related Fields' - - actions = [download_csv, delete_persons] +# list_display_links = ['id'] class ResourceKeywordInline(admin.TabularInline): @@ -262,52 +131,6 @@ class ResourceAdmin(admin.ModelAdmin): ) list_per_page = settings.ADMIN_LIST_PER_PAGE - def get_actions(self, request): - actions = super().get_actions(request) - if 'delete_selected' in actions: - del actions['delete_selected'] - return actions - - def delete_model(self, request, obj): - self.delete_resource(request, obj) - return super(ResourceAdmin, self).delete_model(request, obj) - - def delete_resource(self, request, obj): - resource_keyword = ResourceKeyword.objects.filter(resource=obj.id) - for i in resource_keyword: - i.delete() - resource_range = ResourceRange.objects.filter(resource_title=obj.id) - for i in resource_range: - i.delete() - resource_people = ResourcesPeople.objects.filter(resource=obj.id) - for i in resource_people: - i.delete() - resource_people_resource = PeopleResource.objects.filter( - resource=obj.id) - for i in resource_people_resource: - i.delete() - - def delete_resources(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() - messages.success(request, "Successfully deleted") - delete_resources.short_description = 'Delete Resource & Related Fields' - - actions = [download_csv, delete_resources] - class RangeNameTranslationInline(admin.TabularInline): autocomplete_fields = ['language_translation'] @@ -362,8 +185,6 @@ class RangeAdmin(admin.ModelAdmin): ordering = ['range_name'] list_per_page = settings.ADMIN_LIST_PER_PAGE - actions = [download_csv] - class PeopleOrganizationInline(admin.TabularInline): model = Person @@ -376,17 +197,15 @@ class OrganizationAdmin(admin.ModelAdmin): PeopleOrganizationInline, ] readonly_fields = ('org_num1',) - search_fields = ['organisation_search', 'org_alpha_search', - 'organisation_2', 'organisation_3', 'subject', 'organisation_english'] - list_display = ['org_num1', 'organisation_english', - 'organisation_2', 'country'] + search_fields = ['organisation_search', 'org_alpha_search', 'organisation_2', 'organisation_3', 'subject'] + list_display = ['org_num1', 'organisation_english', 'organisation_2', 'country'] fieldsets = ( (None, { 'fields': ( 'org_num1', ('acronym', 'category', 'subject'), 'country', - ('organisation_english', 'tel', 'email', 'url',), + ('organisation_english','tel', 'email', 'url',), ('organisation_2', 'organisation_3'), 'organisation_original', ) @@ -401,12 +220,11 @@ class OrganizationAdmin(admin.ModelAdmin): ('Other details', { 'classes': ('collapse',), 'fields': ( - 'tags', - ), + 'tags', + ), }) ) ordering = ['organisation_english'] - actions = [download_csv] def org_url(self, instance): return format_html('{1}', @@ -499,8 +317,7 @@ class SpeciesAdmin(admin.ModelAdmin): class TaxonRangeAdmin(admin.ModelAdmin): 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'] def range_name(self, obj): @@ -574,7 +391,6 @@ admin.site.register(Keyword, KeywordAdmin) # admin.site.register(Scale) # admin.site.register(Taxon) # admin.site.register(Field, FieldAdmin) -admin.site.disable_action('delete_selected') # LU models diff --git a/app/management/commands/import.py b/app/management/commands/import.py index b9eea00..e7d83cb 100644 --- a/app/management/commands/import.py +++ b/app/management/commands/import.py @@ -356,7 +356,7 @@ class Command(BaseCommand): for k, v in self.csv_files_models_dict.items(): if v.strip().lower() == model_name.strip().lower(): csv_file_name = k - if csv_file_name == '': + if k == '': raise Exception('Could not find a csv file name for model %s' % model_name) if csv_folder_path.endswith('/'): file_path = '%s%s' % (csv_folder_path, csv_file_name) diff --git a/app/models.py b/app/models.py index 8875ee0..bed7292 100644 --- a/app/models.py +++ b/app/models.py @@ -31,8 +31,7 @@ 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: @@ -54,10 +53,8 @@ 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' @@ -95,14 +92,10 @@ 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) @@ -120,16 +113,14 @@ 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) @@ -210,8 +201,7 @@ 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) @@ -362,20 +352,15 @@ 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'), @@ -399,8 +384,7 @@ 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'), @@ -415,12 +399,9 @@ 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) @@ -433,33 +414,27 @@ 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: if self.organisation_2: name = f"{self.organisation_english} ({self.organisation_2})" - name = f"{self.country} < {self.organisation_english} < {self.organisation_2} < {self.organisation_3} < {self.acronym}" - else: name = f"{self.organisation_english}" - name = f"{self.country} < {self.organisation_english} < {self.organisation_2} < {self.organisation_3} < {self.acronym}" - else: - name = ' ---' + 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 @@ -476,10 +451,8 @@ 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): @@ -532,10 +505,8 @@ 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) @@ -558,10 +529,8 @@ 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) @@ -569,8 +538,7 @@ 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): @@ -592,10 +560,8 @@ 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) @@ -618,12 +584,12 @@ class Person(models.Model): ('''Involved scientist Steering committee''', '''Involved scientist Steering committee'''), - ('Network', 'Network'), + ('Network', 'Network'), ('Newsletter only', 'Newsletter only'), ('''Steering committee Involved scientist''', '''Steering committee Involved scientist''') - ) + ) id = models.AutoField(primary_key=True) source_id = models.IntegerField(blank=True, null=True) title = models.CharField(blank=True, null=True, max_length=255) @@ -634,9 +600,7 @@ 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 renamed because it started with '_'. - field_indexer = models.TextField( - db_column='_indexer', 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) @@ -647,16 +611,12 @@ 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) @@ -681,8 +641,7 @@ Involved scientist''') assessment = models.BooleanField(default=False) meta_analysis = models.BooleanField(default=False) synthesis = models.BooleanField(default=False) - # "Qualitative social science methods (interviews, surveys)" - qualitative_ssm = 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) @@ -715,7 +674,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 @@ -740,16 +699,11 @@ 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' @@ -761,8 +715,7 @@ 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' @@ -774,8 +727,7 @@ 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' @@ -786,8 +738,7 @@ 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: @@ -811,8 +762,7 @@ 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 @@ -820,10 +770,8 @@ 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) @@ -834,8 +782,7 @@ 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) @@ -843,8 +790,7 @@ 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) @@ -875,8 +821,7 @@ 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): @@ -885,10 +830,8 @@ 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') diff --git a/app/static/app/gmba-search.tag b/app/static/app/gmba-search.tag index c4136c7..c8cc28c 100644 --- a/app/static/app/gmba-search.tag +++ b/app/static/app/gmba-search.tag @@ -248,7 +248,7 @@