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): ...@@ -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_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')) 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({ rendered = config_tpl.render(Context({
'settings': settings, 'settings': settings,
'is_robot': is_robot, 'is_robot': is_robot,
'is_favicon': is_favicon, 'is_favicon': is_favicon,
'wsgi_alias': wsgi_alias,
'wsgi_path': os.path.join(settings.SITE_ROOT, *settings.WSGI_APPLICATION.split('.')[:-1]) + '.py', '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__): ...@@ -119,8 +119,9 @@ def update_urls(base_url=None, name=__name__):
setattr(this_module, 'BASE_URL', base_url) setattr(this_module, 'BASE_URL', base_url)
setattr(this_module, 'SESSION_COOKIE_PATH', base_url) setattr(this_module, 'SESSION_COOKIE_PATH', base_url)
setattr(this_module, 'CSRF_COOKIE_PATH', base_url) setattr(this_module, 'CSRF_COOKIE_PATH', base_url)
setattr(this_module, 'MEDIA_URL', '{}/media/'.format(base_url)) setattr(this_module, 'MEDIA_URL', '{}media/'.format(base_url))
setattr(this_module, 'STATIC_URL', '{}/static/'.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("/") update_urls("/")
# ---------- END URL CONFIGURATION # ---------- END URL CONFIGURATION
...@@ -181,7 +182,7 @@ MIDDLEWARE_CLASSES.insert( ...@@ -181,7 +182,7 @@ MIDDLEWARE_CLASSES.insert(
) )
MIDDLEWARE_CLASSES += ('corsheaders.middleware.CorsMiddleware', ) MIDDLEWARE_CLASSES += ('corsheaders.middleware.CorsMiddleware', )
CORS_ORIGIN_ALLOW_ALL = True CORS_ORIGIN_ALLOW_ALL = True
CORS_URLS_REGEX = r'^/api/.*$' # CORS_URLS_REGEX = r'^.*/api/.*$'
# ..... ADIM # ..... ADIM
...@@ -237,7 +238,7 @@ ATTP = { ...@@ -237,7 +238,7 @@ ATTP = {
'CACHE_TIMEOUT': 20, # 30, 'CACHE_TIMEOUT': 20, # 30,
}, },
'moodle': { '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 'MODE_ID': 16
}, },
'toto': { 'toto': {
......
...@@ -4,7 +4,7 @@ Settings for production server ...@@ -4,7 +4,7 @@ Settings for production server
from .base import * from .base import *
update_urls('/adim', __name__) update_urls('/adim/', __name__)
ALLOWED_HOSTS = ['.unil.ch'] ALLOWED_HOSTS = ['.unil.ch']
......
...@@ -6,7 +6,7 @@ from .base import * ...@@ -6,7 +6,7 @@ from .base import *
DEBUG = True DEBUG = True
TEMPLATE_DEBUG = TEMPLATES[0]['OPTIONS']['debug'] = True TEMPLATE_DEBUG = TEMPLATES[0]['OPTIONS']['debug'] = True
update_urls('/adim-dev', __name__) update_urls('/adim-dev/', __name__)
ALLOWED_HOSTS = ['.unil.ch'] ALLOWED_HOSTS = ['.unil.ch']
......
...@@ -177,7 +177,7 @@ def get_or_create_user(attp_user): ...@@ -177,7 +177,7 @@ def get_or_create_user(attp_user):
user_changed = True user_changed = True
if attp_user.get('email') and user.email != attp_user['email']: # Update email and username if provided 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 user_changed = True
if user_changed: if user_changed:
......
...@@ -20,6 +20,8 @@ def login(request): ...@@ -20,6 +20,8 @@ def login(request):
:param attp_hash: :param attp_hash:
:return: :return:
""" """
if request.user.is_anonymous():
raise Http404()
token, _ = Token.objects.get_or_create(user=request.user) token, _ = Token.objects.get_or_create(user=request.user)
return render(request, "adim_ttp/logged.html", context={'token': token}) return render(request, "adim_ttp/logged.html", context={'token': token})
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
## ------------ ## ------------
Alias {{ settings.STATIC_URL }} "{{ settings.STATIC_ROOT }}/" Alias {{ settings.STATIC_URL }} "{{ settings.STATIC_ROOT }}/"
{% if favicon %} {% 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 %} {% endif %}
<Directory "{{ settings.STATIC_ROOT }}"> <Directory "{{ settings.STATIC_ROOT }}">
Options +FollowSymLinks -Indexes Options +FollowSymLinks -Indexes
...@@ -83,7 +83,7 @@ ...@@ -83,7 +83,7 @@
{% if not NoDaemonProcess %} {% 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" }} 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 %} {% endif %}
WSGIScriptAlias {{ settings.BASE_URL|default:"/" }} "{{ wsgi_path }}" WSGIScriptAlias {{ wsgi_alias }} "{{ wsgi_path }}"
<Directory "{{ settings.DJANGO_ROOT }}"> <Directory "{{ settings.DJANGO_ROOT }}">
WSGIProcessGroup {{ daemon_process_name|default:settings.SITE_NAME }}.django WSGIProcessGroup {{ daemon_process_name|default:settings.SITE_NAME }}.django
WSGIPassAuthorization On WSGIPassAuthorization On
......
Supports Markdown
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