diff --git a/bims/admin.py b/bims/admin.py index 937aca238..6b77c2ac9 100644 --- a/bims/admin.py +++ b/bims/admin.py @@ -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 diff --git a/bims/api_urls.py b/bims/api_urls.py index 4b508faf8..224195b5b 100644 --- a/bims/api_urls.py +++ b/bims/api_urls.py @@ -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, @@ -104,209 +103,209 @@ ) urlpatterns = [ - url(r'^location-type/(?P[0-9]+)/allowed-geometry/$', + re_path(r'^location-type/(?P[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[0-9]+)/$', + re_path(r'^taxon/(?P[0-9]+)/$', TaxonDetail.as_view()), - url(r'^cluster/(?P\w+)/$', + re_path(r'^cluster/(?P\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[\w-]+)/$', + re_path(r'^get-farm/(?P[\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[0-9]+)/$', + re_path(r'^upload-status/(?P[0-9]+)/$', DataUploadStatusView.as_view(), name='upload-status'), - url(r'^harvest-status/(?P[0-9]+)/$', + re_path(r'^harvest-status/(?P[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[0-9]+)/$', TaxonImageList.as_view(), + re_path(r'^taxon-images/(?P[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[\w-]+)/$', + re_path(r'^celery-status/(?P[\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///', diff --git a/bims/middleware.py b/bims/middleware.py index 8c12590de..bc4fa9deb 100644 --- a/bims/middleware.py +++ b/bims/middleware.py @@ -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: @@ -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'): @@ -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 @@ -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 diff --git a/bims/models/basemap_layer.py b/bims/models/basemap_layer.py index 5254faa18..3236e3d57 100644 --- a/bims/models/basemap_layer.py +++ b/bims/models/basemap_layer.py @@ -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 diff --git a/bims/models/biological_collection_record.py b/bims/models/biological_collection_record.py index be2686a63..d9e38cb32 100644 --- a/bims/models/biological_collection_record.py +++ b/bims/models/biological_collection_record.py @@ -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 diff --git a/bims/models/chemical_record.py b/bims/models/chemical_record.py index 77298a5e2..0c2322595 100644 --- a/bims/models/chemical_record.py +++ b/bims/models/chemical_record.py @@ -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 diff --git a/bims/models/dashboard_configuration.py b/bims/models/dashboard_configuration.py index ed477eb55..ccb31d35b 100644 --- a/bims/models/dashboard_configuration.py +++ b/bims/models/dashboard_configuration.py @@ -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 diff --git a/bims/models/location_site.py b/bims/models/location_site.py index c5353c4af..6d93501b5 100644 --- a/bims/models/location_site.py +++ b/bims/models/location_site.py @@ -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 diff --git a/bims/models/profile.py b/bims/models/profile.py index 9013d8240..f18b6e08f 100644 --- a/bims/models/profile.py +++ b/bims/models/profile.py @@ -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 diff --git a/bims/models/search_process.py b/bims/models/search_process.py index 86b375715..7a05649a9 100644 --- a/bims/models/search_process.py +++ b/bims/models/search_process.py @@ -141,11 +141,12 @@ def save_to_file(self, results): def get_file_if_exits(self, finished=True): if os.path.exists(self.file_path) and self.finished == finished: - raw_data = open(self.file_path) - try: - return json.load(raw_data) - except ValueError: - return json.load(raw_data.read()) + with open(self.file_path, 'r') as raw_data: + file_content = raw_data.read() + try: + return json.loads(file_content) + except ValueError: + return None else: self.finished = False self.save() diff --git a/bims/models/site_setting.py b/bims/models/site_setting.py index dc4ef8a8e..174d686f2 100644 --- a/bims/models/site_setting.py +++ b/bims/models/site_setting.py @@ -1,6 +1,6 @@ import json from django.db import models -from django.contrib.postgres.fields import JSONField +from django.db.models import JSONField from preferences.models import Preferences diff --git a/bims/models/taxonomy.py b/bims/models/taxonomy.py index 488f7cdce..b1e856c78 100644 --- a/bims/models/taxonomy.py +++ b/bims/models/taxonomy.py @@ -18,7 +18,7 @@ from bims.utils.iucn import get_iucn_status from bims.permissions.generate_permission import generate_permission from bims.models.vernacular_name import VernacularName -from django.contrib.postgres.fields import JSONField +from django.db.models import JSONField ORIGIN_CATEGORIES = { 'non-native': 'alien', diff --git a/bims/signals/app.py b/bims/signals/app.py index 9ec87fe1b..3f143464a 100644 --- a/bims/signals/app.py +++ b/bims/signals/app.py @@ -1,5 +1,5 @@ from django.apps import AppConfig -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ class SignalsConfig(AppConfig): diff --git a/bims/urls.py b/bims/urls.py index cc215d98f..400ded0dd 100644 --- a/bims/urls.py +++ b/bims/urls.py @@ -1,8 +1,7 @@ # coding=utf-8 from django.contrib.auth.decorators import login_required -from django.conf.urls import url, include -from django.urls import reverse_lazy, path +from django.urls import reverse_lazy, path, include, re_path from django.views.generic import RedirectView from django.views.generic import TemplateView @@ -93,169 +92,169 @@ PhysicoChemicalSiteView urlpatterns = [ - url(r'^$', landing_page_view, name='landing-page'), - url(r'^map/$', MapPageView.as_view(), name='map-page'), - url(r'^upload/$', CsvUploadView.as_view(), + re_path(r'^$', landing_page_view, name='landing-page'), + re_path(r'^map/$', MapPageView.as_view(), name='map-page'), + re_path(r'^upload/$', CsvUploadView.as_view(), name='csv-upload'), - url(r'^upload-taxa/$', TaxaUploadView.as_view(), + re_path(r'^upload-taxa/$', TaxaUploadView.as_view(), name='csv-upload-taxa'), - url(r'^upload_shp/$', ShapefileUploadView.as_view(), + re_path(r'^upload_shp/$', ShapefileUploadView.as_view(), name='shapefile-upload'), - url(r'^process_shapefiles/$', process_shapefiles, + re_path(r'^process_shapefiles/$', process_shapefiles, name='process_shapefiles'), - url(r'^process_user_boundary_shapefiles/$', + re_path(r'^process_user_boundary_shapefiles/$', process_user_boundary_shapefiles, name='process_user_boundary_shapefiles'), - url(r'^links/$', LinksCategoryView.as_view(), name='link_list'), - url(r'^activate-user/(?P[\w-]+)/$', + re_path(r'^links/$', LinksCategoryView.as_view(), name='link_list'), + re_path(r'^activate-user/(?P[\w-]+)/$', activate_user, name='activate-user'), - url(r'^under-development/$', + re_path(r'^under-development/$', UnderDevelopmentView.as_view(), name='under-development'), - url(r'^tracking/$', dashboard, name='tracking-dashboard'), - url(r'^update/(?P\d+)/$', + re_path(r'^tracking/$', dashboard, name='tracking-dashboard'), + re_path(r'^update/(?P\d+)/$', BioRecordsUpdateView.as_view(), name='update-records'), - url(r'^get_feature/$', + re_path(r'^get_feature/$', GetFeatureInfo.as_view(), name='get-feature'), - url(r'^collection/check_process/$', + re_path(r'^collection/check_process/$', CollectionDownloader.as_view()), - url(r'^download-csv-taxa-list/$', + re_path(r'^download-csv-taxa-list/$', download_csv_taxa_list, name='taxa-list-download'), - url(r'^autocomplete/$', autocomplete, name='autocomplete-search'), - url(r'^user-autocomplete/$', + re_path(r'^autocomplete/$', autocomplete, name='autocomplete-search'), + re_path(r'^user-autocomplete/$', user_autocomplete, name='user-autocomplete-search'), - url(r'^species-autocomplete/$', + re_path(r'^species-autocomplete/$', species_autocomplete, name='species-autocomplete-search'), - url(r'^data-source-autocomplete/$', + re_path(r'^data-source-autocomplete/$', data_source_autocomplete, name='data-source-autocomplete-search'), - url(r'^location-site-autocomplete/$', + re_path(r'^location-site-autocomplete/$', site_autocomplete, name='location-site-autocomplete-search'), - url(r'^abiotic-autocomplete/$', + re_path(r'^abiotic-autocomplete/$', abiotic_autocomplete, name='abiotic-autocomplete-search'), - url(r'^bims_proxy/(?P.*)', proxy_request), - url(r'^fish-form/$', FishFormView.as_view(), name='fish-form'), - url(r'^invert-form/$', InvertFormView.as_view(), name='invert-form'), - url(r'^algae-form/$', AlgaeFormView.as_view(), name='algae-form'), - url(r'^module-form/$', ModuleFormView.as_view(), name='module-form'), - url(r'^source-reference-form/$', SourceReferenceView.as_view(), + re_path(r'^bims_proxy/(?P.*)', proxy_request), + re_path(r'^fish-form/$', FishFormView.as_view(), name='fish-form'), + re_path(r'^invert-form/$', InvertFormView.as_view(), name='invert-form'), + re_path(r'^algae-form/$', AlgaeFormView.as_view(), name='algae-form'), + re_path(r'^module-form/$', ModuleFormView.as_view(), name='module-form'), + re_path(r'^source-reference-form/$', SourceReferenceView.as_view(), name='source-reference-form'), - url(r'^source-reference/database/', + re_path(r'^source-reference/database/', DatabaseRecordsList.as_view(), name='source-reference-database'), - url(r'^source-reference/document/upload$', + re_path(r'^source-reference/document/upload$', SourceReferenceBimsDocumentUploadView.as_view(), name='source-reference-document-upload'), - url(r'^location-site-form/add/$', + re_path(r'^location-site-form/add/$', LocationSiteFormView.as_view(), name='location-site-form'), - url(r'^location-site-form/update/$', + re_path(r'^location-site-form/update/$', LocationSiteFormUpdateView.as_view(), name='location-site-update-form'), - url(r'^location-site-form/delete/(?P\d+)/$', + re_path(r'^location-site-form/delete/(?P\d+)/$', LocationSiteFormDeleteView.as_view(), name='location-site-delete-form'), - url(r'^bug-report/$', BugReportView.as_view(), + re_path(r'^bug-report/$', BugReportView.as_view(), name='bug-report'), - url(r'^abiotic/$', AbioticFormView.as_view(), + re_path(r'^abiotic/$', AbioticFormView.as_view(), name='abiotic-form'), - url(r'^svg_to_pdf/$', svg_to_pdf, name='svg-to-pdf'), - url(r'^collection/delete/(?P\d+)/$', + re_path(r'^svg_to_pdf/$', svg_to_pdf, name='svg-to-pdf'), + re_path(r'^collection/delete/(?P\d+)/$', CollectionDeleteApiView.as_view(), name='collection-delete'), - url(r'^bims-document/(?P\d+)/$', + re_path(r'^bims-document/(?P\d+)/$', BimsDocumentUpdateView.as_view(), name='bims-document-update-view'), - url(r'^site-visit/update/(?P\d+)/$', + re_path(r'^site-visit/update/(?P\d+)/$', login_required(SiteVisitUpdateView.as_view()), name='site-visit-update'), - url(r'^site-visit/list/$', + re_path(r'^site-visit/list/$', SiteVisitListView.as_view(), name='site-visit-list'), - url(r'^site-visit/detail/(?P\d+)/$', + re_path(r'^site-visit/detail/(?P\d+)/$', SiteVisitDetailView.as_view(), name='site-visit-detail'), - url(r'^site-visit/delete/(?P\d+)/$', + re_path(r'^site-visit/delete/(?P\d+)/$', SiteVisitDeleteView.as_view()), - url(r'^taxa-management/$', + re_path(r'^taxa-management/$', TaxaManagementView.as_view()), - url(r'^backups-management/$', + re_path(r'^backups-management/$', BackupsManagementView.as_view()), - url(r'^dashboard-management/$', + re_path(r'^dashboard-management/$', DashboardManagementView.as_view()), - url(r'^upload-collections/$', CollectionsUploadView.as_view(), + re_path(r'^upload-collections/$', CollectionsUploadView.as_view(), name='upload-collections'), - url(r'^upload-physico-chemical/$', PhysicoChemicalUploadView.as_view(), + re_path(r'^upload-physico-chemical/$', PhysicoChemicalUploadView.as_view(), name='upload-physico-chemical'), - url(r'^harvest-collections/$', HarvestCollectionView.as_view(), + re_path(r'^harvest-collections/$', HarvestCollectionView.as_view(), name='harvest-collections'), - url(r'^source-references/$', SourceReferenceListView.as_view(), + re_path(r'^source-references/$', SourceReferenceListView.as_view(), name='source-references'), - url(r'^delete-source-reference/$', DeleteSourceReferenceView.as_view(), + re_path(r'^delete-source-reference/$', DeleteSourceReferenceView.as_view(), name='delete-source-reference'), - url(r'^edit-source-reference/(?P\d+)/$', + re_path(r'^edit-source-reference/(?P\d+)/$', EditSourceReferenceView.as_view(), name='edit-source-reference'), - url(r'^add-source-reference/$', + re_path(r'^add-source-reference/$', AddSourceReferenceView.as_view(), name='add-source-reference'), - url(r'^summary-report/$', SummaryReportView.as_view(), + re_path(r'^summary-report/$', SummaryReportView.as_view(), name='summary-report'), - url(r'^profile/(?P\w+)/$', ProfileView.as_view(), + re_path(r'^profile/(?P\w+)/$', ProfileView.as_view(), name='profile'), - url(r'^download-request/$', DownloadRequestListView.as_view(), + re_path(r'^download-request/$', DownloadRequestListView.as_view(), name='download-request'), - url(r'^profile/$', + re_path(r'^profile/$', login_required(lambda request: RedirectView.as_view( url=reverse_lazy('profile', kwargs={ 'slug': request.user.username }), permanent=False)(request)), name='user-profile'), - url(r'^contact/$', CustomContactUsView.as_view(), + re_path(r'^contact/$', CustomContactUsView.as_view(), name='contact'), - url(r'^contact/success/$', TemplateView.as_view( + re_path(r'^contact/success/$', TemplateView.as_view( template_name='contactus/contact_success.html'), {}, 'contactus-success'), - url(r'^nonvalidated-site/$', + re_path(r'^nonvalidated-site/$', NonValidatedSiteView.as_view(), name='nonvalidated-site'), - url(r'^nonvalidated-site/detail/(?P\d+)/$', + re_path(r'^nonvalidated-site/detail/(?P\d+)/$', SiteLocationDetailView.as_view(), name='nonvalidated-site'), - url(r'^source-reference/unpublished/', + re_path(r'^source-reference/unpublished/', UnpublishedData.as_view(), name='source-reference-unpublished'), - url(r'^download-taxa-template/', + re_path(r'^download-taxa-template/', download_taxa_template, name='download-taxa-template'), - url(r'^water-temperature-form/$', + re_path(r'^water-temperature-form/$', WaterTemperatureView.as_view(), name='water-temperature-form'), - url(r'^physico-chemical-form/$', + re_path(r'^physico-chemical-form/$', PhysicoChemicalView.as_view(), name='physico-chemical-form'), - url(r'^water-temperature-form/edit/$', + re_path(r'^water-temperature-form/edit/$', WaterTemperatureEditView.as_view(), name='water-temperature-edit-form'), - url(r'^upload-water-temperature/$', + re_path(r'^upload-water-temperature/$', WaterTemperatureUploadView.as_view(), name='upload-water-temperature'), - url(r'^validate-water-temperature/$', + re_path(r'^validate-water-temperature/$', WaterTemperatureValidateView.as_view(), name='validate-water-temperature'), - url(r'^water-temperature/(?P\d+)/$', + re_path(r'^water-temperature/(?P\d+)/$', WaterTemperatureSiteView.as_view(), name='water-temperature-site'), - url(r'^water-temperature/(?P\d+)/(?P\d{4})/$', + re_path(r'^water-temperature/(?P\d+)/(?P\d{4})/$', WaterTemperatureSiteView.as_view(), name='water-temperature-site'), - url(r'^physico-chemical/(?P\d+)/$', + re_path(r'^physico-chemical/(?P\d+)/$', PhysicoChemicalSiteView.as_view(), name='physico-chemical-site'), # Account - url( + re_path( r'^account/moderation_sent/(?P[^/]*)$', moderator_contacted, name='moderator_contacted'), @@ -264,15 +263,15 @@ # Api urls urlpatterns += [ # '', - url(r'^api/', + re_path(r'^api/', include('bims.api_urls')), - url(r'^wagtail-api/v2/', api_router.urls), + re_path(r'^wagtail-api/v2/', api_router.urls), ] # Thermals urlpatterns += [ - url(r'^thermal-dashboard/$', + re_path(r'^thermal-dashboard/$', ThermalDashboardView.as_view(), name='thermal-dashboard'), ] diff --git a/bims/views/autocomplete_search.py b/bims/views/autocomplete_search.py index 24c7fe6f8..492bc706f 100644 --- a/bims/views/autocomplete_search.py +++ b/bims/views/autocomplete_search.py @@ -133,7 +133,7 @@ def autocomplete(request): def user_autocomplete(request): q = request.GET.get('term', '').capitalize() - if not request.is_ajax() and len(q) < 2: + if not is_ajax(request) and len(q) < 2: data = 'fail' else: user_model_str = settings.AUTH_USER_MODEL @@ -167,10 +167,12 @@ def user_autocomplete(request): mime_type = 'application/json' return HttpResponse(data, mime_type) +def is_ajax(request): + return request.META.get('HTTP_X_REQUESTED_WITH') == 'XMLHttpRequest' def data_source_autocomplete(request): q = request.GET.get('term', '').capitalize() - if not request.is_ajax() and len(q) < 2: + if not is_ajax(request) and len(q) < 2: data = 'fail' else: search_qs = DataSource.objects.filter( @@ -232,7 +234,7 @@ def species_autocomplete(request): if rank: optional_query['rank__iexact'] = rank - if not request.is_ajax() and len(q) < 2: + if not is_ajax(request) and len(q) < 2: data = 'fail' else: if taxon_group_species: diff --git a/bims/views/documents.py b/bims/views/documents.py index 65f092994..0a2ba2a77 100644 --- a/bims/views/documents.py +++ b/bims/views/documents.py @@ -1,7 +1,7 @@ import json import logging from django.http import HttpResponse, HttpResponseRedirect -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.conf import settings from django.urls import reverse from django.views.generic import UpdateView, CreateView diff --git a/bims/views/water_temperature.py b/bims/views/water_temperature.py index 324fa114e..17d95d990 100644 --- a/bims/views/water_temperature.py +++ b/bims/views/water_temperature.py @@ -33,6 +33,7 @@ SourceReference, SiteImage, WATER_TEMPERATURE_KEY ) +from bims.views.autocomplete_search import is_ajax from bims.views.mixin.session_form import SessionFormMixin @@ -321,7 +322,7 @@ class WaterTemperatureUploadView(LoginRequiredMixin, View): upload_task = None def post(self, request, *args, **kwargs): - if not request.is_ajax(): + if not is_ajax(request): return HttpResponseForbidden() upload_session_id = request.POST.get('upload_session_id', None) diff --git a/core/settings/contrib.py b/core/settings/contrib.py index 3f38a3178..8c7c61634 100644 --- a/core/settings/contrib.py +++ b/core/settings/contrib.py @@ -449,7 +449,7 @@ TASK_TRACK_STARTED = True CACHES = { 'default': { - 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', + 'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache', 'LOCATION': 'cache:11211', } } diff --git a/core/settings/dev_docker.py b/core/settings/dev_docker.py index 93ceb81e8..28fd1ea8e 100644 --- a/core/settings/dev_docker.py +++ b/core/settings/dev_docker.py @@ -43,7 +43,7 @@ CACHES = { 'default': { - 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', + 'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache', 'LOCATION': 'cache:11211', } } diff --git a/core/settings/legacy_geonode_settings.py b/core/settings/legacy_geonode_settings.py index 70566191a..e96a032e5 100644 --- a/core/settings/legacy_geonode_settings.py +++ b/core/settings/legacy_geonode_settings.py @@ -329,7 +329,7 @@ } MEMCACHED_ENABLED = ast.literal_eval(os.getenv('MEMCACHED_ENABLED', 'False')) -MEMCACHED_BACKEND = os.getenv('MEMCACHED_BACKEND', 'django.core.cache.backends.memcached.MemcachedCache') +MEMCACHED_BACKEND = os.getenv('MEMCACHED_BACKEND', 'django.core.cache.backends.memcached.PyMemcacheCache') MEMCACHED_LOCATION = os.getenv('MEMCACHED_LOCATION', '127.0.0.1:11211') MEMCACHED_LOCK_EXPIRE = int(os.getenv('MEMCACHED_LOCK_EXPIRE', 3600)) MEMCACHED_LOCK_TIMEOUT = int(os.getenv('MEMCACHED_LOCK_TIMEOUT', 10)) @@ -377,7 +377,6 @@ 'modeltranslation', 'dal', 'dal_select2', - 'grappelli', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', diff --git a/core/settings/prod_worker.py b/core/settings/prod_worker.py index 5d9b571e2..c1b6b9ce0 100644 --- a/core/settings/prod_worker.py +++ b/core/settings/prod_worker.py @@ -2,7 +2,7 @@ CACHES = { 'default': { - 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', + 'BACKEND': 'django.core.cache.backends.memcached.PyMemcacheCache', 'LOCATION': 'cache:11211', } } diff --git a/core/settings/project.py b/core/settings/project.py index e9f814c07..bac954f81 100644 --- a/core/settings/project.py +++ b/core/settings/project.py @@ -7,7 +7,7 @@ """ import os # noqa -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from .contrib import * # noqa # Project apps diff --git a/core/settings/test_docker.py b/core/settings/test_docker.py index 382188d30..cd0b59deb 100644 --- a/core/settings/test_docker.py +++ b/core/settings/test_docker.py @@ -29,9 +29,9 @@ } CACHES = { - 'default': { - 'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', - 'LOCATION': 'cache:11211', + "default": { + "BACKEND": "django.core.cache.backends.filebased.FileBasedCache", + "LOCATION": "/var/tmp/django_cache", } } DJANGO_EASY_AUDIT_WATCH_MODEL_EVENTS = False diff --git a/core/urls.py b/core/urls.py index f91bf9eff..91fd74635 100644 --- a/core/urls.py +++ b/core/urls.py @@ -5,50 +5,50 @@ Examples: Function views 1. Add an import: from my_app import views - 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') + 2. Add a URL to urlpatterns: re_path(r'^$', views.home, name='home') Class-based views 1. Add an import: from other_app.views import Home - 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') + 2. Add a URL to urlpatterns: re_path(r'^$', Home.as_view(), name='home') Including another URLconf - 1. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) + 1. Add a URL to urlpatterns: re_path(r'^blog/', include('blog.urls')) """ -from django.conf.urls import url, include from django.views.generic import TemplateView from django.conf import settings from django.conf.urls.static import static from django.contrib import admin from django.contrib.auth.decorators import login_required -from django.urls import re_path +from django.urls import include, re_path from wagtail.admin import urls as wagtailadmin_urls from wagtail.core import urls as wagtail_urls from wagtail.documents import urls as wagtaildocs_urls # from geonode.urls import urlpatterns as geonode_urlpatterns from bims.views.documents import BimsDocumentUploadView +from django.urls import re_path # GeoNode has to be in root url conf. # It cannot be included in include() function because it contains i18n urls urlpatterns = [ - url(r'^grappelli/', include('grappelli.urls')), - url(r'^accounts/', include('allauth.urls')), - url(r'^pages/', include('django.contrib.flatpages.urls')), - url(r'^', include('bims.urls')), - url(r'^mobile/', include('mobile.urls')), - url(r'^', include('bims_theme.urls')), - url(r'^', include('pesticide.urls')), - url(r'^sass/', include('sass.urls')), - url(r'^bibliography/', + re_path(r'^grappelli/', include('grappelli.urls')), + re_path(r'^accounts/', include('allauth.urls')), + re_path(r'^pages/', include('django.contrib.flatpages.urls')), + re_path(r'^', include('bims.urls')), + re_path(r'^mobile/', include('mobile.urls')), + re_path(r'^', include('bims_theme.urls')), + re_path(r'^', include('pesticide.urls')), + re_path(r'^sass/', include('sass.urls')), + re_path(r'^bibliography/', include(('td_biblio.urls', 'bibliography'), namespace = 'td_biblio')), - url(r'^', include('example.urls')), + re_path(r'^', include('example.urls')), # prometheus monitoring - # url(r'', include('django_prometheus.urls')), - url(r'^documents/upload/?$', login_required( + # re_path(r'', include('django_prometheus.urls')), + re_path(r'^documents/upload/?$', login_required( BimsDocumentUploadView.as_view()), name='document_upload'), - url(r'^api-auth/', include('rest_framework.urls')), - url(r'^geonode/?$', + re_path(r'^api-auth/', include('rest_framework.urls')), + re_path(r'^geonode/?$', TemplateView.as_view(template_name='site_index.html'), name='home'), re_path(r'^wagtail-documents/', include(wagtaildocs_urls)), @@ -65,7 +65,7 @@ # urlpatterns += geonode_urlpatterns urlpatterns += [ - url('^admin/', admin.site.urls), + re_path('^admin/', admin.site.urls), re_path(r'^', include(wagtail_urls)), ] diff --git a/deployment/docker-compose.dev.yml b/deployment/docker-compose.dev.yml index 5b6779057..31e3119b4 100644 --- a/deployment/docker-compose.dev.yml +++ b/deployment/docker-compose.dev.yml @@ -103,6 +103,7 @@ services: <<: *default-common-django container_name: bims_dev_worker hostname: worker + image: bims_dev links: - db:db - cache:cache diff --git a/deployment/docker/REQUIREMENTS.txt b/deployment/docker/REQUIREMENTS.txt index 9ef1e3665..a60eef15d 100644 --- a/deployment/docker/REQUIREMENTS.txt +++ b/deployment/docker/REQUIREMENTS.txt @@ -1,4 +1,4 @@ -Django==3.2.20 +Django==4.1.10 psycopg2-binary==2.8.5 django-braces==1.14.0 django-model-utils==4.0.0 @@ -10,17 +10,17 @@ requests>=2.23.0 pytz # support special characters -django-allauth==0.41.0 +django-allauth==0.54.0 # Django Easy Audit # https://github.com/soynatan/django-easy-audit -django-easy-audit==1.2.2 -django-grappelli==2.14.1 +django-easy-audit==1.3.5 +django-grappelli==2.15.4 djangorestframework>=3.11.2 -djangorestframework-gis==0.15 -django-colorfield==0.1.15 - +djangorestframework-gis==1.0 +django-colorfield==0.9.0 +pymemcache==4.0.0 # bibliography bibtexparser==1.1.0 eutils==0.6.0 @@ -51,11 +51,11 @@ selenium==3.141.0 django-admin-rangefilter==0.6.0 django-preferences==1.0.0 PyGithub==1.51 -sorl-thumbnail==12.6.3 +sorl-thumbnail==12.9.0 svglib==1.0.0 simplejson==3.17.0 -django-extensions==2.2.9 -wagtail==4.1.4 +django-extensions==3.2.3 +wagtail==4.2.4 service-identity==18.1.0 geopy==2.0.0 python-dwca-reader==0.15.0 @@ -65,17 +65,17 @@ django-webpack-loader==1.3.0 requests-cache==0.6.0 dj-database-url==0.5.0 -django-polymorphic==3.0.0 +django-polymorphic==3.1.0 django-modeltranslation==0.16.2 -django-autocomplete-light==3.5.1 +django-autocomplete-light==3.9.7 dj-pagination==2.5.0 -django-mptt==0.11.0 +django-mptt==0.14.0 django-guardian==2.3.0 djangorestframework-guardian==0.3.0 django-cors-headers==3.5.0 -django-invitations==1.9.3 +django-invitations==2.0.0 django-uuid-upload-path==1.0.0 -django-pipeline==2.0.5 +django-pipeline==2.1.0 python-memcached==1.59 geonode-oauth-toolkit==2.1.0 mock==4.0.3 diff --git a/deployment/production/REQUIREMENTS.txt b/deployment/production/REQUIREMENTS.txt index 9ef1e3665..a60eef15d 100644 --- a/deployment/production/REQUIREMENTS.txt +++ b/deployment/production/REQUIREMENTS.txt @@ -1,4 +1,4 @@ -Django==3.2.20 +Django==4.1.10 psycopg2-binary==2.8.5 django-braces==1.14.0 django-model-utils==4.0.0 @@ -10,17 +10,17 @@ requests>=2.23.0 pytz # support special characters -django-allauth==0.41.0 +django-allauth==0.54.0 # Django Easy Audit # https://github.com/soynatan/django-easy-audit -django-easy-audit==1.2.2 -django-grappelli==2.14.1 +django-easy-audit==1.3.5 +django-grappelli==2.15.4 djangorestframework>=3.11.2 -djangorestframework-gis==0.15 -django-colorfield==0.1.15 - +djangorestframework-gis==1.0 +django-colorfield==0.9.0 +pymemcache==4.0.0 # bibliography bibtexparser==1.1.0 eutils==0.6.0 @@ -51,11 +51,11 @@ selenium==3.141.0 django-admin-rangefilter==0.6.0 django-preferences==1.0.0 PyGithub==1.51 -sorl-thumbnail==12.6.3 +sorl-thumbnail==12.9.0 svglib==1.0.0 simplejson==3.17.0 -django-extensions==2.2.9 -wagtail==4.1.4 +django-extensions==3.2.3 +wagtail==4.2.4 service-identity==18.1.0 geopy==2.0.0 python-dwca-reader==0.15.0 @@ -65,17 +65,17 @@ django-webpack-loader==1.3.0 requests-cache==0.6.0 dj-database-url==0.5.0 -django-polymorphic==3.0.0 +django-polymorphic==3.1.0 django-modeltranslation==0.16.2 -django-autocomplete-light==3.5.1 +django-autocomplete-light==3.9.7 dj-pagination==2.5.0 -django-mptt==0.11.0 +django-mptt==0.14.0 django-guardian==2.3.0 djangorestframework-guardian==0.3.0 django-cors-headers==3.5.0 -django-invitations==1.9.3 +django-invitations==2.0.0 django-uuid-upload-path==1.0.0 -django-pipeline==2.0.5 +django-pipeline==2.1.0 python-memcached==1.59 geonode-oauth-toolkit==2.1.0 mock==4.0.3 diff --git a/example/urls.py b/example/urls.py index 0934e7248..c0289ee95 100644 --- a/example/urls.py +++ b/example/urls.py @@ -2,9 +2,9 @@ __author__ = 'Anita Hapsari ' __date__ = '06/06/18' -from django.conf.urls import url +from django.urls import re_path from example.views.test_captcha import CaptchaTestView urlpatterns = [ - url(r'^example/captcha/', CaptchaTestView.as_view()) + re_path(r'^example/captcha/', CaptchaTestView.as_view()) ] diff --git a/geonode/base/enumerations.py b/geonode/base/enumerations.py index e0001052d..847124c4c 100644 --- a/geonode/base/enumerations.py +++ b/geonode/base/enumerations.py @@ -18,7 +18,7 @@ # ######################################################################### -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ LINK_TYPES = ['original', 'data', 'image', 'metadata', 'html', 'OGC:WMS', 'OGC:WFS', 'OGC:WCS'] diff --git a/geonode/base/models.py b/geonode/base/models.py index f255d3468..a1c7b0a0c 100644 --- a/geonode/base/models.py +++ b/geonode/base/models.py @@ -29,7 +29,7 @@ from django.core.exceptions import ValidationError from django.utils.html import escape from django.contrib.auth import get_user_model -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from polymorphic.models import PolymorphicModel diff --git a/geonode/documents/forms.py b/geonode/documents/forms.py index b09de96df..baba2533a 100644 --- a/geonode/documents/forms.py +++ b/geonode/documents/forms.py @@ -3,7 +3,7 @@ import json from django import forms -from django.utils.translation import ugettext as _ +from django.utils.translation import gettext as _ from django.conf import settings from django.forms import HiddenInput from modeltranslation.forms import TranslationModelForm diff --git a/geonode/documents/models.py b/geonode/documents/models.py index dea6bbb56..86dad283f 100644 --- a/geonode/documents/models.py +++ b/geonode/documents/models.py @@ -28,7 +28,7 @@ from django.urls import reverse from django.db.models import signals from django.contrib.staticfiles import finders -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.fields import GenericForeignKey diff --git a/geonode/groups/models.py b/geonode/groups/models.py index daff861d6..aa38bcde5 100644 --- a/geonode/groups/models.py +++ b/geonode/groups/models.py @@ -25,7 +25,7 @@ from django.contrib.auth import get_user_model from django.db import models from django.db.models import Q -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.utils.text import slugify from django.db.models import signals from django.utils.timezone import now diff --git a/geonode/people/admin.py b/geonode/people/admin.py index 985971c82..f066258cb 100644 --- a/geonode/people/admin.py +++ b/geonode/people/admin.py @@ -19,12 +19,12 @@ ######################################################################### from django.conf import settings -from django.conf.urls import url from django.contrib import admin +from django.urls import re_path from django.contrib import messages from django.contrib.auth import get_user_model from django.contrib.auth.forms import AdminPasswordChangeForm -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.utils.decorators import method_decorator from django.views.decorators.csrf import csrf_protect from django.db import transaction @@ -100,7 +100,7 @@ def get_form(self, request, obj=None, **kwargs): def get_urls(self): return [ # '', - url(r'^(\d+)/password/$', + re_path(r'^(\d+)/password/$', self.admin_site.admin_view(self.user_change_password)) ] + super(ProfileAdmin, self).get_urls() diff --git a/geonode/people/enumerations.py b/geonode/people/enumerations.py index 397687196..b9f2b402d 100644 --- a/geonode/people/enumerations.py +++ b/geonode/people/enumerations.py @@ -18,7 +18,7 @@ # ######################################################################### -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ CONTACT_FIELDS = [ "name", diff --git a/geonode/people/models.py b/geonode/people/models.py index 57132a563..f0e402e7c 100644 --- a/geonode/people/models.py +++ b/geonode/people/models.py @@ -29,7 +29,7 @@ from django.urls import reverse from django.contrib.sites.models import Site -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.contrib.auth.models import AbstractUser, UserManager from taggit.managers import TaggableManager diff --git a/sass/models/abstract_additional_data.py b/sass/models/abstract_additional_data.py index ce7fb82b8..372d9abe3 100644 --- a/sass/models/abstract_additional_data.py +++ b/sass/models/abstract_additional_data.py @@ -1,6 +1,6 @@ import json from django.contrib.gis.db import models -from django.contrib.postgres.fields import JSONField +from django.db.models import JSONField from django.core.serializers.json import DjangoJSONEncoder diff --git a/sass/urls.py b/sass/urls.py index e11d80f24..6a709476c 100644 --- a/sass/urls.py +++ b/sass/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import url +from django.urls import re_path from sass.views.sass_form import SassFormView, SassReadFormView, SassDeleteView from sass.views.sass_list import SassListView @@ -14,33 +14,33 @@ ) urlpatterns = [ - url(r'^(?P\d+)/$', SassFormView.as_view(), name='sass-form-page'), - url(r'^update/(?P\d+)/$', + re_path(r'^(?P\d+)/$', SassFormView.as_view(), name='sass-form-page'), + re_path(r'^update/(?P\d+)/$', SassFormView.as_view(), name='sass-update-page'), - url(r'^delete/(?P\d+)/$', + re_path(r'^delete/(?P\d+)/$', SassDeleteView.as_view(), name='sass-delete'), - url(r'^view/(?P\d+)/$', + re_path(r'^view/(?P\d+)/$', SassReadFormView.as_view(), name='sass-view-page'), - url(r'^list/$', SassListView.as_view(), name='sass-list-page'), - url(r'^dashboard/(?P\d+)/$', + re_path(r'^list/$', SassListView.as_view(), name='sass-list-page'), + re_path(r'^dashboard/(?P\d+)/$', SassDashboardView.as_view(), name='sass-dashboard-single-site'), - url(r'^dashboard-multi-sites/$', + re_path(r'^dashboard-multi-sites/$', SassDashboardMultipleSitesView.as_view(), name='sass-dashboard-multiple-sites'), - url(r'^dashboard-multi-sites-api/$', + re_path(r'^dashboard-multi-sites-api/$', SassDashboardMultipleSitesApiView.as_view(), name='sass-dashboard-multiple-sites-api'), - url(r'^download-sass-data-site/$', + re_path(r'^download-sass-data-site/$', download_sass_data_site, name='download-sass-data-site'), - url(r'^download-sass-summary-data/$', + re_path(r'^download-sass-summary-data/$', download_sass_summary_data, name='download-sass-summary-data'), - url(r'^download-sass-taxon-data/$', + re_path(r'^download-sass-taxon-data/$', download_sass_taxon_data, name='download-sass-taxon-data'), ] diff --git a/td_biblio/forms/bibliography.py b/td_biblio/forms/bibliography.py index 3a14e4052..da3c65114 100644 --- a/td_biblio/forms/bibliography.py +++ b/td_biblio/forms/bibliography.py @@ -3,7 +3,7 @@ from operator import methodcaller from django import forms -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from td_biblio.utils.format_validator import BibliographyFormatValidator diff --git a/td_biblio/models/bibliography.py b/td_biblio/models/bibliography.py index f4a20f4a4..bd1d615cc 100644 --- a/td_biblio/models/bibliography.py +++ b/td_biblio/models/bibliography.py @@ -6,7 +6,7 @@ from django.utils.text import slugify from django.contrib.auth import get_user_model from django.db import models -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ class AbstractHuman(models.Model): diff --git a/td_biblio/urls.py b/td_biblio/urls.py index 0cc5f0e63..bec1f1ecf 100644 --- a/td_biblio/urls.py +++ b/td_biblio/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import url, include +from django.urls import include, re_path from td_biblio.views.bibliography import ( EntryListView, EntryBatchImportView, @@ -6,13 +6,13 @@ from td_biblio.api_views.bibliography import GetBibliographyByDOI api_urls = [ - url( + re_path( '^fetch/by-doi/$', GetBibliographyByDOI.as_view(), name='fetch-by-doi'), ] urlpatterns = [ - url('^$', EntryListView.as_view(), name='entry_list'), - url('^import/$', EntryBatchImportView.as_view(), name='import'), - url('^api/', include(api_urls)), + re_path('^$', EntryListView.as_view(), name='entry_list'), + re_path('^import/$', EntryBatchImportView.as_view(), name='import'), + re_path('^api/', include(api_urls)), ] diff --git a/td_biblio/utils/format_validator.py b/td_biblio/utils/format_validator.py index 86c6e7c62..95047b969 100644 --- a/td_biblio/utils/format_validator.py +++ b/td_biblio/utils/format_validator.py @@ -1,6 +1,6 @@ from django.core.exceptions import ValidationError from django.core.validators import RegexValidator -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ PMID_REGEX = '^-?\d+\Z' pmid_validator = RegexValidator( diff --git a/td_biblio/utils/loaders.py b/td_biblio/utils/loaders.py index ab7655886..c24ed2fec 100644 --- a/td_biblio/utils/loaders.py +++ b/td_biblio/utils/loaders.py @@ -17,7 +17,7 @@ from bibtexparser import customization as bp_customization from bibtexparser.bparser import BibTexParser from bibtexparser.latexenc import string_to_latex -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from habanero import cn from td_biblio.exceptions import DOILoaderError, PMIDLoaderError diff --git a/td_biblio/views/bibliography.py b/td_biblio/views/bibliography.py index 14aa0635b..6112543f9 100644 --- a/td_biblio/views/bibliography.py +++ b/td_biblio/views/bibliography.py @@ -9,7 +9,7 @@ from django.contrib import messages from django.contrib.auth.decorators import login_required, user_passes_test from django.urls import reverse_lazy -from django.utils.translation import ugettext_lazy as _ +from django.utils.translation import gettext_lazy as _ from django.views.generic import FormView, ListView from django.db.models import Q