Towards django2.0

This commit is contained in:
Julian M. Kunkel 2018-05-06 00:04:26 +01:00
parent 5cf362c910
commit ebe78713ef
8 changed files with 19 additions and 14 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
run run
*.pyc
__pycache__

View File

@ -2,6 +2,8 @@
ServerAdmin admin@hps.vi4io.org ServerAdmin admin@hps.vi4io.org
#ServerName oer.hps.vi4io.org #ServerName oer.hps.vi4io.org
#/etc/apache2/apache2.conf => LogLevel info
WSGIScriptAlias / "/data/src/main/wsgi.py" WSGIScriptAlias / "/data/src/main/wsgi.py"
WSGIDaemonProcess hoou python-home=/data/run/virtualenv python-path=/data/src/ home=/data/src/ inactivity-timeout=10 request-timeout=10 WSGIDaemonProcess hoou python-home=/data/run/virtualenv python-path=/data/src/ home=/data/src/ inactivity-timeout=10 request-timeout=10
WSGIProcessGroup hoou WSGIProcessGroup hoou

View File

@ -19,7 +19,6 @@ if [[ ! -e $V ]] ; then
source $V/bin/activate source $V/bin/activate
pip3 install -U -r /data/dev/requirements.txt pip3 install -U -r /data/dev/requirements.txt
python3 ./manage.py migrate python3 ./manage.py migrate
python3 ./manage.py collectstatic
fi fi
source $V/bin/activate source $V/bin/activate

View File

@ -6,4 +6,5 @@ cd /data/src
export GENERATED_PATH=/data/run/oer export GENERATED_PATH=/data/run/oer
export OER_SRC_DIR=/data/oer export OER_SRC_DIR=/data/oer
export PLATFORM_PATH=/data/src export PLATFORM_PATH=/data/src
python3 manage.py import-courses --sources=/data/oer/courses --formats=/data/oer/exercise-formats/ python3 ./manage.py import-courses --sources=/data/oer/courses --formats=/data/oer/exercise-formats/
python3 ./manage.py collectstatic

View File

@ -8,6 +8,8 @@ from django.urls import reverse
from django.http import HttpResponse from django.http import HttpResponse
from django.http import HttpResponseRedirect from django.http import HttpResponseRedirect
from django.contrib.auth.decorators import login_required
from django import template from django import template
from django.template.defaultfilters import stringfilter from django.template.defaultfilters import stringfilter
@ -40,7 +42,7 @@ def course(request, cid):
first_section = course.sections.first() first_section = course.sections.first()
first_slide = first_section.slides.first() first_slide = first_section.slides.first()
if request.user.is_authenticated(): if request.user.is_authenticated:
try: try:
# when the user is merely opening the course, jump the last active section (better: last incomplete?) # when the user is merely opening the course, jump the last active section (better: last incomplete?)
user_course = UserCourse.objects.get(course=course, user=request.user) user_course = UserCourse.objects.get(course=course, user=request.user)
@ -64,7 +66,7 @@ def section(request, cid, seid):
section = get_object_or_404(Section, pk=seid) section = get_object_or_404(Section, pk=seid)
first_slide = section.slides.first() first_slide = section.slides.first()
if request.user.is_authenticated(): if request.user.is_authenticated:
try: try:
user_course = UserCourse.objects.get(course=course, user=request.user) user_course = UserCourse.objects.get(course=course, user=request.user)
@ -97,7 +99,7 @@ def slide(request, cid, seid, slid):
if request.user.is_authenticated(): if request.user.is_authenticated:
try: try:
user_course = UserCourse.objects.get(course=course, user=request.user) user_course = UserCourse.objects.get(course=course, user=request.user)
# simply update last user_course action # simply update last user_course action
@ -112,7 +114,7 @@ def slide(request, cid, seid, slid):
user_solution = None user_solution = None
if request.user.is_authenticated(): if request.user.is_authenticated:
try: try:
user_solution = UserSolution.objects.get(slide=slide, user=request.user) user_solution = UserSolution.objects.get(slide=slide, user=request.user)

View File

@ -36,7 +36,7 @@ def attribution(request):
def dashboard(request): def dashboard(request):
# only registered users can see their statistics # only registered users can see their statistics
if not request.user.is_authenticated(): if not request.user.is_authenticated:
return HttpResponseRedirect('/') return HttpResponseRedirect('/')
else: else:
data = {} data = {}
@ -47,7 +47,7 @@ def dashboard(request):
@login_required @login_required
def settings(request): def settings(request):
# only registered users have settings # only registered users have settings
if not request.user.is_authenticated(): if not request.user.is_authenticated:
return HttpResponseRedirect('/') return HttpResponseRedirect('/')
else: else:
data = {} data = {}

View File

@ -23,7 +23,7 @@ SECRET_KEY = 'pxf234t25323vasfk3t202v2232v124'
# SECURITY WARNING: don't run with debug turned on in production! # SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False DEBUG = False
#DEBUG = True DEBUG = True
ALLOWED_HOSTS = ['localhost', 'oer.hps.vi4io.org'] ALLOWED_HOSTS = ['localhost', 'oer.hps.vi4io.org']
@ -51,14 +51,13 @@ INSTALLED_APPS = (
'tools' 'tools'
) )
MIDDLEWARE_CLASSES = ( MIDDLEWARE = (
# 'djangosecure.middleware.SecurityMiddleware', # 'djangosecure.middleware.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.common.CommonMiddleware', 'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware', 'django.middleware.security.SecurityMiddleware',
) )

View File

@ -214,7 +214,7 @@ def job_new(request):
# Also create/update the user solution. # Also create/update the user solution.
user_solution = None user_solution = None
if request.user.is_authenticated(): if request.user.is_authenticated:
try: try:
item, created = UserSolution.objects.get_or_create(slide=slide, user=request.user) item, created = UserSolution.objects.get_or_create(slide=slide, user=request.user)
user_solution = item user_solution = item