Skip to content

Commit

Permalink
Upgrade Django to version 4.1.10, and other libraries (kartoza#3422)
Browse files Browse the repository at this point in the history
* Upgrade Django to version 4.1.10, and other libraries

* Update test_docker.py

* Fix search
  • Loading branch information
dimasciput authored Jul 28, 2023
1 parent 918ed19 commit b736e08
Show file tree
Hide file tree
Showing 44 changed files with 281 additions and 275 deletions.
2 changes: 1 addition & 1 deletion bims/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from django.contrib.gis import admin
from django.contrib import admin as django_admin
from django.core.mail import send_mail
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.contrib.auth.models import Permission
from django.contrib.flatpages.admin import FlatPageAdmin
from django.contrib.flatpages.models import FlatPage
Expand Down
165 changes: 82 additions & 83 deletions bims/api_urls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from django.conf.urls import url
from django.urls import path
from django.urls import re_path, include, path
# from rest_framework.documentation import include_docs_urls
from bims.api_views.boundary import (
BoundaryList,
Expand Down Expand Up @@ -104,209 +103,209 @@
)

urlpatterns = [
url(r'^location-type/(?P<pk>[0-9]+)/allowed-geometry/$',
re_path(r'^location-type/(?P<pk>[0-9]+)/allowed-geometry/$',
LocationTypeAllowedGeometryDetail.as_view()),
url(r'^location-site/$', LocationSiteList.as_view()),
url(r'^location-site-detail/$',
re_path(r'^location-site/$', LocationSiteList.as_view()),
re_path(r'^location-site-detail/$',
SingleLocationSiteOverview.as_view(),
name='location-site-detail'),
url(r'^multi-location-sites-overview/$',
re_path(r'^multi-location-sites-overview/$',
MultiLocationSitesOverview.as_view(),
name='multi-location-sites-overview'),
url(r'^multi-location-sites-background-overview/$',
re_path(r'^multi-location-sites-background-overview/$',
MultiLocationSitesBackgroundOverview.as_view(),
name='multi-location-sites-background-overview'),
url(r'^location-sites-summary/$',
re_path(r'^location-sites-summary/$',
LocationSitesSummary.as_view(),
name='location-sites-summary'),
url(r'^location-sites-endemism-chart-data/$',
re_path(r'^location-sites-endemism-chart-data/$',
LocationSitesEndemismChartData.as_view(),
name='location-sites-endemism-chart-data'),
url(r'^location-sites-occurrences-chart-data/$',
re_path(r'^location-sites-occurrences-chart-data/$',
OccurrencesChartData.as_view(),
name='location-sites-occurrences-chart-data'),
url(r'^location-sites-cons-chart-data/$',
re_path(r'^location-sites-cons-chart-data/$',
LocationSitesConservationChartData.as_view(),
name='location-sites-cons-chart-data'),
url(r'^location-sites-taxa-chart-data/$',
re_path(r'^location-sites-taxa-chart-data/$',
LocationSitesTaxaChartData.as_view(),
name='location-sites-taxa-chart-data'),
url(r'^location-sites-coordinate/$',
re_path(r'^location-sites-coordinate/$',
LocationSitesCoordinate.as_view(),
name='location-sites-coordinate'),
url(r'^taxon/(?P<pk>[0-9]+)/$',
re_path(r'^taxon/(?P<pk>[0-9]+)/$',
TaxonDetail.as_view()),
url(r'^cluster/(?P<administrative_level>\w+)/$',
re_path(r'^cluster/(?P<administrative_level>\w+)/$',
ClusterList.as_view()),
url(r'^collection/download/$',
re_path(r'^collection/download/$',
CollectionDownloader.as_view()),
url(r'^chemical-record/download/$',
re_path(r'^chemical-record/download/$',
ChemicalRecordDownloader.as_view()),
url(r'^collection-search/$',
re_path(r'^collection-search/$',
CollectionSearchAPIView.as_view(), name='collection-search'),
url(r'^search-module/$',
re_path(r'^search-module/$',
SearchModuleAPIView.as_view(), name='search-module'),
url(r'^boundary/geojson$',
re_path(r'^boundary/geojson$',
BoundaryGeojson.as_view(), name='boundary-geojson'),
url(r'^list-boundary/$',
re_path(r'^list-boundary/$',
BoundaryList.as_view(), name='list-boundary'),
url(r'^list-user-boundary/$',
re_path(r'^list-user-boundary/$',
UserBoundaryList.as_view(), name='list-user-boundary'),
url(r'^list-collector/$',
re_path(r'^list-collector/$',
CollectorList.as_view(), name='list-collector'),
url(r'^list-dst/$',
re_path(r'^list-dst/$',
DecisionSupportToolList.as_view(), name='list-dst'),
url(r'^list-category/$',
re_path(r'^list-category/$',
CategoryList.as_view(), name='list-date-category'),
url(r'^list-reference/$',
re_path(r'^list-reference/$',
ReferenceList.as_view(), name='list-reference'),
url(r'^list-entry-reference/$',
re_path(r'^list-entry-reference/$',
ReferenceEntryList.as_view(), name='list-entry-reference'),
url(r'^list-documents/$',
re_path(r'^list-documents/$',
DocumentList.as_view(), name='list-documents'),
url(r'^list-non-biodiversity/$',
re_path(r'^list-non-biodiversity/$',
NonBiodiversityLayerList.as_view(),
name='list-non-biodiversity-layer'),
url(r'^validate-object/$',
re_path(r'^validate-object/$',
ValidateObject.as_view(), name='validate-object'),
url(r'^reject-site-visit/$',
re_path(r'^reject-site-visit/$',
RejectSiteVisit.as_view(), name='reject-site-visit'),
url(r'^get-bio-object/$',
re_path(r'^get-bio-object/$',
GetBioRecordDetail.as_view(), name='get-bio-object'),
url(r'^get-site-code/$',
re_path(r'^get-site-code/$',
GetSiteCode.as_view(), name='get-site-code'),
url(r'^site-in-country/$',
re_path(r'^site-in-country/$',
SiteInCountry.as_view(), name='site-in-country'),
url(r'^get-river-name/$',
re_path(r'^get-river-name/$',
GetRiverName.as_view(), name='get-river-name'),
url(r'^get-geomorphological-zone/$',
re_path(r'^get-geomorphological-zone/$',
GetGeomorphologicalZone.as_view(), name='get-geomorphological-zone'),
url(r'^get-bio-records/$',
re_path(r'^get-bio-records/$',
GetBioRecords.as_view(), name='get-bio-records'),
url(r'^bio-collection-summary/$',
re_path(r'^bio-collection-summary/$',
BioCollectionSummary.as_view(), name='bio-collection-summary'),
url(r'^get-unvalidated-records/$',
re_path(r'^get-unvalidated-records/$',
GetNonValidatedRecords.as_view(), name='get-unvalidated-records'),
url(r'^send-email-validation/$',
re_path(r'^send-email-validation/$',
SendNotificationValidation.as_view(), name='send-email-validation'),
url(r'^filter-farm-id/$',
re_path(r'^filter-farm-id/$',
filter_farm_ids_view, name='filter-farm-id'),
url(r'^get-farm/(?P<farm_id>[\w-]+)/$',
re_path(r'^get-farm/(?P<farm_id>[\w-]+)/$',
get_farm_view, name='get-farm'),
url(r'hide-popup-info/$',
re_path(r'hide-popup-info/$',
HidePopupInfoUser.as_view(), name='hide-popup-user'),
url(r'^list-reference-category/$',
re_path(r'^list-reference-category/$',
ReferenceCategoryList.as_view(), name='list-reference-category'),
url(r'^list-source-collection/$',
re_path(r'^list-source-collection/$',
SourceCollectionList.as_view(), name='list-source-collection'),
# url(r'^docs/', include_docs_urls(title='BIMS API')),
url(r'^module-summary/$',
# re_path(r'^docs/', include_docs_urls(title='BIMS API')),
re_path(r'^module-summary/$',
ModuleSummary.as_view(),
name='module-summary'),
url(r'^endemism-list/$',
re_path(r'^endemism-list/$',
EndemismList.as_view(),
name='endemism-list'),
url(r'^spatial-scale-filter-list/$',
re_path(r'^spatial-scale-filter-list/$',
SpatialScaleFilterList.as_view(),
name='spatial-scale-filter-list'),
url(r'^site-search-result/$',
re_path(r'^site-search-result/$',
SiteSearchResult.as_view(),
name='site-search-result'),
url(r'^taxa-search-result/$',
re_path(r'^taxa-search-result/$',
TaxaSearchResult.as_view(),
name='taxa-search-result'),
url(r'^get-site-by-coord/$',
re_path(r'^get-site-by-coord/$',
SiteByCoord.as_view(), name='get-site-by-coord'),
url(r'^module-list/$',
re_path(r'^module-list/$',
ModuleList.as_view(),
name='module-list'),
url(r'^find-taxon/$',
re_path(r'^find-taxon/$',
FindTaxon.as_view(),
name='find-taxon'),
url(r'^add-new-taxon/$',
re_path(r'^add-new-taxon/$',
AddNewTaxon.as_view(),
name='add-new-taxon'),
url(r'^csv-download/$',
re_path(r'^csv-download/$',
CsvDownload.as_view(),
name='csv-download'),
url(r'^upload-status/(?P<session_id>[0-9]+)/$',
re_path(r'^upload-status/(?P<session_id>[0-9]+)/$',
DataUploadStatusView.as_view(),
name='upload-status'),
url(r'^harvest-status/(?P<session_id>[0-9]+)/$',
re_path(r'^harvest-status/(?P<session_id>[0-9]+)/$',
HarvestSessionStatusView.as_view(),
name='harvest-status'),
url(r'^taxa-list/$',
re_path(r'^taxa-list/$',
TaxaList.as_view(),
name='taxa-list'),
url(r'^update-taxon-group-order/$',
re_path(r'^update-taxon-group-order/$',
UpdateTaxonGroupOrder.as_view(),
name='update-taxon-group-order'),
url(r'^remove-taxa-from-taxon-group/$',
re_path(r'^remove-taxa-from-taxon-group/$',
RemoveTaxaFromTaxonGroup.as_view(),
name='remove-taxa-from-taxon-group'),
url(r'^add-taxa-to-taxon-group/$',
re_path(r'^add-taxa-to-taxon-group/$',
AddTaxaToTaxonGroup.as_view(),
name='add-taxa-to-taxon-group'),
url(r'^update-taxon-group/$',
re_path(r'^update-taxon-group/$',
UpdateTaxonGroup.as_view(),
name='update-taxon-group'),
url(r'^landing-page-summary/$',
re_path(r'^landing-page-summary/$',
LandingPageSummary.as_view(),
name='landing-page-summary'),
url(r'^location-context-report/$',
re_path(r'^location-context-report/$',
SummaryReportLocationContextApiView.as_view(),
name='location-context-report'),
url(r'^summary-general-report/$',
re_path(r'^summary-general-report/$',
SummaryReportGeneralApiView.as_view(),
name='summary-general-report'),
url(r'^location-site-summary-public/$',
re_path(r'^location-site-summary-public/$',
LocationSiteSummaryPublic.as_view(),
name='location-site-summary-public'),
url(r'^remove-occurrences/$',
re_path(r'^remove-occurrences/$',
RemoveOccurrencesApiView.as_view(),
name='remove-occurrences'),
url(r'^validate-location-site/$',
re_path(r'^validate-location-site/$',
ValidateSite.as_view(), name='validate-location-site'),
url(r'^validate-taxon/$',
re_path(r'^validate-taxon/$',
ValidateTaxon.as_view(), name='validate-taxon'),
url(r'^reject-location-site/$',
re_path(r'^reject-location-site/$',
RejectSite.as_view(), name='reject-location-site'),
url(r'^reject-taxon/$',
re_path(r'^reject-taxon/$',
RejectTaxon.as_view(), name='reject-taxon'),
url(r'^taxon-images/(?P<taxon>[0-9]+)/$', TaxonImageList.as_view(),
re_path(r'^taxon-images/(?P<taxon>[0-9]+)/$', TaxonImageList.as_view(),
name='taxon-images'),
url(r'^merge-sites/$',
re_path(r'^merge-sites/$',
MergeSites.as_view(),
name='merge-sites'),
url(r'^duplicate-records/download/$',
re_path(r'^duplicate-records/download/$',
DuplicateRecordsApiView.as_view(),
),
url(r'^thermal-data/$',
re_path(r'^thermal-data/$',
ThermalDataApiView.as_view(),
),
url(r'^water-temperature-threshold/$',
re_path(r'^water-temperature-threshold/$',
WaterTemperatureThresholdApiView.as_view(),
),
url(r'^source-reference-list/$',
re_path(r'^source-reference-list/$',
SourceReferenceAPIView.as_view(),
),
url(r'^decision-support-tool/$',
re_path(r'^decision-support-tool/$',
DecisionSupportToolView.as_view(),
name='decision-support-tool'
),
url(r'^dst-status/$',
re_path(r'^dst-status/$',
check_dst_status,
name='dst-status'
),
url(r'^celery-status/(?P<task_id>[\w-]+)/$',
re_path(r'^celery-status/(?P<task_id>[\w-]+)/$',
CeleryStatus.as_view(),
name='celery-status'
),
url(r'^download-request/$',
re_path(r'^download-request/$',
DownloadRequestApi.as_view(),
name='download-request'
),
url(r'^gbif-ids/download/$',
re_path(r'^gbif-ids/download/$',
GbifIdsDownloader.as_view()),

path('download-layer-data/<int:layer_id>/<str:query_filter>/',
Expand Down
10 changes: 7 additions & 3 deletions bims/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import django
from django.db import IntegrityError, transaction
from django.utils import timezone
from django.utils.encoding import smart_text
from django.utils.encoding import smart_str
try:
from django.utils.deprecation import MiddlewareMixin
except ImportError:
Expand Down Expand Up @@ -40,6 +40,10 @@ def is_anonymous(user):


class VisitorTrackingMiddleware(MiddlewareMixin):
@staticmethod
def is_ajax(request):
return request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest'

def _should_track(self, user, request, response):
# Session framework not installed, nothing to see here..
if not hasattr(request, 'session'):
Expand All @@ -49,7 +53,7 @@ def _should_track(self, user, request, response):
return False

# Do not track AJAX requests
if request.is_ajax() and not TRACK_AJAX_REQUESTS:
if self.is_ajax(request) and not TRACK_AJAX_REQUESTS:
return False

# Do not track if HTTP HttpResponse status_code blacklisted
Expand Down Expand Up @@ -101,7 +105,7 @@ def _refresh_visitor(self, user, request, visit_time):
# grab the latest User-Agent and store it
user_agent = request.META.get('HTTP_USER_AGENT', None)
if user_agent:
visitor.user_agent = smart_text(
visitor.user_agent = smart_str(
user_agent, encoding='latin-1', errors='ignore')

time_on_site = 0
Expand Down
2 changes: 1 addition & 1 deletion bims/models/basemap_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""

from django.db import models
from django.contrib.postgres.fields import JSONField
from django.db.models import JSONField
from django.db.models.signals import post_save
from django.dispatch import receiver
from ordered_model.models import OrderedModel
Expand Down
2 changes: 1 addition & 1 deletion bims/models/biological_collection_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.db import models
from django.dispatch import receiver
from django.utils import timezone
from django.contrib.postgres.fields import JSONField
from django.db.models import JSONField

from preferences import preferences
from bims.models.location_site import LocationSite
Expand Down
2 changes: 1 addition & 1 deletion bims/models/chemical_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from django.utils import timezone
from django.contrib.gis.db import models
from django.db.models import Q
from django.contrib.postgres.fields import JSONField
from django.db.models import JSONField
from bims.models import LocationSite, SourceReference, Survey
from bims.models.biological_collection_record import (
BiologicalCollectionQuerySet
Expand Down
2 changes: 1 addition & 1 deletion bims/models/dashboard_configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"""
from datetime import datetime
from django.db import models
from django.contrib.postgres.fields import JSONField
from django.db.models import JSONField
from bims.models.taxon_group import TaxonGroup


Expand Down
2 changes: 1 addition & 1 deletion bims/models/location_site.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from django.core.exceptions import ValidationError
from django.contrib.gis.db import models
from django.dispatch import receiver
from django.contrib.postgres.fields import JSONField
from django.db.models import JSONField
from django.conf import settings
from django.utils import timezone

Expand Down
2 changes: 1 addition & 1 deletion bims/models/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

import json
from django.conf import settings
from django.contrib.postgres.fields import JSONField
from django.db.models import JSONField
from django.db import models
from django.core.exceptions import ValidationError

Expand Down
Loading

0 comments on commit b736e08

Please sign in to comment.