diff --git a/VIPSWeb/settings.py b/VIPSWeb/settings.py index 328239715d634400b3256029846767d41b673280..ac1cb4cef88518da881029962340a42c4ad49c1b 100755 --- a/VIPSWeb/settings.py +++ b/VIPSWeb/settings.py @@ -79,7 +79,7 @@ STATICFILES_FINDERS = ( -MIDDLEWARE_CLASSES = ( +MIDDLEWARE = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', diff --git a/VIPSWeb/templatetags/template_helper.py b/VIPSWeb/templatetags/template_helper.py index c13f9a90de57d1e2c20b43591c6060c6c7b8a43a..7157562939286e228256e3fdb1050ab4f0e1a40f 100755 --- a/VIPSWeb/templatetags/template_helper.py +++ b/VIPSWeb/templatetags/template_helper.py @@ -93,7 +93,7 @@ def generate_frontpage_menu(context): """ menu_html = '' - col_md = 12/len(settings.FRONTPAGE_MENU) + col_md = int(12/len(settings.FRONTPAGE_MENU)) for col in settings.FRONTPAGE_MENU: menu_html += '<div class="col-md-%s"><h3>%s</h3>' % (col_md,_(col["label"])) menu_html += "<ul class='linkList'>" diff --git a/VIPSWeb/urls.py b/VIPSWeb/urls.py index c0ec1a85991189db120fcef646d12e77cd5c6808..681c5c57d12edf83cfd960e2c9a0de1dbb94db84 100755 --- a/VIPSWeb/urls.py +++ b/VIPSWeb/urls.py @@ -30,7 +30,7 @@ admin.autodiscover() # Enabling translation in JavaScript files # See https://docs.djangoproject.com/en/1.5/topics/i18n/translation/#internationalization-in-javascript-code js_info_dict = { - 'packages': ['forecasts','messages','VIPSWeb','roughage'], + 'packages': ['forecasts','vips_messages','VIPSWeb','roughage'], 'domain': 'djangojs', } diff --git a/VIPSWeb/views.py b/VIPSWeb/views.py index 1d8589a87efaaec2c5a718721574dda5a4ebfccd..74f2fee79de9e9896d5f2a92231139a040213b02 100755 --- a/VIPSWeb/views.py +++ b/VIPSWeb/views.py @@ -100,13 +100,15 @@ def vipslogicproxy(request, path): params = request.urlencode() - #print "Params:" + params + #print ("Params:" + params) try: url = "%s://%s/%s" % (settings.VIPSLOGIC_PROTOCOL, settings.VIPSLOGIC_SERVER_NAME,path) - #print url + #print(url) except KeyError: return HttpResponseBadRequest("URL must be defined") - response = r(url.encode("ascii"), params=params.encode("ascii")) + url = url.encode("ascii") + params_encoded = params.encode("ascii") + response = r(url, params=params_encoded) if response.status_code == 200: return HttpResponse(response.text, status=int(response.status_code), content_type=response.headers.get('content-type',"text/plain")) else: diff --git a/VIPSWeb/wsgi.py b/VIPSWeb/wsgi.py index ff8ffae4841294be0c3b1f4021b5a244e343072e..ff95b082818085ce939804325a72d1f6b190c22a 100755 --- a/VIPSWeb/wsgi.py +++ b/VIPSWeb/wsgi.py @@ -32,6 +32,7 @@ framework. """ import os +from django.core.wsgi import get_wsgi_application # We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks # if running multiple sites in the same mod_wsgi process. To fix this, use @@ -42,7 +43,7 @@ os.environ.setdefault("DJANGO_SETTINGS_MODULE", "VIPSWeb.settings") # This application object is used by any WSGI server configured to use this # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. -from django.core.wsgi import get_wsgi_application + application = get_wsgi_application() # Apply WSGI middleware here. diff --git a/common/middleware/whodid.py b/common/middleware/whodid.py index f14aff18472ac1d63656ee4f85caa0e8efb5ccec..97b59e2dc4cad5035cda4b2d768d5b1f9273a57d 100755 --- a/common/middleware/whodid.py +++ b/common/middleware/whodid.py @@ -23,8 +23,17 @@ Found here: https://gist.github.com/mindlace/3918300 """ from django.db.models import signals from django.utils.functional import curry +from django.http import HttpResponse class WhodidMiddleware(object): + + def __init__(self, get_response): + self.get_response = get_response + + def __call__(self, request): + self.process_request(request) + return self.get_response(request) + def process_request(self, request): if not request.method in ('GET', 'HEAD', 'OPTIONS', 'TRACE'): if hasattr(request, 'user') and request.user.is_authenticated(): diff --git a/information/migrations/0001_initial.py b/information/migrations/0001_initial.py index 997a00159a03ff8aad42ed4ecb327faf945ee3f5..33f5474900a5416df0ad074f47df4dc26454d05e 100755 --- a/information/migrations/0001_initial.py +++ b/information/migrations/0001_initial.py @@ -16,7 +16,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('main_illustration', models.ImageField(upload_to=b'images/information', verbose_name='Hovedillustrasjon', blank=True)), - ('parent_information', models.ForeignKey(related_name='children', verbose_name='Informasjon', blank=True, to='information.Information', null=True)), + ('parent_information', models.ForeignKey(related_name='children', verbose_name='Informasjon', blank=True, to='information.Information', null=True,on_delete=models.CASCADE)), ], ), migrations.CreateModel( @@ -24,7 +24,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('attachment', models.FileField(upload_to=b'attachments/information', verbose_name='Vedlegg', blank=True)), - ('information', models.ForeignKey(to='information.Information')), + ('information', models.ForeignKey(to='information.Information',on_delete=models.CASCADE)), ], ), migrations.CreateModel( @@ -32,7 +32,7 @@ class Migration(migrations.Migration): fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('illustration', models.ImageField(upload_to=b'images/information', verbose_name='Illustrasjon', blank=True)), - ('information', models.ForeignKey(to='information.Information')), + ('information', models.ForeignKey(to='information.Information',on_delete=models.CASCADE)), ], ), migrations.CreateModel( @@ -43,7 +43,7 @@ class Migration(migrations.Migration): ('lead_paragraph', models.TextField(verbose_name='Ingress')), ('body', tinymce.models.HTMLField(verbose_name='Br\xf8dtekst')), ('language_code', models.CharField(max_length=2, verbose_name='Spr\xe5kkode')), - ('information', models.ForeignKey(to='information.Information')), + ('information', models.ForeignKey(to='information.Information',on_delete=models.CASCADE)), ], ), ] diff --git a/requirements.txt b/requirements.txt index d95ce78865766fc35857a11b2a2546a86dd88e60..c0746db45bd76e2f6933a4a875f0ade26786e5fc 100755 --- a/requirements.txt +++ b/requirements.txt @@ -18,9 +18,9 @@ # Please add requirements here # Read docs for how this works: http://www.pip-installer.org/en/latest/cookbook.html -Django==1.11.17 +Django==2.0.13 Pillow -requests==2.6.0 +requests==2.25.0 django-tinymce==2.8.0 python-dateutil==2.8.1 django-extensions diff --git a/security/middleware/check_login_middleware.py b/security/middleware/check_login_middleware.py index b2681fadb7ba49e57ce9870aa6b8116b8b1f13c4..e8c856a77b16d8181f52d6da8543cb0042686b20 100755 --- a/security/middleware/check_login_middleware.py +++ b/security/middleware/check_login_middleware.py @@ -21,11 +21,20 @@ from security.models import VipsLogicUser from django.conf import settings from datetime import datetime, timedelta import json +from django.http import HttpResponse class CheckLoginMiddleware(object): datetime_format = "%Y-%m-%d %H:%M:%S" + def __init__(self, get_response): + self.get_response = get_response + + def __call__(self, request): + self.process_request(request) + return self.get_response(request) + + def process_request(self, request): # If UUID is provided, login with VIPSLogic # VIPSLogicUser exists in session for 24 hours