Gitlab CSE Unil
Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
M. Chardon
ADIM
Commits
4e53ccb4
Commit
4e53ccb4
authored
Jun 08, 2015
by
Julien Furrer
Browse files
Adaptation configuration pour deploiement
parent
051d7fc1
Changes
29
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
4e53ccb4
...
...
@@ -9,3 +9,7 @@
screen_session_cmd
tmp/*
**/*-OFF
log/debug.log
\ No newline at end of file
adim_project/.gitignore
View file @
4e53ccb4
.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
adim_project/adim_project/apache/generate_config.py
0 → 100755
View file @
4e53ccb4
#!/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
(
'-'
)]
)
adim_project/adim_project/apache/local.conf
0 → 100644
View file @
4e53ccb4
<
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
>
adim_project/adim_project/apache/production.conf
0 → 100644
View file @
4e53ccb4
<
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
>
adim_project/adim_project/apache/staging.conf
0 → 100644
View file @
4e53ccb4
<
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
>
adim_project/adim_project/settings/base.py
View file @
4e53ccb4
...
...
@@ -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
))
...
...
adim_project/adim_project/settings/local.py
View file @
4e53ccb4
...
...
@@ -8,6 +8,8 @@ TEMPLATE_DEBUG = TEMPLATES[0]['OPTIONS']['debug'] = True
ALLOWED_HOSTS
=
[
'127.0.0.1'
,
]
WSGI_APPLICATION
=
'%s.wsgi.local.application'
%
SITE_NAME
DATABASES
=
{
'default'
:
{
'ENGINE'
:
'django.db.backends.mysql'
,
...
...
@@ -21,4 +23,4 @@ DATABASES = {
SENDFILE_BACKEND
=
'sendfile.backends.development'
ADIM_PROD
=
False
ADIM_DEBUG_JS
=
True
ADIM_DEBUG_JS
=
True
\ No newline at end of file
adim_project/adim_project/settings_o/__init__.py
deleted
100644 → 0
View file @
051d7fc1
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
adim_project/adim_project/settings_o/components/adim.py
deleted
100644 → 0
View file @
051d7fc1
# 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
adim_project/adim_project/settings_o/components/auth.py
deleted
100644 → 0
View file @
051d7fc1
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
adim_project/adim_project/settings_o/components/base.py
deleted
100644 → 0
View file @
051d7fc1
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
adim_project/adim_project/settings_o/components/database.py
deleted
100644 → 0
View file @
051d7fc1
DATABASES
=
{
'default'
:
{
'ENGINE'
:
'django.db.backends.mysql'
,
'NAME'
:
'adim_dev'
,
'USER'
:
'adim'
,
'HOST'
:
'localhost'
,
},
}
\ No newline at end of file
adim_project/adim_project/settings_o/components/local_defaults.py
deleted
100644 → 0
View file @
051d7fc1
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
adim_project/adim_project/settings_o/components/paths.py
deleted
100644 → 0
View file @
051d7fc1
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
adim_project/adim_project/settings_o/components/rest_framework.py
deleted
100644 → 0
View file @
051d7fc1
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
adim_project/adim_project/settings_o/components/urls.py
deleted
100644 → 0
View file @
051d7fc1
try
:
BASE_URL
except
NameError
:
BASE_URL
=
'/'
# Static Files
STATIC_URL
=
'{}static/'
.
format
(
BASE_URL
)
# Media files
MEDIA_URL
=
'{}media/'
.
format
(
BASE_URL
)
adim_project/adim_project/settings_o/local_settings.example.py
deleted
100644 → 0
View file @
051d7fc1
"""
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
adim_project/adim_project/settings_o/local_settings.py
deleted
100644 → 0
View file @
051d7fc1
"""
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
adim_project/adim_project/settings_o/shib_settings.py
deleted
100644 → 0
View file @
051d7fc1