diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 6322087ed..c3873dd69 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -37,8 +37,8 @@ jobs: while ! echo exit | nc localhost 5000; do sleep 10; done - name: flake8 lint run: docker compose -f docker-compose.dev.yml exec -T web make flake8 - - name: pylint - run: docker compose -f docker-compose.dev.yml exec -T web make pylint + # - name: pylint + # run: docker compose -f docker-compose.dev.yml exec -T web make pylint - name: pydocstyle lint run: docker compose -f docker-compose.dev.yml exec -T web make pydocstyle - name: pytest @@ -192,7 +192,7 @@ jobs: --log-driver 'json-file' \ --log-opt max-size=100m \ --log-opt max-file=3 \ - -e DJANGO_SETTINGS_MODULE='iati.settings.dev' \ + -e DJANGO_SETTINGS_MODULE='iati.settings.dev_public' \ -e SECRET_KEY='${{ secrets.DEV_SECRET_KEY }}' \ -e DATABASE_NAME='${{ secrets.DEV_DATABASE_NAME }}' \ -e DATABASE_USER='${{ secrets.DEV_DATABASE_USER }}' \ diff --git a/Dockerfile b/Dockerfile index 450b4a952..2bab6f60b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM alpine:3.13.2 +FROM alpine:3.20.2 ENV LANG en_US.UTF-8 ENV PYTHONUNBUFFERED 1 @@ -32,10 +32,9 @@ RUN apk add --no-cache python3 py3-pip && \ if [[ ! -e /usr/bin/python ]]; then ln -sf /usr/bin/python3 /usr/bin/python; fi -RUN apk add build-base libffi-dev libressl-dev && \ +RUN apk add build-base libffi-dev && \ ln -sf /usr/bin/python3 /usr/bin/python && \ - ln -sf /usr/bin/pip3 usr/bin/pip && \ - pip install --upgrade pip + ln -sf /usr/bin/pip3 usr/bin/pip RUN apk add --no-cache jpeg-dev zlib-dev RUN apk add --no-cache postgresql-dev @@ -105,6 +104,7 @@ RUN apk -U upgrade RUN apk add --no-cache gcc musl-dev python3-dev libffi-dev openssl-dev cargo libwebp libwebp-tools &&\ python3 -m venv /usr/src/venv &&\ . /usr/src/venv/bin/activate &&\ + pip3 install --upgrade pip &&\ pip3 install -r requirements_dev.txt RUN apk add --no-cache gettext diff --git a/common/templatetags/responsive.py b/common/templatetags/responsive.py index d4fb15629..2a2ba634f 100644 --- a/common/templatetags/responsive.py +++ b/common/templatetags/responsive.py @@ -80,9 +80,9 @@ def render(self, context): output_format = original_format if output_format not in ['jpeg', 'png', 'gif', 'webp']: output_format = 'webp' - if output_format != original_format and "format" not in self.filter_spec: - self.filter_spec = "{}|{}".format(self.filter_spec, "format-{}".format(output_format)) - rendition = image.get_rendition(self.filter) + if output_format != original_format and not any("format" in x for x in self.filter_specs): + self.filter_specs = ["{}|{}".format(self.filter_specs, "format-{}".format(output_format))] + rendition = image.get_rendition(self.get_filter()) except SourceImageIOError: # It's fairly routine for people to pull down remote databases to their # local dev versions without retrieving the corresponding image files. diff --git a/iati/settings/dev_public.py b/iati/settings/dev_public.py new file mode 100644 index 000000000..8de06fe80 --- /dev/null +++ b/iati/settings/dev_public.py @@ -0,0 +1,34 @@ +"""Settings for the public dev environment (overrides base settings). + +DEBUG is False etc. because the website is publicly accessible. +""" + +import os +from .base import * # noqa: F401, F403 # pylint: disable=unused-wildcard-import, wildcard-import + +DEBUG = False + +# SECURITY WARNING: keep the secret key used in production secret! +# Overwrite this variable in local.py with another unguessable string. +SECRET_KEY = os.environ.get('SECRET_KEY') + +EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' + +ALLOWED_HOSTS = [ + '0.0.0.0', + 'iatistandard.org', + '.iatistandard.org', +] + +SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') + +SECURE_SSL_REDIRECT = not DEBUG +CSRF_COOKIE_SECURE = not DEBUG +SESSION_COOKIE_SECURE = not DEBUG + +AZURE_ACCOUNT_NAME = os.getenv('AZURE_ACCOUNT_NAME') + +try: + from .local import * # # noqa: F401, F403 # pylint: disable=unused-wildcard-import, wildcard-import +except ImportError: + pass diff --git a/patterns/converted-html/assets/css/basic.css b/patterns/converted-html/assets/css/basic.css index 51f30bdf1..cbd2aea9d 100644 --- a/patterns/converted-html/assets/css/basic.css +++ b/patterns/converted-html/assets/css/basic.css @@ -1,2 +1 @@ *,*:before,*:after{-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,embed,figure,figcaption,footer,header,hgroup,menu,nav,output,ruby,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;font:inherit;font-size:100%;vertical-align:baseline}table{border-collapse:collapse;border-spacing:0}caption,th,td{text-align:left;font-weight:normal;vertical-align:middle}q,blockquote{quotes:none}q:before,q:after,blockquote:before,blockquote:after{content:"";content:none}a img{border:none}article,aside,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary{display:block}button,input{line-height:normal}button,input,select,textarea{font-size:100%;margin:0;vertical-align:baseline;*vertical-align:middle}button,input[type="button"],input[type="reset"],input[type="submit"]{cursor:pointer;*overflow:visible}button::-moz-focus-inner,input::-moz-focus-inner{border:0;padding:0}textarea{overflow:auto;vertical-align:top;resize:vertical}body,select,input,textarea,button{font-family:Helvetica, sans-serif}html{font-size:62.5%}body{font-size:16px;line-height:1.5;background:#fff;color:#444}.ui-canvas{width:980px;margin-left:auto;margin-right:auto}h1{font-size:32px;margin:12px auto}h2{font-size:28px;margin:12px auto}h3,h4{font-size:26px;margin:12px auto}h5,h6{font-size:24px;margin:12px auto}p{font-size:16px;margin:16 auto}ul,ol{margin:12px auto}img{margin:12px auto;max-width:980px}*[role="banner"]{border-bottom:1px solid #ddd;padding-bottom:20px;margin-bottom:19px;display:block}*[role="navigation"]{display:block}*[role="navigation"] li{display:inline-block;margin-right:8px}*[role="contentinfo"]{border-top:1px solid #ddd;padding-top:20px;margin-top:19px;display:block}a{color:#09c;text-decoration:none;word-wrap:break-word;-webkit-tap-highlight-color:#09c}a:hover,a:focus,a:active{color:#f0c}::selection{background:#09c;color:#fff;text-shadow:inherit}.skiplink{background:#fff;color:#09c;border:1px solid #ddd;display:block;font-size:16px;line-height:40px;padding:0 20px;position:absolute;top:-60px;left:0;-webkit-transition:all ease-in-out 0.1s;-moz-transition:all ease-in-out 0.1s;-ms-transition:all ease-in-out 0.1s;-o-transition:all ease-in-out 0.1s;transition:all ease-in-out 0.1s}.skiplink:focus,.skiplink:active{top:0;z-index:80}#pagecontent{outline:none}h1,h2,h3,h4,h5,h6{color:#333}ul,ol{list-style-type:none}li{line-height:inherit}strong,b{font-weight:700}em,i,q{font-style:italic}::-webkit-input-placeholder{color:#333}:-moz-placeholder{color:#333}::-moz-placeholder{color:#333}:-ms-input-placeholder{color:#333}label,legend,select{display:block;color:#333}input[type="search"]::-webkit-search-decoration,input[type="search"]::-webkit-search-cancel-button,input[type="submit"],button{-webkit-appearance:none;-moz-appearance:none;-ms-appearance:none;-o-appearance:none;appearance:none;border-radius:0}button{border:none}select,input,textarea,button{border-radius:0}textarea{overflow:auto;vertical-align:top;font-family:inherit}legend{font-size:2.4rem}label{font-size:1.4rem}fieldset{margin:0;display:block;width:100%;clear:both}input[type="text"],input[type="email"],input[type="tel"],input[type="url"],input[type="password"],textarea{width:100%}input[type="radio"],input[type="checkbox"]{margin:4px 0 0;margin-top:1px \9;*margin-top:0;line-height:normal;cursor:pointer}input[type="file"],input[type="image"],input[type="submit"],input[type="reset"],input[type="button"],input[type="radio"],input[type="checkbox"],input[type="submit"] button{width:auto}select,input[type="file"]{*margin-top:4px}select:focus,input[type="file"]:focus,input[type="radio"]:focus,input[type="checkbox"]:focus{outline:thin dotted #333;outline:5px auto -webkit-focus-ring-color;outline-offset:-2px}.as-heading-headline,.is-typeset .headline{font-size:3.2rem;line-height:0.85714}.as-heading-headline--typeset-leader{margin-top:3.6rem}.as-heading-headline--typeset-trailer,.is-typeset .headline{margin-bottom:1.6rem}.as-heading-largest,.is-typeset h1{font-size:2.8rem;line-height:1}.as-heading-largest--typeset-leader,.is-typeset h1{margin-top:4rem}.as-heading-largest--typeset-trailer,.is-typeset h1{margin-bottom:1.6rem}.as-heading-large,.is-typeset h2,.is-typeset h3,.is-typeset h4{font-size:2.6rem;line-height:1.2}.as-heading-large--typeset-leader,.is-typeset h2,.is-typeset h3,.is-typeset h4{margin-top:4rem}.as-heading-large--typeset-trailer,.is-typeset h2,.is-typeset h3,.is-typeset h4{margin-bottom:1.6rem}.as-heading-small,.is-typeset h5,.is-typeset h6{font-size:2rem;line-height:1.2}.as-heading-small--typeset-leader,.is-typeset h5,.is-typeset h6{margin-top:4rem}.as-heading-small--typeset-trailer,.is-typeset h5,.is-typeset h6{margin-bottom:1.6rem}.as-para{font-size:1.6rem}.as-para--typeset,.is-typeset p{margin-bottom:1.6rem}.as-unordered-list,.is-typeset ul{list-style-position:outside;list-style-type:disc;padding-left:1em}.as-ordered-list,.is-typeset ol{list-style-position:outside;list-style-type:decimal;padding-left:1.25em}.as-nobullet-list{list-style-type:none}.as-list--typeset,.as-unordered-list--typeset,.is-typeset ul,.as-ordered-list--typeset,.is-typeset ol{margin-bottom:1.6rem;margin-top:1.6rem}.as-list-item--typeset,.as-unordered-list li,.is-typeset ul li,.as-ordered-list li,.is-typeset ol li,.as-nobullet-list li{margin-bottom:0.8rem}@media print{body{font-size:62.5%}} -/*# sourceMappingURL=basic.css.map */ diff --git a/requirements.in b/requirements.in index fb79b5800..0163ce8b9 100644 --- a/requirements.in +++ b/requirements.in @@ -8,10 +8,12 @@ django-import-export django-haystack django-modeltranslation django-prettyjson -django-recaptcha3 +# Pull in a repo with a small fix to get Django 4.2 working +# See https://github.com/kbytesys/django-recaptcha3/issues/22#issuecomment-1848441795 +django-recaptcha3 @ git+https://github.com/bartsanchez/django-recaptcha3.git@313509e40163ce381e7aa3decd1de1ed9f71d380 django-storages[azure] django-widget-tweaks -Django>=3.2,<3.3 +Django>=4.2,<4.3 elasticsearch>=6.8,<7 gunicorn opencensus-ext-azure @@ -19,8 +21,9 @@ opencensus-ext-django PyGithub psycopg2-binary requests +tzdata wagtail-modeltranslation -wagtail>=4.1,<4.2 +wagtail>=5.2,<5.3 Wand whitenoise wrapt diff --git a/requirements.txt b/requirements.txt index 28e174f59..ae3774bc2 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.8 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # # pip-compile requirements.in @@ -16,12 +16,10 @@ azure-core==1.30.2 # opencensus-ext-azure azure-identity==1.17.1 # via opencensus-ext-azure -azure-storage-blob==12.21.0 +azure-storage-blob==12.22.0 # via django-storages -babel==2.15.0 +babel==2.16.0 # via -r requirements.in -backports-zoneinfo==0.2.1 - # via djangorestframework beautifulsoup4==4.11.2 # via # -r requirements.in @@ -32,7 +30,7 @@ cachetools==5.4.0 # via google-auth certifi==2024.7.4 # via requests -cffi==1.16.0 +cffi==1.17.0 # via # cryptography # pynacl @@ -52,11 +50,12 @@ diff-match-patch==20230430 # via django-import-export dj-database-url==2.2.0 # via -r requirements.in -django==3.2.25 +django==4.2.15 # via # -r requirements.in # dj-database-url # django-appconf + # django-compressor # django-extensions # django-filter # django-haystack @@ -74,11 +73,11 @@ django==3.2.25 # wagtail-modeltranslation django-appconf==1.0.6 # via django-compressor -django-compressor==4.4 +django-compressor==4.5.1 # via -r requirements.in django-extensions==3.2.3 # via -r requirements.in -django-filter==22.1 +django-filter==23.5 # via wagtail django-haystack==3.3.0 # via -r requirements.in @@ -86,7 +85,7 @@ django-import-export==4.1.1 # via -r requirements.in django-modelcluster==6.3 # via wagtail -django-modeltranslation==0.18.11 +django-modeltranslation==0.19.7 # via # -r requirements.in # wagtail-modeltranslation @@ -94,17 +93,17 @@ django-permissionedforms==0.1 # via wagtail django-prettyjson==0.4.1 # via -r requirements.in -django-recaptcha3==0.4.0 +django-recaptcha3 @ git+https://github.com/bartsanchez/django-recaptcha3.git@313509e40163ce381e7aa3decd1de1ed9f71d380 # via -r requirements.in django-storages[azure]==1.14.4 # via -r requirements.in -django-taggit==3.1.0 +django-taggit==4.0.0 # via wagtail django-treebeard==4.7.1 # via wagtail django-widget-tweaks==1.5.0 # via -r requirements.in -djangorestframework==3.15.1 +djangorestframework==3.15.2 # via wagtail draftjs-exporter==2.1.7 # via wagtail @@ -116,11 +115,11 @@ filetype==1.2.0 # via willow google-api-core==2.19.1 # via opencensus -google-auth==2.32.0 +google-auth==2.33.0 # via google-api-core googleapis-common-protos==1.63.2 # via google-api-core -gunicorn==22.0.0 +gunicorn==23.0.0 # via -r requirements.in html5lib==1.1 # via wagtail @@ -153,7 +152,11 @@ packaging==24.1 # django-haystack # gunicorn pillow==10.4.0 - # via wagtail + # via + # pillow-heif + # wagtail +pillow-heif==0.18.0 + # via willow portalocker==2.10.1 # via msal-extensions proto-plus==1.24.0 @@ -185,11 +188,9 @@ pynacl==1.5.0 # via pygithub pytz==2024.1 # via - # babel - # django # django-modelcluster # l18n -rcssmin==1.1.1 +rcssmin==1.1.2 # via django-compressor requests==2.32.3 # via @@ -201,7 +202,7 @@ requests==2.32.3 # opencensus-ext-azure # pygithub # wagtail -rjsmin==1.2.1 +rjsmin==1.2.2 # via django-compressor rsa==4.9 # via google-auth @@ -226,23 +227,23 @@ telepath==0.3.1 # via wagtail typing-extensions==4.12.2 # via - # asgiref # azure-core # azure-identity # azure-storage-blob # dj-database-url - # django-modeltranslation # pygithub +tzdata==2024.1 + # via -r requirements.in urllib3==2.2.2 # via # elasticsearch # pygithub # requests -wagtail==4.1.9 +wagtail==5.2.6 # via # -r requirements.in # wagtail-modeltranslation -wagtail-modeltranslation==0.14.4 +wagtail-modeltranslation==0.15.1 # via -r requirements.in wand==0.6.13 # via -r requirements.in @@ -252,8 +253,10 @@ webencodings==0.5.1 # html5lib whitenoise==6.7.0 # via -r requirements.in -willow==1.6.3 - # via wagtail +willow[heif]==1.6.3 + # via + # wagtail + # willow wrapt==1.16.0 # via # -r requirements.in diff --git a/requirements_dev.in b/requirements_dev.in index b59a56038..5f77cf35d 100644 --- a/requirements_dev.in +++ b/requirements_dev.in @@ -6,10 +6,10 @@ pytest-timeout splinter pytest-splinter responses -flake8>3.9,<3.10 +flake8 pydocstyle -pylint>2.4,<2.5 -pylint-django>2.0,<2.1 +pylint +pylint-django wagtail-factories factory-boy sqlparse diff --git a/requirements_dev.txt b/requirements_dev.txt index 42d81029a..ec760b291 100644 --- a/requirements_dev.txt +++ b/requirements_dev.txt @@ -1,5 +1,5 @@ # -# This file is autogenerated by pip-compile with Python 3.8 +# This file is autogenerated by pip-compile with Python 3.12 # by the following command: # # pip-compile requirements_dev.in @@ -12,9 +12,9 @@ asgiref==3.8.1 # via # -r requirements.txt # django -astroid==2.3.0 +astroid==3.2.4 # via pylint -attrs==23.2.0 +attrs==24.2.0 # via # -r requirements_dev.in # outcome @@ -30,16 +30,12 @@ azure-identity==1.17.1 # via # -r requirements.txt # opencensus-ext-azure -azure-storage-blob==12.21.0 +azure-storage-blob==12.22.0 # via # -r requirements.txt # django-storages -babel==2.15.0 +babel==2.16.0 # via -r requirements.txt -backports-zoneinfo==0.2.1 - # via - # -r requirements.txt - # djangorestframework beautifulsoup4==4.11.2 # via # -r requirements.txt @@ -55,7 +51,7 @@ certifi==2024.7.4 # -r requirements.txt # requests # selenium -cffi==1.16.0 +cffi==1.17.0 # via # -r requirements.txt # cryptography @@ -83,13 +79,16 @@ diff-match-patch==20230430 # via # -r requirements.txt # django-import-export +dill==0.3.8 + # via pylint dj-database-url==2.2.0 # via -r requirements.txt -django==3.2.25 +django==4.2.15 # via # -r requirements.txt # dj-database-url # django-appconf + # django-compressor # django-debug-toolbar # django-extensions # django-filter @@ -110,13 +109,13 @@ django-appconf==1.0.6 # via # -r requirements.txt # django-compressor -django-compressor==4.4 +django-compressor==4.5.1 # via -r requirements.txt -django-debug-toolbar==4.3.0 +django-debug-toolbar==4.4.6 # via -r requirements_dev.in django-extensions==3.2.3 # via -r requirements.txt -django-filter==22.1 +django-filter==23.5 # via # -r requirements.txt # wagtail @@ -128,7 +127,7 @@ django-modelcluster==6.3 # via # -r requirements.txt # wagtail -django-modeltranslation==0.18.11 +django-modeltranslation==0.19.7 # via # -r requirements.txt # wagtail-modeltranslation @@ -138,11 +137,11 @@ django-permissionedforms==0.1 # wagtail django-prettyjson==0.4.1 # via -r requirements.txt -django-recaptcha3==0.4.0 +django-recaptcha3 @ git+https://github.com/bartsanchez/django-recaptcha3.git@313509e40163ce381e7aa3decd1de1ed9f71d380 # via -r requirements.txt django-storages[azure]==1.14.4 # via -r requirements.txt -django-taggit==3.1.0 +django-taggit==4.0.0 # via # -r requirements.txt # wagtail @@ -152,7 +151,7 @@ django-treebeard==4.7.1 # wagtail django-widget-tweaks==1.5.0 # via -r requirements.txt -djangorestframework==3.15.1 +djangorestframework==3.15.2 # via # -r requirements.txt # wagtail @@ -166,28 +165,23 @@ et-xmlfile==1.1.0 # via # -r requirements.txt # openpyxl -exceptiongroup==1.2.2 - # via - # pytest - # trio - # trio-websocket factory-boy==3.3.0 # via # -r requirements_dev.in # wagtail-factories -faker==26.1.0 +faker==27.0.0 # via factory-boy filetype==1.2.0 # via # -r requirements.txt # willow -flake8==3.9.2 +flake8==7.1.1 # via -r requirements_dev.in google-api-core==2.19.1 # via # -r requirements.txt # opencensus -google-auth==2.32.0 +google-auth==2.33.0 # via # -r requirements.txt # google-api-core @@ -195,7 +189,7 @@ googleapis-common-protos==1.63.2 # via # -r requirements.txt # google-api-core -gunicorn==22.0.0 +gunicorn==23.0.0 # via -r requirements.txt h11==0.14.0 # via wsproto @@ -214,15 +208,13 @@ isodate==0.6.1 # via # -r requirements.txt # azure-storage-blob -isort==4.3.21 +isort==5.13.2 # via pylint l18n==2021.3 # via # -r requirements.txt # wagtail -lazy-object-proxy==1.10.0 - # via astroid -mccabe==0.6.1 +mccabe==0.7.0 # via # flake8 # pylint @@ -263,7 +255,14 @@ packaging==24.1 pillow==10.4.0 # via # -r requirements.txt + # pillow-heif # wagtail +pillow-heif==0.18.0 + # via + # -r requirements.txt + # willow +platformdirs==4.2.2 + # via pylint pluggy==1.5.0 # via pytest portalocker==2.10.1 @@ -295,7 +294,7 @@ pyasn1-modules==0.4.0 # via # -r requirements.txt # google-auth -pycodestyle==2.7.0 +pycodestyle==2.12.1 # via flake8 pycparser==2.22 # via @@ -303,7 +302,7 @@ pycparser==2.22 # cffi pydocstyle==6.3.0 # via -r requirements_dev.in -pyflakes==2.3.1 +pyflakes==3.2.0 # via flake8 pygithub==2.3.0 # via -r requirements.txt @@ -312,12 +311,12 @@ pyjwt[crypto]==2.9.0 # -r requirements.txt # msal # pygithub -pylint==2.4.4 +pylint==3.2.6 # via # -r requirements_dev.in # pylint-django # pylint-plugin-utils -pylint-django==2.0.15 +pylint-django==2.5.5 # via -r requirements_dev.in pylint-plugin-utils==0.8.2 # via pylint-django @@ -344,13 +343,11 @@ python-dateutil==2.9.0.post0 pytz==2024.1 # via # -r requirements.txt - # babel - # django # django-modelcluster # l18n -pyyaml==6.0.1 +pyyaml==6.0.2 # via responses -rcssmin==1.1.1 +rcssmin==1.1.2 # via # -r requirements.txt # django-compressor @@ -367,7 +364,7 @@ requests==2.32.3 # wagtail responses==0.25.3 # via -r requirements_dev.in -rjsmin==1.2.1 +rjsmin==1.2.2 # via # -r requirements.txt # django-compressor @@ -380,7 +377,6 @@ selenium==4.23.1 six==1.16.0 # via # -r requirements.txt - # astroid # azure-core # bleach # django-prettyjson @@ -421,9 +417,9 @@ telepath==0.3.1 # via # -r requirements.txt # wagtail -tomli==2.0.1 - # via pytest -trio==0.26.0 +tomlkit==0.13.0 + # via pylint +trio==0.26.2 # via # selenium # trio-websocket @@ -432,14 +428,14 @@ trio-websocket==0.11.1 typing-extensions==4.12.2 # via # -r requirements.txt - # asgiref # azure-core # azure-identity # azure-storage-blob # dj-database-url - # django-modeltranslation # pygithub # selenium +tzdata==2024.1 + # via -r requirements.txt urllib3[socks]==2.2.2 # via # -r requirements.txt @@ -450,14 +446,14 @@ urllib3[socks]==2.2.2 # responses # selenium # splinter -wagtail==4.1.9 +wagtail==5.2.6 # via # -r requirements.txt # wagtail-factories # wagtail-modeltranslation -wagtail-factories==4.1.0 +wagtail-factories==4.2.1 # via -r requirements_dev.in -wagtail-modeltranslation==0.14.4 +wagtail-modeltranslation==0.15.1 # via -r requirements.txt wand==0.6.13 # via -r requirements.txt @@ -470,14 +466,13 @@ websocket-client==1.8.0 # via selenium whitenoise==6.7.0 # via -r requirements.txt -willow==1.6.3 +willow[heif]==1.6.3 # via # -r requirements.txt # wagtail wrapt==1.16.0 # via # -r requirements.txt - # astroid # deprecated wsproto==1.2.0 # via trio-websocket diff --git a/search/models.py b/search/models.py index d896f5b6f..68f36565a 100644 --- a/search/models.py +++ b/search/models.py @@ -1,4 +1,3 @@ -from itertools import chain from django.core.paginator import Paginator, EmptyPage, PageNotAnInteger from django.shortcuts import render from wagtail.models import Page @@ -67,14 +66,19 @@ def serve(self, request, page=None): for r in m.objects.live().public().search(search_query).annotate_score('_score')] search_results = sorted(search_results, key=lambda x: x._score, reverse=True) - promoted = [x.page.specific for x in Query.get(search_query).editors_picks.all() if x.page.live] - promoted_page_ids = [promoted_page.id for promoted_page in promoted] - filtered_search_results = [result for result in search_results if result.id not in promoted_page_ids] + # These don't work with recent wagtail, + # but there's currently no editors picks in the database, + # so disable for now. + # promoted = [x.page.specific for x in Query.get(search_query).editors_picks.all() if x.page.live] + # promoted_page_ids = [promoted_page.id for promoted_page in promoted] + # filtered_search_results = [result for result in search_results if result.id not in promoted_page_ids] query = Query.get(search_query) query.add_hit() - results = list(chain(promoted, filtered_search_results)) + # Disabled, see above + # results = list(chain(promoted, filtered_search_results)) + results = search_results else: results = Page.objects.none()