Skip to content

Commit 633a7da

Browse files
authored
Merge branch 'issue-6127' into issue-6126
2 parents 45bd49d + bcc4277 commit 633a7da

File tree

53 files changed

+1169
-516
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1169
-516
lines changed

Dockerfile

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ RUN apt-get update \
99
libldap-2.4-2 \
1010
libmariadb3 \
1111
rsync \
12+
tzdata \
1213
&& apt-get clean \
1314
&& rm -rf /var/lib/apt/lists/*
1415

@@ -42,6 +43,8 @@ RUN npx webpack --mode production
4243

4344
FROM common AS build-backend
4445

46+
ENV DEBIAN_FRONTEND=noninteractive
47+
4548
RUN apt-get update \
4649
&& apt-get -y install --no-install-recommends \
4750
build-essential \
@@ -58,6 +61,7 @@ RUN apt-get update \
5861
python3.8-distutils \
5962
python3.8-dev \
6063
libmariadbclient-dev \
64+
tzdata \
6165
&& apt-get clean \
6266
&& rm -rf /var/lib/apt/lists/*
6367

@@ -129,13 +133,15 @@ RUN echo \
129133
"\nREPORT_RUNNER_PORT = os.getenv('REPORT_RUNNER_PORT', '')" \
130134
"\nWEB_ATTACHMENT_URL = os.getenv('ASSET_SERVER_URL', None)" \
131135
"\nWEB_ATTACHMENT_KEY = os.getenv('ASSET_SERVER_KEY', None)" \
132-
"\nWEB_ATTACHMENT_COLLECTION = os.getenv('ASSET_SERVER_COLLECTION', None)" \
136+
"\nWEB_ATTACHMENT_COLLECTION = os.getenv('ASSET_SERVER_COLLECTION', DATABASE_NAME) or DATABASE_NAME" \
133137
"\nSEPARATE_WEB_ATTACHMENT_FOLDERS = os.getenv('SEPARATE_WEB_ATTACHMENT_FOLDERS', None)" \
134138
"\nCELERY_BROKER_URL = os.getenv('CELERY_BROKER_URL', None)" \
135139
"\nCELERY_RESULT_BACKEND = os.getenv('CELERY_RESULT_BACKEND', None)" \
136140
"\nCELERY_TASK_DEFAULT_QUEUE = os.getenv('CELERY_TASK_QUEUE', DATABASE_NAME)" \
137141
"\nANONYMOUS_USER = os.getenv('ANONYMOUS_USER', None)" \
138142
"\nSPECIFY_CONFIG_DIR = os.environ.get('SPECIFY_CONFIG_DIR', '/opt/Specify/config')" \
143+
"\nhost = os.getenv('CSRF_TRUSTED_ORIGINS', None)" \
144+
"\nCSRF_TRUSTED_ORIGINS = [origin.strip() for origin in host.split(',')] if host else []" \
139145
> settings/local_specify_settings.py
140146

141147
RUN echo "import os \nDEBUG = os.getenv('SP7_DEBUG', '').lower() == 'true'\n" \

docker-entrypoint.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/bash
12
set -e
23
if [ -z "$(ls -A /volumes/static-files/specify-config)" ]; then
34
mkdir -p /volumes/static-files/specify-config/config/

requirements.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
setuptools>=50.0.0
2+
tzdata
3+
wheel
4+
backports.zoneinfo==0.2.1
15
kombu==5.2.4
26
celery[redis]==5.2.7
3-
Django==3.2.15
7+
Django==4.2.18
48
mysqlclient==2.1.1
59
SQLAlchemy==1.2.11
610
requests==2.32.2

specifyweb/accounts/views.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from django.shortcuts import render
1717
from django.template.response import TemplateResponse
1818
from django.utils import crypto
19-
from django.utils.http import is_safe_url, urlencode
19+
from django.utils.http import url_has_allowed_host_and_scheme, urlencode
2020
from django.views.decorators.cache import never_cache
2121
from typing import Union, Optional, Dict, cast
2222
from typing_extensions import TypedDict
@@ -362,7 +362,7 @@ def choose_collection(request) -> http.HttpResponse:
362362

363363
redirect_to = (request.POST if request.method == "POST" else request.GET).get('next', '')
364364
redirect_resp = http.HttpResponseRedirect(
365-
redirect_to if is_safe_url(url=redirect_to, allowed_hosts=request.get_host())
365+
redirect_to if url_has_allowed_host_and_scheme(url=redirect_to, allowed_hosts=request.get_host())
366366
else settings.LOGIN_REDIRECT_URL
367367
)
368368

specifyweb/attachment_gw/urls.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
1-
from django.conf.urls import url
1+
from django.urls import path
22

33
from . import views
44

55
urlpatterns = [
6-
url(r'^get_settings/$', views.get_settings),
7-
url(r'^get_upload_params/$', views.get_upload_params),
8-
url(r'^get_token/$', views.get_token),
9-
url(r'^proxy/$', views.proxy),
10-
url(r'^download_all/$', views.download_all),
11-
url(r'^dataset/$', views.datasets),
12-
url(r'^dataset/(?P<ds_id>\d+)/$', views.dataset),
13-
6+
path('get_settings/', views.get_settings),
7+
path('get_upload_params/', views.get_upload_params),
8+
path('get_token/', views.get_token),
9+
path('proxy/', views.proxy),
10+
path('download_all/', views.download_all),
11+
path('dataset/', views.datasets),
12+
path('dataset/<int:ds_id>/', views.dataset),
1413
]

specifyweb/attachment_gw/views.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,11 @@ def get_collection(request=None):
7272
# do any better than using the first collection
7373
# and hoping that all the assets are in the same
7474
# folder.
75-
from specifyweb.specify.models import Collection
76-
return Collection.objects.all()[0].collectionname
75+
# from specifyweb.specify.models import Collection
76+
# return Collection.objects.all()[0].collectionname
77+
78+
# The default coll parameter to assets is the database name
79+
return settings.DATABASE_NAME
7780

7881
@openapi(schema={
7982
"get": {

specifyweb/barvis/urls.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
from django.conf.urls import url
1+
from django.urls import path
22

33
from . import views
44

55
urlpatterns = [
6-
url(r'^taxon_bar/$', views.taxon_bar),
6+
path('taxon_bar/', views.taxon_bar),
77
]
Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +0,0 @@
1-
default_app_config = 'specifyweb.businessrules.apps.BussinessRuleConfig'

specifyweb/businessrules/urls.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from django.conf.urls import include, url
1+
from django.urls import path
22

33
from . import views
44

55
urlpatterns = [
6-
url(r'^uniqueness_rules/(?P<discipline_id>\d+)/$', views.uniqueness_rule),
7-
url(r'^uniqueness_rules/validate/$', views.validate_uniqueness),
6+
path('uniqueness_rules/<int:discipline_id>/', views.uniqueness_rule),
7+
path('uniqueness_rules/validate/', views.validate_uniqueness),
88
]

specifyweb/context/remote_prefs.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django.utils.encoding import force_text
1+
from django.utils.encoding import force_str
22

33
from specifyweb.specify.models import Spappresourcedata
44

@@ -11,10 +11,10 @@ def get_remote_prefs() -> str:
1111
# Spappresource.data is stored in a blob field even though we treat
1212
# it as a TextField. Starting in django 2.2 it doesn't automatically
1313
# get decoded from bytes to str.
14-
return '\n'.join(force_text(r.data) for r in res)
14+
return '\n'.join(force_str(r.data) for r in res)
1515

1616
def get_global_prefs() -> str:
1717
res = Spappresourcedata.objects.filter(
1818
spappresource__name='preferences',
1919
spappresource__spappresourcedir__usertype='Global Prefs')
20-
return '\n'.join(force_text(r.data) for r in res)
20+
return '\n'.join(force_str(r.data) for r in res)

0 commit comments

Comments
 (0)