From 4bd1b62e645d66c8e324bc9bb8785f524c8a3d24 Mon Sep 17 00:00:00 2001 From: cmile Date: Wed, 25 May 2022 23:38:10 +0200 Subject: [PATCH] upgrade to django3.2 --- Dockerfile | 2 +- account/templates/base.html | 2 +- account/views.py | 4 ++-- cbapi_ldap/urls.py | 8 ++++---- cbapi_ldap/views.py | 6 +++--- cbmi/settings.py | 20 ++++++++++++-------- requirements.txt | 13 ++++++------- 7 files changed, 29 insertions(+), 26 deletions(-) diff --git a/Dockerfile b/Dockerfile index abceb94..4216cee 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ RUN apt-get update && apt-get install -y libsasl2-dev python-dev libldap2-dev li ADD requirements.txt /requirements.txt RUN pip install --upgrade -r /requirements.txt -RUN ls /opt/cbmi +# RUN ls /opt/cbmi EXPOSE 8000 ENTRYPOINT ["/opt/cbmi/start"] diff --git a/account/templates/base.html b/account/templates/base.html index 393bc84..d59cf41 100644 --- a/account/templates/base.html +++ b/account/templates/base.html @@ -1,6 +1,6 @@ {% load i18n %} {% load crispy_forms_tags %} -{% load static from staticfiles %} +{% load static %} diff --git a/account/views.py b/account/views.py index f61ca79..4d41236 100755 --- a/account/views.py +++ b/account/views.py @@ -14,7 +14,7 @@ from django.contrib.auth.models import User from django.http import HttpResponse, HttpResponseRedirect from django.shortcuts import get_object_or_404 from django.shortcuts import render -from django.shortcuts import render_to_response +from django.shortcuts import render from django.utils.translation import ugettext as _ import smbpasswd @@ -123,7 +123,7 @@ def groups_list(request, group_name): is_ceymaster = True if 'ldap_admins' in [g.name for g in request.user.groups.all()]: is_admin = True - return render_to_response("group_list.html", locals()) + return render(request, "group_list.html", locals()) @login_required diff --git a/cbapi_ldap/urls.py b/cbapi_ldap/urls.py index 478f5b8..f515de9 100644 --- a/cbapi_ldap/urls.py +++ b/cbapi_ldap/urls.py @@ -1,10 +1,10 @@ from django.conf.urls import url -from jsonrpc import jsonrpc_site -from jsonrpc.views import browse +# from jsonrpc import jsonrpc_site +# from jsonrpc.views import browse from cbapi_ldap import views urlpatterns = [ - url(r'^ldap/browse/$', browse, name='jsonrpc_browser'), - url(r'^ldap/$', jsonrpc_site.dispatch, name='jsonrpc_mountpoint'), + # url(r'^ldap/browse/$', browse, name='jsonrpc_browser'), + # url(r'^ldap/$', jsonrpc_site.dispatch, name='jsonrpc_mountpoint'), ] diff --git a/cbapi_ldap/views.py b/cbapi_ldap/views.py index d417c14..613c839 100644 --- a/cbapi_ldap/views.py +++ b/cbapi_ldap/views.py @@ -1,10 +1,10 @@ -from jsonrpc import jsonrpc_method +# from jsonrpc import jsonrpc_method TODO = [ '', ] -@jsonrpc_method("ping", authenticated=True) +# @jsonrpc_method("ping", authenticated=True) def ping(request, username, password): """Ping - Echo Request @@ -13,7 +13,7 @@ def ping(request, username, password): echo_response = "PONG" return echo_response -@jsonrpc_method("todo") +# @jsonrpc_method("todo") def todo(request): """Todo - List ToDo Items diff --git a/cbmi/settings.py b/cbmi/settings.py index b270422..854dc35 100644 --- a/cbmi/settings.py +++ b/cbmi/settings.py @@ -81,9 +81,11 @@ STATICFILES_DIRS = ( STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', - #'django.contrib.staticfiles.finders.DefaultStorageFinder', + # 'django.contrib.staticfiles.finders.DefaultStorageFinder', ) +DEFAULT_AUTO_FIELD = 'django.db.models.AutoField' + # Make this unique, and don't share it with anybody. SECRET_KEY = 'vp!#muchjm!fqgi9r1%^xi^t$vb443!e^3b3fyke7b))xk2ml=' @@ -144,9 +146,9 @@ TEMPLATES = [ import ldap from django_auth_ldap.config import LDAPSearch, GroupOfNamesType -AUTH_LDAP_SERVER_URI = "ldaps://lea.cbrp3.c-base.org" +AUTH_LDAP_SERVER_URI = "ldap://lea.cbrp3.c-base.org" AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s,ou=crew,dc=c-base,dc=org" -AUTH_LDAP_START_TLS = False +AUTH_LDAP_START_TLS = True AUTH_LDAP_BIND_AS_AUTHENTICATING_USER = True AUTH_LDAP_CACHE_GROUPS = True @@ -159,7 +161,7 @@ AUTH_LDAP_GROUP_SEARCH = LDAPSearch( ) AUTH_LDAP_REQUIRE_GROUP = "cn=crew,ou=groups,dc=c-base,dc=org" AUTH_LDAP_GROUP_TYPE = GroupOfNamesType(name_attr="cn") -#AUTH_LDAP_PROFILE_FLAGS_BY_GROUP = { +# AUTH_LDAP_PROFILE_FLAGS_BY_GROUP = { AUTH_LDAP_USER_FLAGS_BY_GROUP = { "is_member": "cn=crew,ou=groups,dc=c-base,dc=org", "is_ldap_admin": "cn=ldap_admins,ou=groups,dc=c-base,dc=org", @@ -202,11 +204,11 @@ INSTALLED_APPS = ( 'django.contrib.staticfiles', 'django.contrib.admin', 'django.contrib.admindocs', - #'jsonrpc', # STUBBED due to django-1.8.4 upgraded + # 'jsonrpc', # STUBBED due to django-1.8.4 upgraded 'crispy_forms', # 'cbmi', 'account', - #'cbapi_ldap', + # 'cbapi_ldap', ) # A sample logging configuration. The only tangible logging @@ -227,7 +229,8 @@ LOGGING = { 'level': 'ERROR', 'filters': ['require_debug_false'], 'class': 'django.utils.log.AdminEmailHandler' - } + }, + "console": {"class": "logging.StreamHandler"} }, 'loggers': { 'django.request': { @@ -235,6 +238,7 @@ LOGGING = { 'level': 'ERROR', 'propagate': True, }, + "django_auth_ldap": {"level": "DEBUG", "handlers": ["console"]} } } @@ -247,7 +251,7 @@ CBASE_BASE_DN = 'ou=crew,dc=c-base,dc=org' # Set session cookie timeout to 10 minutes SESSION_COOKIE_AGE = 600 LOGIN_URL = '/account/login/' -#LOCALE_PATHS = +# LOCALE_PATHS = try: from cbmi.local_settings import * diff --git a/requirements.txt b/requirements.txt index 74c029c..6cbdecf 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,9 +1,8 @@ -Django==1.11.25 -#MySQL-python==1.2.5 -django-auth-ldap>=1.7.0 -django-json-rpc>=0.7.2 -django-crispy-forms>=1.7.2 -gunicorn>=19.9.0 +Django==3.2.8 +django-auth-ldap==3.0.0 +# django-json-rpc>=0.7.2 +django-crispy-forms>=1.13.0 +gunicorn>=20.1.0 pycrypto>=2.6.1 passlib -requests>=2.19.1 +requests>=2.26.0