Gitlab CSE Unil

Commit db6e193e authored by Julien Furrer's avatar Julien Furrer
Browse files

Merge branch 'small-dev' into dev

Conflicts:
	.gitignore
FIXED
parents 73c9676e 4e53ccb4
......@@ -8,3 +8,8 @@
**/*.old.jpg
screen_session_cmd
tmp/*
**/*-OFF
log/debug.log
.DS_Store
*.pyc
*.swp
*.bak
.idea
......@@ -12,11 +9,13 @@
/static
adim_project/apache.conf
adim_project/wsgi.py
adim_project/apache.conf*
adim_project/generate_apache_conf.py
adim_project/apache.conf.tpl
adim_app/playground.py
/templates/playground
adim_app/static/js/playground.js
adim_project/wsgi.example.py
adim_project/wsgi-off.py
\ No newline at end of file
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Generate Apache configuration based on templates found in templates/apache_config/**
"""
import os
import sys
import time
import django
from django.conf import settings
from django.template import Context
from django.template.loader import get_template
from django.utils import timezone
__TARGETS = ('local', 'production', 'staging')
def generate_apache_conf(target='local', quiet=True, yes=True):
config_tpl = get_template('apache_config/{}.conf'.format(target))
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'))
rendered = config_tpl.render(Context({
'settings': settings,
'is_robot': is_robot,
'is_favicon': is_favicon,
'wsgi_path': os.path.join(settings.SITE_ROOT, *settings.WSGI_APPLICATION.split('.')[:-1]) + '.py',
}))
# Cleanup blanklines
rendered_lines = rendered.split("\n")
rendered = []
lp = None
for i, l in enumerate(rendered_lines):
if not lp == l.strip() == "":
rendered.append(l)
lp = l.strip()
rendered = "\n".join(rendered)
output_filename = '{}.conf'.format(target)
output_path = os.path.join(settings.DJANGO_ROOT, 'apache', output_filename)
if os.path.exists(output_path) and not (yes or quiet):
r = raw_input("Config file «{}» already exists, overwrite ? [Y/n]".format(output_filename))
if r and r[0] not in ('Y', 'y'):
output_filename = '{0}-{1}.conf'.format(target, int(time.time()))
output_path = os.path.join(settings.DJANGO_ROOT, 'apache', output_filename)
with file(output_path, 'w') as output_file:
output_file.write(rendered)
if not quiet:
print "Saved target {0} as {1}".format(target, output_filename)
def main(quiet=True, yes=True, targets=None):
if not targets:
targets = __TARGETS
for target in targets:
generate_apache_conf(target=target, quiet=quiet, yes=yes)
# for tgt_conf in os.listdir(tpl_dir):
# if os.path.isfile(os.path.join(tpl_dir, tgt_conf)) and not tgt_conf.startswith('base'):
# generate_apache_conf(target=os.path.splitext(tgt_conf)[0])
if __name__ == "__main__":
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(os.path.dirname(__file__))))
sys.path.append(BASE_DIR)
django.setup()
args = sys.argv[:]
args.pop(0)
if '-h' in args:
print """
usage generate_config.py [-y] [-q] [target, target, ]
Params:
-y Force 'yes' if overwrite confirmation needed (not echoed)
-q Quiet, no output (implies -q)
target The name of the target to render. May have more. Must be at the end of the command line
"""
sys.exit(0)
main(
quiet='-q' in args,
yes='-y' in args,
targets=[t for t in args if not t.startswith('-')]
)
<IfModule wsgi_module>
## ------------
## Static paths
## ------------
Alias /static/ "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/static/"
<Directory "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/static">
Options +FollowSymLinks -Indexes
Order deny,allow
Allow from all
<IfModule expires_module>
ExpiresActive On
ExpiresDefault "access plus 10 minutes"
<IfModule headers_module>
Header append Cache-Control "public"
</IfModule>
</IfModule>
</Directory>
# ----------
# Media path
# ----------
Alias /media/ "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/media/"
<Directory "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/media">
Options +FollowSymLinks -Indexes
Order deny,allow
Allow from all
</Directory>
# ---------------
# Protected Media
# ---------------
<Directory "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/media/ao_images/">
Order allow,deny
Deny from all
# --------------
# XsendFile Conf
# --------------
<IfModule xsendfile_module>
XSendFile On
XSendFilePath "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/media"
</IfModule>
</Directory>
# ---------------
# Shibboleth Conf
# ---------------
<IfModule mod_shib>
<Location //shibauth/>
#Order allow,deny
#Allow from all
AuthType shibboleth
ShibRequireSession On
ShibRedirectToSSL 443
require uniqueID impossiblevaluehere@nowhere.org
require valid-user
</Location>
</IfModule>
# ---------
# WSGI conf
# ---------
WSGIDaemonProcess adim.django user=_www group=_www
WSGIScriptAlias / "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/adim_project/wsgi/local.py"
<Directory "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/adim_project">
WSGIProcessGroup adim.django
WSGIPassAuthorization On
<Files wsgi.py>
Order deny,allow
Allow from all
</Files>
</Directory>
</IfModule>
<IfModule wsgi_module>
## ------------
## Static paths
## ------------
Alias /static/ "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/static/"
<Directory "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/static">
Options +FollowSymLinks -Indexes
Order deny,allow
Allow from all
<IfModule expires_module>
ExpiresActive On
ExpiresDefault "access plus 10 minutes"
<IfModule headers_module>
Header append Cache-Control "public"
</IfModule>
</IfModule>
</Directory>
# ----------
# Media path
# ----------
Alias /media/ "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/media/"
<Directory "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/media">
Options +FollowSymLinks -Indexes
Order deny,allow
Allow from all
</Directory>
# ---------------
# Protected Media
# ---------------
<Directory "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/media/ao_images/">
Order allow,deny
Deny from all
# --------------
# XsendFile Conf
# --------------
<IfModule xsendfile_module>
XSendFile On
XSendFilePath "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/media"
</IfModule>
</Directory>
# ---------------
# Shibboleth Conf
# ---------------
<IfModule mod_shib>
<Location //shibauth/>
#Order allow,deny
#Allow from all
AuthType shibboleth
ShibRequireSession On
ShibRedirectToSSL 443
require uniqueID impossiblevaluehere@nowhere.org
require valid-user
</Location>
</IfModule>
</IfModule>
<IfModule wsgi_module>
## ------------
## Static paths
## ------------
Alias /static/ "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/static/"
<Directory "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/static">
Options +FollowSymLinks -Indexes
Order deny,allow
Allow from all
<IfModule expires_module>
ExpiresActive On
ExpiresDefault "access plus 10 minutes"
<IfModule headers_module>
Header append Cache-Control "public"
</IfModule>
</IfModule>
</Directory>
# ----------
# Media path
# ----------
Alias /media/ "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/media/"
<Directory "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/media">
Options +FollowSymLinks -Indexes
Order deny,allow
Allow from all
</Directory>
# ---------------
# Protected Media
# ---------------
<Directory "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/media/ao_images/">
Order allow,deny
Deny from all
# --------------
# XsendFile Conf
# --------------
<IfModule xsendfile_module>
XSendFile On
XSendFilePath "/Users/jfurrer/JOB/___RISET/PROJECTS/Misc/AnnotationDImage/workspace/adim.django/adim_project/media"
</IfModule>
</Directory>
# ---------------
# Shibboleth Conf
# ---------------
<IfModule mod_shib>
<Location //shibauth/>
#Order allow,deny
#Allow from all
AuthType shibboleth
ShibRequireSession On
ShibRedirectToSSL 443
require uniqueID impossiblevaluehere@nowhere.org
require valid-user
</Location>
</IfModule>
</IfModule>
......@@ -116,6 +116,7 @@ def update_urls(base_url=None, name=__name__):
this_module = modules[name]
if base_url is None:
base_url = getattr(this_module, 'BASE_URL', "/")
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))
......@@ -343,4 +344,4 @@ LOGGING = {
},
}
}
########## END LOGGING CONFIGURATION
\ No newline at end of file
########## END LOGGING CONFIGURATION
......@@ -8,6 +8,8 @@ TEMPLATE_DEBUG = TEMPLATES[0]['OPTIONS']['debug'] = True
ALLOWED_HOSTS = ['127.0.0.1', 'localhost', ]
WSGI_APPLICATION = '%s.wsgi.local.application' % SITE_NAME
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
......
from split_settings.tools import optional, include
include(
'components/base.py',
'components/database.py',
'components/rest_framework.py',
'components/adim.py',
'components/local_defaults.py',
optional('shib_settings.py'),
optional('local_settings.py'),
'components/urls.py',
'components/auth.py',
'components/paths.py',
scope=locals()
)
\ No newline at end of file
# Max filesize in Mb
ADIM_UPLOAD_MAX_FILESIZE = 50
# Size of the Thumbnail
ADIM_THUMB_SIZE = (150, 150)
# When in PROD, DEBUG_JS if False and uses prod ready css too
ADIM_PROD = True
# If True load the non-minified version of adim js
ADIM_DEBUG_JS = False
# If the number of suggested adim-user is less than this value,
# the ldap will be queried too
ADIM_SUGGESTION = {
'LIMIT': 7,
'LDAP': {
'URL': "ldap://ldap.unil.ch:389",
'BASE': "o=universite de lausanne, c=ch",
'TIMEOUT': 3
}
}
\ No newline at end of file
AUTHENTICATION_BACKENDS = (
'shibauth.shibbolethbackends.ShibbolethBackend',
'django.contrib.auth.backends.ModelBackend',
)
LOGIN_REDIRECT_URL = "adim.app:annotate-new"
LOGIN_URL = "adim.app:home"
SHIB_UID_ATTR = 'uniqueID'
SHIB_USERNAME_ATTR = 'mail'
SHIB_ATTR_MAP = {
'user': (
('first_name', 'givenName'),
('last_name', 'surname'),
('email', 'mail'),
),
'profile': (
('homeOrganization', 'homeOrganization'),
('uniqueID', 'uniqueID'),
)
}
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SESSION_COOKIE_PATH = BASE_URL
CSRF_COOKIE_PATH = BASE_URL
\ No newline at end of file
DEBUG = False
TEMPLATE_DEBUG = False
ALLOWED_HOSTS = []
INSTALLED_APPS = (
'django.contrib.sites',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django_extensions',
'rest_framework',
'shibauth',
'adim',
'adim_app',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.request',
'django.core.context_processors.tz',
'django.contrib.messages.context_processors.messages',
'adim_project.context_processors.default',
)
ROOT_URLCONF = 'adim_project.urls'
WSGI_APPLICATION = 'adim_project.wsgi.application'
# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/
LANGUAGE_CODE = 'fr-ch'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
SITE_ID = 1
\ No newline at end of file
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'adim_dev',
'USER': 'adim',
'HOST': 'localhost',
},
}
\ No newline at end of file
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
'LOCATION': '127.0.0.1:11211',
}
}
SENDFILE_BACKEND = 'sendfile.backends.xsendfile'
\ No newline at end of file
import os
try:
BASE_DIR = BASE_DIR
except NameError:
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Static Files
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
# Media files
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
\ No newline at end of file
REST_FRAMEWORK = {
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
),
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAuthenticated'
]
}
\ No newline at end of file
try:
BASE_URL
except NameError:
BASE_URL = '/'
# Static Files
STATIC_URL = '{}static/'.format(BASE_URL)
# Media files
MEDIA_URL = '{}media/'.format(BASE_URL)
"""
This file contains confidential data that shouldn't be versioned nor distributed
It SHOULD define at least the SECRET_KEY config value
"""
DEBUG = False
ALLOWED_HOSTS = ('127.0.0.1',)
SECRET_KEY = '< run ./manage.py generate_secret_key >'
try:
DATABASES['default']['PASSWORD'] = 'tagada'
except NameError:
pass
"""
This file contains confidential data that shouldn't be versioned nor distributed
It SHOULD define at least the SECRET_KEY config value
"""
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ALLOWED_HOSTS = ('127.0.0.1', )
SECRET_KEY = 'k+zjz_dc&6@yrppyzykv3c6qk1z-tmuestnfe=_zt&me@^m8%u'
try:
DATABASES['default']['PASSWORD'] = 'fsdkuz289r3jhkasdf987'
DATABASES['default']['HOST'] = '127.0.0.1'
except NameError:
pass
SENDFILE_BACKEND = 'sendfile.backends.development'
ADIM_DEBUG_JS = True
ADIM_PROD = False
AAI = {
'SLO': True,
# Not yet used
'URLS': {
'SP_LOGOUT': "https://jabba.unil.ch/Shibboleth.sso/Logout",
'idp_LOGOUT': "https://aai.unil.ch/idp/logout.jsp"
}
}
#INSTALLED_APPS += ( 'debug_toolbar', )
\ No newline at end of file
SHIB_ATTRIBUTES = {
'affiliation': 'affiliation'