Gitlab CSE Unil

Commit 6ed8a210 authored by Julien Furrer's avatar Julien Furrer
Browse files

Fixed BASE_URL trailing slash ; added moodle check_url

parent 6a087d5b
......@@ -21,10 +21,12 @@ def generate_apache_conf(target='local', quiet=True, yes=True):
is_robot = os.path.isfile(os.path.join(settings.STATIC_ROOT, 'robots.txt'))
is_favicon = os.path.isfile(os.path.join(settings.STATIC_ROOT, 'favicon.ico'))
wsgi_alias = getattr(settings, 'BASE_URL', '/').rstrip('/') or '/'
rendered = config_tpl.render(Context({
'settings': settings,
'is_robot': is_robot,
'is_favicon': is_favicon,
'wsgi_alias': wsgi_alias,
'wsgi_path': os.path.join(settings.SITE_ROOT, *settings.WSGI_APPLICATION.split('.')[:-1]) + '.py',
}))
......
......@@ -119,8 +119,9 @@ def update_urls(base_url=None, name=__name__):
setattr(this_module, 'BASE_URL', base_url)
setattr(this_module, 'SESSION_COOKIE_PATH', base_url)
setattr(this_module, 'CSRF_COOKIE_PATH', base_url)
setattr(this_module, 'MEDIA_URL', '{}/media/'.format(base_url))
setattr(this_module, 'STATIC_URL', '{}/static/'.format(base_url))
setattr(this_module, 'MEDIA_URL', '{}media/'.format(base_url))
setattr(this_module, 'STATIC_URL', '{}static/'.format(base_url))
setattr(this_module, 'CORS_URLS_REGEX', r'^{}api/.*$'.format(base_url))
update_urls("/")
# ---------- END URL CONFIGURATION
......@@ -181,7 +182,7 @@ MIDDLEWARE_CLASSES.insert(
)
MIDDLEWARE_CLASSES += ('corsheaders.middleware.CorsMiddleware', )
CORS_ORIGIN_ALLOW_ALL = True
CORS_URLS_REGEX = r'^/api/.*$'
# CORS_URLS_REGEX = r'^.*/api/.*$'
# ..... ADIM
......@@ -237,7 +238,7 @@ ATTP = {
'CACHE_TIMEOUT': 20, # 30,
},
'moodle': {
'CHECK_URL': "http://localhost/tests/phpupload/gv.php?a={uuid}",
'CHECK_URL': "http://tstmoodle.unil.ch/28/mod/adim/checkAccess.php?uuid={uuid}",
'MODE_ID': 16
},
'toto': {
......
......@@ -4,7 +4,7 @@ Settings for production server
from .base import *
update_urls('/adim', __name__)
update_urls('/adim/', __name__)
ALLOWED_HOSTS = ['.unil.ch']
......
......@@ -6,7 +6,7 @@ from .base import *
DEBUG = True
TEMPLATE_DEBUG = TEMPLATES[0]['OPTIONS']['debug'] = True
update_urls('/adim-dev', __name__)
update_urls('/adim-dev/', __name__)
ALLOWED_HOSTS = ['.unil.ch']
......
......@@ -177,7 +177,7 @@ def get_or_create_user(attp_user):
user_changed = True
if attp_user.get('email') and user.email != attp_user['email']: # Update email and username if provided
user.email = user.username = attp_user['last_name']
user.email = user.username = attp_user['email']
user_changed = True
if user_changed:
......
......@@ -20,6 +20,8 @@ def login(request):
:param attp_hash:
:return:
"""
if request.user.is_anonymous():
raise Http404()
token, _ = Token.objects.get_or_create(user=request.user)
return render(request, "adim_ttp/logged.html", context={'token': token})
......
......@@ -7,7 +7,7 @@
## ------------
Alias {{ settings.STATIC_URL }} "{{ settings.STATIC_ROOT }}/"
{% if favicon %}
Alias {{ settings.BASE_URL }}/favicon.ico "{{ settings.STATIC_ROOT }}/favicon.ico"
Alias {{ settings.BASE_URL }}favicon.ico "{{ settings.STATIC_ROOT }}/favicon.ico"
{% endif %}
<Directory "{{ settings.STATIC_ROOT }}">
Options +FollowSymLinks -Indexes
......@@ -83,7 +83,7 @@
{% if not NoDaemonProcess %}
WSGIDaemonProcess {{ daemon_process_name|default:settings.SITE_NAME }}.django user={{ apache_user|default:"www-data" }} group={{ apache_group|default:apache_user|default:"www-data" }}
{% endif %}
WSGIScriptAlias {{ settings.BASE_URL|default:"/" }} "{{ wsgi_path }}"
WSGIScriptAlias {{ wsgi_alias }} "{{ wsgi_path }}"
<Directory "{{ settings.DJANGO_ROOT }}">
WSGIProcessGroup {{ daemon_process_name|default:settings.SITE_NAME }}.django
WSGIPassAuthorization On
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment