Skip to content
Snippets Groups Projects
Commit cd8426f4 authored by Tor-Einar Skog's avatar Tor-Einar Skog
Browse files

Migration step 2: Now works with Django 2.0

parent d4caff28
Branches
No related tags found
1 merge request!8Upgrade to django 3.1
...@@ -79,7 +79,7 @@ STATICFILES_FINDERS = ( ...@@ -79,7 +79,7 @@ STATICFILES_FINDERS = (
MIDDLEWARE_CLASSES = ( MIDDLEWARE = (
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
......
...@@ -93,7 +93,7 @@ def generate_frontpage_menu(context): ...@@ -93,7 +93,7 @@ def generate_frontpage_menu(context):
""" """
menu_html = '' menu_html = ''
col_md = 12/len(settings.FRONTPAGE_MENU) col_md = int(12/len(settings.FRONTPAGE_MENU))
for col in 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 += '<div class="col-md-%s"><h3>%s</h3>' % (col_md,_(col["label"]))
menu_html += "<ul class='linkList'>" menu_html += "<ul class='linkList'>"
......
...@@ -30,7 +30,7 @@ admin.autodiscover() ...@@ -30,7 +30,7 @@ admin.autodiscover()
# Enabling translation in JavaScript files # Enabling translation in JavaScript files
# See https://docs.djangoproject.com/en/1.5/topics/i18n/translation/#internationalization-in-javascript-code # See https://docs.djangoproject.com/en/1.5/topics/i18n/translation/#internationalization-in-javascript-code
js_info_dict = { js_info_dict = {
'packages': ['forecasts','messages','VIPSWeb','roughage'], 'packages': ['forecasts','vips_messages','VIPSWeb','roughage'],
'domain': 'djangojs', 'domain': 'djangojs',
} }
......
...@@ -100,13 +100,15 @@ def vipslogicproxy(request, path): ...@@ -100,13 +100,15 @@ def vipslogicproxy(request, path):
params = request.urlencode() params = request.urlencode()
#print "Params:" + params #print ("Params:" + params)
try: try:
url = "%s://%s/%s" % (settings.VIPSLOGIC_PROTOCOL, settings.VIPSLOGIC_SERVER_NAME,path) url = "%s://%s/%s" % (settings.VIPSLOGIC_PROTOCOL, settings.VIPSLOGIC_SERVER_NAME,path)
#print url #print(url)
except KeyError: except KeyError:
return HttpResponseBadRequest("URL must be defined") 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: if response.status_code == 200:
return HttpResponse(response.text, status=int(response.status_code), content_type=response.headers.get('content-type',"text/plain")) return HttpResponse(response.text, status=int(response.status_code), content_type=response.headers.get('content-type',"text/plain"))
else: else:
......
...@@ -32,6 +32,7 @@ framework. ...@@ -32,6 +32,7 @@ framework.
""" """
import os import os
from django.core.wsgi import get_wsgi_application
# We defer to a DJANGO_SETTINGS_MODULE already in the environment. This breaks # 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 # 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") ...@@ -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 # This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION # file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here. # setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application() application = get_wsgi_application()
# Apply WSGI middleware here. # Apply WSGI middleware here.
......
...@@ -23,8 +23,17 @@ Found here: https://gist.github.com/mindlace/3918300 ...@@ -23,8 +23,17 @@ Found here: https://gist.github.com/mindlace/3918300
""" """
from django.db.models import signals from django.db.models import signals
from django.utils.functional import curry from django.utils.functional import curry
from django.http import HttpResponse
class WhodidMiddleware(object): 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): def process_request(self, request):
if not request.method in ('GET', 'HEAD', 'OPTIONS', 'TRACE'): if not request.method in ('GET', 'HEAD', 'OPTIONS', 'TRACE'):
if hasattr(request, 'user') and request.user.is_authenticated(): if hasattr(request, 'user') and request.user.is_authenticated():
......
...@@ -16,7 +16,7 @@ class Migration(migrations.Migration): ...@@ -16,7 +16,7 @@ class Migration(migrations.Migration):
fields=[ fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('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)), ('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( migrations.CreateModel(
...@@ -24,7 +24,7 @@ class Migration(migrations.Migration): ...@@ -24,7 +24,7 @@ class Migration(migrations.Migration):
fields=[ fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('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)), ('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( migrations.CreateModel(
...@@ -32,7 +32,7 @@ class Migration(migrations.Migration): ...@@ -32,7 +32,7 @@ class Migration(migrations.Migration):
fields=[ fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('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)), ('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( migrations.CreateModel(
...@@ -43,7 +43,7 @@ class Migration(migrations.Migration): ...@@ -43,7 +43,7 @@ class Migration(migrations.Migration):
('lead_paragraph', models.TextField(verbose_name='Ingress')), ('lead_paragraph', models.TextField(verbose_name='Ingress')),
('body', tinymce.models.HTMLField(verbose_name='Br\xf8dtekst')), ('body', tinymce.models.HTMLField(verbose_name='Br\xf8dtekst')),
('language_code', models.CharField(max_length=2, verbose_name='Spr\xe5kkode')), ('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)),
], ],
), ),
] ]
...@@ -18,9 +18,9 @@ ...@@ -18,9 +18,9 @@
# Please add requirements here # Please add requirements here
# Read docs for how this works: http://www.pip-installer.org/en/latest/cookbook.html # Read docs for how this works: http://www.pip-installer.org/en/latest/cookbook.html
Django==1.11.17 Django==2.0.13
Pillow Pillow
requests==2.6.0 requests==2.25.0
django-tinymce==2.8.0 django-tinymce==2.8.0
python-dateutil==2.8.1 python-dateutil==2.8.1
django-extensions django-extensions
......
...@@ -21,11 +21,20 @@ from security.models import VipsLogicUser ...@@ -21,11 +21,20 @@ from security.models import VipsLogicUser
from django.conf import settings from django.conf import settings
from datetime import datetime, timedelta from datetime import datetime, timedelta
import json import json
from django.http import HttpResponse
class CheckLoginMiddleware(object): class CheckLoginMiddleware(object):
datetime_format = "%Y-%m-%d %H:%M:%S" 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): def process_request(self, request):
# If UUID is provided, login with VIPSLogic # If UUID is provided, login with VIPSLogic
# VIPSLogicUser exists in session for 24 hours # VIPSLogicUser exists in session for 24 hours
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment