From a3ca2e66bfeb4c35f7bce0b43051a4f0b4b2b866 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 22 Nov 2019 21:02:15 +0800 Subject: [PATCH 1/5] Fix some dependency issue with wagtail --- kfet/cms/fixtures/kfet_wagtail_02_19.json | 6 ++---- requirements.txt | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/kfet/cms/fixtures/kfet_wagtail_02_19.json b/kfet/cms/fixtures/kfet_wagtail_02_19.json index 4d3c4a9b..72b2a06d 100644 --- a/kfet/cms/fixtures/kfet_wagtail_02_19.json +++ b/kfet/cms/fixtures/kfet_wagtail_02_19.json @@ -1598,8 +1598,7 @@ "localhost", 8000 ], - "max_levels": 2, - "use_specific": 1 + "max_levels": 2 } }, { @@ -1613,8 +1612,7 @@ "title": "K-F\u00eat - Navigation", "handle": "kfet-nav", "heading": "", - "max_levels": 1, - "use_specific": 1 + "max_levels": 1 } } ] diff --git a/requirements.txt b/requirements.txt index 320f2c06..00183aea 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,6 +19,6 @@ ldap3 channels==1.1.5 python-dateutil wagtail==2.4.* -wagtailmenus<3 +wagtailmenus==3.* wagtail-modeltranslation==0.10.* django-cors-headers==2.2.0 From 481cb5e47809c61ca55719828c34432bb7a419be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 22 Nov 2019 21:58:56 +0800 Subject: [PATCH 2/5] Move production deps out of requirements.txt --- gestioncof/autocomplete.py | 8 +++++++- kfet/autocomplete.py | 8 +++++++- requirements-prod.txt | 14 ++++++++++++++ requirements.txt | 5 ----- 4 files changed, 28 insertions(+), 7 deletions(-) create mode 100644 requirements-prod.txt diff --git a/gestioncof/autocomplete.py b/gestioncof/autocomplete.py index 0aa94ae9..e27cdb92 100644 --- a/gestioncof/autocomplete.py +++ b/gestioncof/autocomplete.py @@ -3,11 +3,17 @@ from django.conf import settings from django.contrib.auth.models import User from django.db.models import Q from django.http import Http404 -from ldap3 import Connection from gestioncof.decorators import buro_required from gestioncof.models import CofProfile +if getattr(settings, "LDAP_SERVER_URL", None): + from ldap3 import Connection +else: + # shared.tests.testcases.TestCaseMixin.mockLDAP needs + # Connection to be defined in order to mock it. + Connection = None + class Clipper(object): def __init__(self, clipper, fullname): diff --git a/kfet/autocomplete.py b/kfet/autocomplete.py index d7448194..5b23bb1e 100644 --- a/kfet/autocomplete.py +++ b/kfet/autocomplete.py @@ -2,12 +2,18 @@ from django.conf import settings from django.db.models import Q from django.http import Http404 from django.shortcuts import render -from ldap3 import Connection from gestioncof.models import User from kfet.decorators import teamkfet_required from kfet.models import Account +if getattr(settings, "LDAP_SERVER_URL", None): + from ldap3 import Connection +else: + # shared.tests.testcases.TestCaseMixin.mockLDAP needs + # Connection to be defined in order to mock it. + Connection = None + class Clipper(object): def __init__(self, clipper, fullname): diff --git a/requirements-prod.txt b/requirements-prod.txt new file mode 100644 index 00000000..6d7b645e --- /dev/null +++ b/requirements-prod.txt @@ -0,0 +1,14 @@ +-r requirements.txt + +# Postgresql bindings +psycopg2<2.8 + +# Redis +django-redis-cache==1.8.1 + +# ASGI protocol and HTTP server +asgiref==1.1.1 +daphne==1.3.0 + +# ldap bindings +ldap3 diff --git a/requirements.txt b/requirements.txt index 00183aea..7dc49821 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,18 +4,13 @@ django-autocomplete-light==3.3.* django-cas-ng==3.6.* django-djconfig==0.8.0 django-recaptcha==1.4.0 -django-redis-cache==1.8.1 icalendar -psycopg2<2.8 Pillow django-bootstrap-form==3.3 -asgiref==1.1.1 -daphne==1.3.0 asgi-redis==1.3.0 statistics==1.0.3.5 django-widget-tweaks==1.4.1 git+https://git.eleves.ens.fr/cof-geek/django_custommail.git#egg=django_custommail -ldap3 channels==1.1.5 python-dateutil wagtail==2.4.* From e2af45929ec2fe499cd82d245f92eae2e52577e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 22 Nov 2019 22:22:21 +0800 Subject: [PATCH 3/5] Use the production requirements in CI --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a8f27b8f..6a6ce23a 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,7 +27,7 @@ test: - sed -i.bak -E 's;^REDIS_PASSWD = .*$;REDIS_PASSWD = "";' cof/settings/secret.py # Remove the old test database if it has not been done yet - psql --username=$POSTGRES_USER --host=$DBHOST -c "DROP DATABASE IF EXISTS test_$POSTGRES_DB" - - pip install --upgrade -r requirements.txt coverage tblib + - pip install --upgrade -r requirements-prod.txt coverage tblib - python --version script: - coverage run manage.py test --parallel @@ -67,7 +67,7 @@ migration_checks: - mkdir -p vendor/{pip,apt} - apt-get update -q && apt-get -o dir::cache::archives="vendor/apt" install -yqq postgresql-client - cp cof/settings/secret_example.py cof/settings/secret.py - - pip install --upgrade -r requirements.txt + - pip install --upgrade -r requirements-prod.txt - python --version script: python manage.py makemigrations --dry-run --check services: From 8c5d09dbeec34c67e911d12ecbea6fef46aa8a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 22 Nov 2019 22:35:23 +0800 Subject: [PATCH 4/5] Bump wagtail to version 2.7 (LTS) --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 7dc49821..be12f457 100644 --- a/requirements.txt +++ b/requirements.txt @@ -13,7 +13,7 @@ django-widget-tweaks==1.4.1 git+https://git.eleves.ens.fr/cof-geek/django_custommail.git#egg=django_custommail channels==1.1.5 python-dateutil -wagtail==2.4.* +wagtail==2.7.* wagtailmenus==3.* wagtail-modeltranslation==0.10.* django-cors-headers==2.2.0 From f9b461a08db930a3429ffcd37722047b233377f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20P=C3=A9pin?= Date: Fri, 22 Nov 2019 22:45:27 +0800 Subject: [PATCH 5/5] Bump django-redis-cache to version 2.1.* --- requirements-prod.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements-prod.txt b/requirements-prod.txt index 6d7b645e..e08ac120 100644 --- a/requirements-prod.txt +++ b/requirements-prod.txt @@ -4,7 +4,7 @@ psycopg2<2.8 # Redis -django-redis-cache==1.8.1 +django-redis-cache==2.1.* # ASGI protocol and HTTP server asgiref==1.1.1