]> git.parisson.com Git - mezzo.git/commitdiff
refactor app
authorGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Tue, 19 Apr 2016 10:20:50 +0000 (12:20 +0200)
committerGuillaume Pellerin <guillaume.pellerin@ircam.fr>
Tue, 19 Apr 2016 10:20:50 +0000 (12:20 +0200)
27 files changed:
app/deploy/crontab.template [deleted file]
app/deploy/gunicorn.conf.py.template [deleted file]
app/deploy/local_settings.py.template [deleted file]
app/deploy/my.cnf [deleted file]
app/deploy/nginx-app.conf [deleted file]
app/deploy/nginx.conf.template [deleted file]
app/deploy/start_app.sh [deleted file]
app/deploy/wait.sh [deleted file]
app/local_settings.py [new file with mode: 0644]
app/manage.py
app/middleware.py [new file with mode: 0644]
app/routers.py [new file with mode: 0644]
app/sandbox/__init__.py [deleted file]
app/sandbox/local_settings.py [deleted file]
app/sandbox/middleware.py [deleted file]
app/sandbox/routers.py [deleted file]
app/sandbox/settings.py [deleted file]
app/sandbox/urls.py [deleted file]
app/scripts/app.sh [new file with mode: 0644]
app/scripts/wait.sh [new file with mode: 0644]
app/settings.py [new file with mode: 0644]
app/urls.py [new file with mode: 0644]
app/wait.py
app/wsgi.py
docker-compose.yml
env/dev.yml
etc/nginx.conf [new file with mode: 0644]

diff --git a/app/deploy/crontab.template b/app/deploy/crontab.template
deleted file mode 100644 (file)
index c4af8cf..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-# Poll Twitter every 5 minutes
-# Comment-out if you don't use Mezzanine's Twitter app
-*/5 * * * * %(user)s %(manage)s poll_twitter
diff --git a/app/deploy/gunicorn.conf.py.template b/app/deploy/gunicorn.conf.py.template
deleted file mode 100644 (file)
index 257bb97..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-from __future__ import unicode_literals
-import multiprocessing
-
-bind = "unix:%(proj_path)s/gunicorn.sock"
-workers = %(num_workers)s
-errorlog = "/home/%(user)s/logs/%(proj_name)s_error.log"
-loglevel = "error"
-proc_name = "%(proj_name)s"
diff --git a/app/deploy/local_settings.py.template b/app/deploy/local_settings.py.template
deleted file mode 100644 (file)
index d8dc9a0..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-from __future__ import unicode_literals
-
-SECRET_KEY = "%(secret_key)s"
-NEVERCACHE_KEY = "%(nevercache_key)s"
-ALLOWED_HOSTS = [%(domains_python)s]
-
-DATABASES = {
-    "default": {
-        # Ends with "postgresql_psycopg2", "mysql", "sqlite3" or "oracle".
-        "ENGINE": "django.db.backends.postgresql_psycopg2",
-        # DB name or path to database file if using sqlite3.
-        "NAME": "%(proj_name)s",
-        # Not used with sqlite3.
-        "USER": "%(proj_name)s",
-        # Not used with sqlite3.
-        "PASSWORD": "%(db_pass)s",
-        # Set to empty string for localhost. Not used with sqlite3.
-        "HOST": "127.0.0.1",
-        # Set to empty string for default. Not used with sqlite3.
-        "PORT": "",
-    }
-}
-
-SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTOCOL", "https")
-
-CACHE_MIDDLEWARE_SECONDS = 60
-
-CACHE_MIDDLEWARE_KEY_PREFIX = "%(proj_name)s"
-
-CACHES = {
-    "default": {
-        "BACKEND": "django.core.cache.backends.memcached.MemcachedCache",
-        "LOCATION": "127.0.0.1:11211",
-    }
-}
-
-SESSION_ENGINE = "django.contrib.sessions.backends.cache"
diff --git a/app/deploy/my.cnf b/app/deploy/my.cnf
deleted file mode 100644 (file)
index 7d10856..0000000
+++ /dev/null
@@ -1,193 +0,0 @@
-# MariaDB database server configuration file.
-#
-# You can copy this file to one of:
-# - "/etc/mysql/my.cnf" to set global options,
-# - "~/.my.cnf" to set user-specific options.
-#
-# One can use all long options that the program supports.
-# Run program with --help to get a list of available options and with
-# --print-defaults to see which it would actually understand and use.
-#
-# For explanations see
-# http://dev.mysql.com/doc/mysql/en/server-system-variables.html
-
-# This will be passed to all mysql clients
-# It has been reported that passwords should be enclosed with ticks/quotes
-# escpecially if they contain "#" chars...
-# Remember to edit /etc/mysql/debian.cnf when changing the socket location.
-[client]
-port           = 3306
-socket         = /var/run/mysqld/mysqld.sock
-
-# Here is entries for some specific programs
-# The following values assume you have at least 32M ram
-
-# This was formally known as [safe_mysqld]. Both versions are currently parsed.
-[mysqld_safe]
-socket         = /var/run/mysqld/mysqld.sock
-nice           = 0
-
-[mysqld]
-skip-host-cache
-skip-name-resolve
-#
-# * Basic Settings
-#
-user           = mysql
-pid-file       = /var/run/mysqld/mysqld.pid
-socket         = /var/run/mysqld/mysqld.sock
-port           = 3306
-basedir                = /usr
-datadir                = /var/lib/mysql
-tmpdir         = /tmp
-lc_messages_dir        = /usr/share/mysql
-lc_messages    = en_US
-skip-external-locking
-#
-# Instead of skip-networking the default is now to listen only on
-# localhost which is more compatible and is not less secure.
-
-bind-address           = 0.0.0.0
-
-#
-# * Fine Tuning
-#
-max_connections                = 100
-connect_timeout                = 5
-wait_timeout           = 600
-max_allowed_packet     = 16M
-thread_cache_size       = 128
-sort_buffer_size       = 4M
-bulk_insert_buffer_size        = 16M
-tmp_table_size         = 32M
-max_heap_table_size    = 32M
-#
-# * MyISAM
-#
-# This replaces the startup script and checks MyISAM tables if needed
-# the first time they are touched. On error, make copy and try a repair.
-myisam_recover_options = BACKUP
-key_buffer_size                = 128M
-#open-files-limit      = 2000
-table_open_cache       = 400
-myisam_sort_buffer_size        = 512M
-concurrent_insert      = 2
-read_buffer_size       = 2M
-read_rnd_buffer_size   = 1M
-#
-# * Query Cache Configuration
-#
-# Cache only tiny result sets, so we can fit more in the query cache.
-query_cache_limit              = 128K
-query_cache_size               = 64M
-# for more write intensive setups, set to DEMAND or OFF
-#query_cache_type              = DEMAND
-#
-# * Logging and Replication
-#
-# Both location gets rotated by the cronjob.
-# Be aware that this log type is a performance killer.
-# As of 5.1 you can enable the log at runtime!
-#general_log_file        = /var/log/mysql/mysql.log
-#general_log             = 1
-#
-# Error logging goes to syslog due to /etc/mysql/conf.d/mysqld_safe_syslog.cnf.
-#
-# we do want to know about network errors and such
-#log_warnings          = 2
-#
-# Enable the slow query log to see queries with especially long duration
-#slow_query_log[={0|1}]
-slow_query_log_file    = /var/log/mysql/mariadb-slow.log
-long_query_time = 10
-#log_slow_rate_limit   = 1000
-#log_slow_verbosity    = query_plan
-
-#log-queries-not-using-indexes
-#log_slow_admin_statements
-#
-# The following can be used as easy to replay backup logs or for replication.
-# note: if you are setting up a replication slave, see README.Debian about
-#       other settings you may need to change.
-#server-id             = 1
-#report_host           = master1
-#auto_increment_increment = 2
-#auto_increment_offset = 1
-#log_bin                       = /var/log/mysql/mariadb-bin
-#log_bin_index         = /var/log/mysql/mariadb-bin.index
-# not fab for performance, but safer
-#sync_binlog           = 1
-expire_logs_days       = 10
-max_binlog_size         = 100M
-# slaves
-#relay_log             = /var/log/mysql/relay-bin
-#relay_log_index       = /var/log/mysql/relay-bin.index
-#relay_log_info_file   = /var/log/mysql/relay-bin.info
-#log_slave_updates
-#read_only
-#
-# If applications support it, this stricter sql_mode prevents some
-# mistakes like inserting invalid dates etc.
-#sql_mode              = NO_ENGINE_SUBSTITUTION,TRADITIONAL
-#
-# * InnoDB
-#
-# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/.
-# Read the manual for more InnoDB related options. There are many!
-default_storage_engine = InnoDB
-# you can't just change log file size, requires special procedure
-#innodb_log_file_size  = 50M
-innodb_buffer_pool_size        = 256M
-innodb_log_buffer_size = 8M
-innodb_file_per_table  = 1
-innodb_open_files      = 400
-innodb_io_capacity     = 400
-innodb_flush_method    = O_DIRECT
-#
-# * Security Features
-#
-# Read the manual, too, if you want chroot!
-# chroot = /var/lib/mysql/
-#
-# For generating SSL certificates I recommend the OpenSSL GUI "tinyca".
-#
-# ssl-ca=/etc/mysql/cacert.pem
-# ssl-cert=/etc/mysql/server-cert.pem
-# ssl-key=/etc/mysql/server-key.pem
-
-#
-# * Galera-related settings
-#
-[galera]
-# Mandatory settings
-#wsrep_on=ON
-#wsrep_provider=
-#wsrep_cluster_address=
-#binlog_format=row
-#default_storage_engine=InnoDB
-#innodb_autoinc_lock_mode=2
-#
-# Allow server to accept connections on all interfaces.
-#
-#bind-address=0.0.0.0
-#
-# Optional setting
-#wsrep_slave_threads=1
-#innodb_flush_log_at_trx_commit=0
-
-[mysqldump]
-quick
-quote-names
-max_allowed_packet     = 16M
-
-[mysql]
-#no-auto-rehash        # faster start of mysql but no tab completition
-
-[isamchk]
-key_buffer             = 16M
-
-#
-# * IMPORTANT: Additional settings that can override those from this file!
-#   The files must end with '.cnf', otherwise they'll be ignored.
-#
-!includedir /etc/mysql/conf.d/
diff --git a/app/deploy/nginx-app.conf b/app/deploy/nginx-app.conf
deleted file mode 100644 (file)
index 3f89e87..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-server_tokens off;
-
-server {
-       listen 80;
-       server_name messiaen.ircam.fr nginx;
-       charset utf-8;
-
-       access_log /var/log/nginx/app-access.log;
-       error_log /var/log/nginx/app-error.log;
-
-       # max upload size
-       client_max_body_size 4096M; # adjust to taste
-
-       # Django media
-       location /media {
-                       alias /srv/media; # your Django project's media files - amend as required
-       }
-       # Django static
-       location /static {
-               alias /srv/static; # your Django project's static files - amend as required
-       }
-
-       location / {
-            uwsgi_pass app:8000;
-            include /etc/nginx/uwsgi_params;
-       }
-}
diff --git a/app/deploy/nginx.conf.template b/app/deploy/nginx.conf.template
deleted file mode 100644 (file)
index f99430a..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-
-upstream %(proj_name)s {
-    server unix:%(proj_path)s/gunicorn.sock fail_timeout=0;
-}
-
-server {
-
-    listen 80;
-    %(ssl_disabled)s listen 443 ssl;
-    server_name %(domains_nginx)s;
-    client_max_body_size 10M;
-    keepalive_timeout    15;
-    error_log /home/%(user)s/logs/%(proj_name)s_error_nginx.log info;
-
-    %(ssl_disabled)s ssl_certificate      conf/%(proj_name)s.crt;
-    %(ssl_disabled)s ssl_certificate_key  conf/%(proj_name)s.key;
-    %(ssl_disabled)s ssl_session_cache    shared:SSL:10m;
-    %(ssl_disabled)s ssl_session_timeout  10m;
-    %(ssl_disabled)s ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA;
-    %(ssl_disabled)s ssl_prefer_server_ciphers on;
-
-    # Deny illegal Host headers
-    if ($host !~* ^(%(domains_regex)s)$) {
-        return 444;
-    }
-
-    location / {
-        proxy_redirect      off;
-        proxy_set_header    Host                    $host;
-        proxy_set_header    X-Real-IP               $remote_addr;
-        proxy_set_header    X-Forwarded-For         $proxy_add_x_forwarded_for;
-        proxy_set_header    X-Forwarded-Protocol    $scheme;
-        proxy_pass          http://%(proj_name)s;
-    }
-
-    location /static/ {
-        root            %(proj_path)s;
-        access_log      off;
-        log_not_found   off;
-        expires 30d;
-    }
-
-    location /robots.txt {
-        root            %(proj_path)s/static;
-        access_log      off;
-        log_not_found   off;
-    }
-
-    location /favicon.ico {
-        root            %(proj_path)s/static/img;
-        access_log      off;
-        log_not_found   off;
-    }
-
-}
diff --git a/app/deploy/start_app.sh b/app/deploy/start_app.sh
deleted file mode 100644 (file)
index 320752d..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/bin/sh
-
-# paths
-app='/srv/app'
-manage=$app'/manage.py'
-wsgi=$app'/wsgi.py'
-static='/srv/static/'
-media='/srv/media/'
-src='/srv/src/'
-
-# uwsgi params
-port=8000
-processes=2
-threads=2
-autoreload=3
-uid='www-data'
-gid='www-data'
-patterns='*.js;*.css;*.jpg;*.jpeg;*.gif;*.png;*.svg;*.ttf;*.eot;*.woff;*.woff2'
-
-# Staging
-# pip install psycopg2
-# pip install -U https://forge.ircam.fr/p/django-eve/source/download/dev/
-
-chown -R $uid:$gid $media
-
-# waiting for other services
-sh $app/deploy/wait.sh
-
-# waiting for available database
-# python $app/wait.py
-# python $manage wait-for-db-connection
-
-# django init
-# python $manage syncdb --noinput
-python $manage migrate --noinput
-python $manage collectstatic --noinput
-python $manage create-admin-user
-
-# app start
-if [ $1 = "--runserver" ]
-then
-    python $manage runserver 0.0.0.0:8000
-else
-    # static files auto update
-    watchmedo shell-command --patterns="$patterns" --recursive \
-        --command='python '$manage' collectstatic --noinput' $app &
-
-    uwsgi --socket :$port --wsgi-file $wsgi --chdir $app --master \
-    --processes $processes --threads $threads \
-    --uid $uid --gid $gid \
-    --py-autoreload $autoreload
-fi
diff --git a/app/deploy/wait.sh b/app/deploy/wait.sh
deleted file mode 100644 (file)
index 202c4d1..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-
-set -e
-
-host=$(env | grep _TCP_ADDR | cut -d = -f 2)
-port=$(env | grep _TCP_PORT | cut -d = -f 2)
-
-echo -n "waiting for TCP connection to $host:$port..."
-
-while ! nc -w 1 $host $port 2>/dev/null
-do
-  echo -n .
-  sleep 1
-done
-
-echo 'ok'
diff --git a/app/local_settings.py b/app/local_settings.py
new file mode 100644 (file)
index 0000000..31e9a42
--- /dev/null
@@ -0,0 +1,109 @@
+import os
+from django.utils.translation import ugettext_lazy as _
+
+DEBUG = True if os.environ.get('DEBUG', 'True') else False
+
+# Make these unique, and don't share it with anybody.
+SECRET_KEY = "+3b01&_6_m@@yb4f06$s0zno8vkybh81nbuj_q(xzk+xeih1+s"
+NEVERCACHE_KEY = "l11tr%#!uc@+%$51(&+%=&z6h9yrw42(jpcj$3_&6evtu6hl%z"
+
+# DATABASE_ROUTERS = ['eve.routers.EveRouter', 'festival.routers.FestivalRouter',]
+# DATABASE_ROUTERS = ['eve.routers.EveRouter',]
+
+DATABASES = {
+    'default': {
+     'ENGINE': 'django.db.backends.mysql',  # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
+         'USER': os.environ.get('DB_ENV_MYSQL_USER'),      # Not used with sqlite3.
+         'PASSWORD': os.environ.get('DB_ENV_MYSQL_PASSWORD'),  # Not used with sqlite3.
+         'NAME': os.environ.get('DB_ENV_MYSQL_DATABASE'),
+         'HOST': 'db',      # Set to empty string for localhost. Not used with sqlite3.
+         'PORT': '3306',      # Set to empty string for default. Not used with sqlite3.
+    },
+    'eve': {
+        'ENGINE': 'django.db.backends.postgresql_psycopg2',
+        'NAME': 'eve',
+        'USER': 'eve',
+        'PASSWORD': 'HmazS2frT',
+        'HOST': 'pgdb',
+        'PORT': '5432',
+    },
+    #'eve': {
+    #     'ENGINE': 'django.db.backends.postgresql_psycopg2',
+    #     'NAME': 'eve',
+    #     'USER': 'django',
+    #     'PASSWORD': 'q2nqzt0WGnwWé,256',
+    #     'HOST': 'eve.ircam.fr',
+    #     'PORT': '5432',
+    #},
+
+}
+
+DATABASE_ROUTERS = ['eve.routers.EveRouter',]
+
+
+# EXTENSIONS AND FORMATS
+# Allowed Extensions for File Upload. Lower case is important.
+FILEBROWSER_EXTENSIONS = {
+    'Folder': [''],
+    'Image': ['.jpg', '.jpeg', '.gif', '.png', '.tif', '.tiff'],
+    'Document': ['.pdf', '.doc', '.rtf', '.txt', '.xls', '.csv', '.docx'],
+    'Video': ['.mov', '.wmv', '.mpeg', '.mpg', '.avi', '.rm'],
+    'Audio': ['.mp3', '.mp4', '.wav', '.aiff', '.midi', '.m4p']
+    }
+
+# Define different formats for allowed selections.
+# This has to be a subset of EXTENSIONS.
+# e.g., add ?type=image to the browse-URL ...
+FILEBROWSER_SELECT_FORMATS = {
+    'File': ['Folder', 'Document'],
+    'Image': ['Image'],
+    'Media': ['Video', 'Audio'],
+    'Audio': ['Audio'],
+    'Document': ['Document'],
+    # for TinyMCE we can also define lower-case items
+    'image': ['Image'],
+    'file': ['Folder', 'Image', 'Document'],
+    'media': ['Video', 'Audio'],
+    'audio': ['Audio'],
+}
+
+EMAIL_HOST = 'smtp.ircam.fr'
+EMAIL_PORT = '25'
+DEFAULT_FROM_EMAIL = 'manifeste2016@ircam.fr'
+EMAIL_SUBJECT_PREFIX = "IRCAM Manifeste 2016"
+
+SITE_TITLE = 'Manifeste 2016'
+SITE_TAGLINE = 'Festival 2 juin | 2 juillet 2016'
+
+SILENCED_SYSTEM_CHECKS = ['fields.W342',]
+
+ADMIN_MENU_ORDER = (
+    (_("Content"), ("pages.Page", "blog.BlogPost", "mezzanine_agenda.Event",
+        "festival.Artist", "festival.Video", "festival.Audio", "festival.Playlist",
+        "festival.Featured",
+        "generic.ThreadedComment", (_("Media Library"), "fb_browse"),)),
+    (_("Site"), ("sites.Site", "redirects.Redirect", "conf.Setting")),
+    (_("Users"), ("auth.User", "auth.Group",)),
+    (_("Festival"), ("mezzanine_agenda.EventLocation",
+        "mezzanine_agenda.EventCategory", "mezzanine_agenda.EventPrice",
+        "festival.PageCategory",)),
+)
+
+SEARCH_MODEL_CHOICES = ()
+
+RATINGS_ACCOUNT_REQUIRED = True
+
+import warnings
+warnings.filterwarnings(
+        'ignore', r"DateTimeField .* received a naive datetime",
+        RuntimeWarning, r'django\.db\.models\.fields')
+
+EVENT_GOOGLE_MAPS_DOMAIN = 'maps.google.fr'
+EVENT_PER_PAGE = 50
+EVENT_USE_FEATURED_IMAGE = True
+EVENT_SHOP_URL = 'http://eve.ircam.fr/manifeste.php/manifestation/'
+EVENT_PASS_URL = 'http://eve.ircam.fr/manifeste.php/pass/'
+
+TINYMCE_SETUP_JS = "/static/js/tinymce_setup.js"
+
+SLUGIFY = 'django.template.defaultfilters.slugify'
index 7102e85fae05cc03561e79cd916cd4c2e542593c..87ab2e2dbb3d3a08f23b18d2dc76a29cf16e6f69 100755 (executable)
@@ -3,12 +3,6 @@ import os
 import sys
 
 if __name__ == "__main__":
-
-    from mezzanine.utils.conf import real_project_name
-
-    settings_module = "%s.settings" % real_project_name("sandbox")
-    os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings_module)
-
+    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
     from django.core.management import execute_from_command_line
-
     execute_from_command_line(sys.argv)
diff --git a/app/middleware.py b/app/middleware.py
new file mode 100644 (file)
index 0000000..43a158a
--- /dev/null
@@ -0,0 +1,22 @@
+from django.core.exceptions import MiddlewareNotUsed
+from django.conf import settings
+from django.core.management import call_command
+
+
+class StartupMiddleware(object):
+
+    def __init__(self):
+        up = False
+        print 'check..................................'
+        while not up:
+            try:
+                # # The following db settings name is django 1.2.  django < 1.2 will use settings.DATABASE_NAME
+                # if settings.DATABASES['default']['NAME'] == ':memory:':
+                call_command('syncdb', interactive=False)
+                call_command('collectstatic', interactive=False)
+                up = True
+            except:
+                print 'waiting...'
+                time.sleep(1)
+
+        raise MiddlewareNotUsed('Startup complete')
diff --git a/app/routers.py b/app/routers.py
new file mode 100644 (file)
index 0000000..7766b6d
--- /dev/null
@@ -0,0 +1,35 @@
+
+
+class Router(object):
+    """
+    A router to control all database operations between the 2 apps
+    """
+    def db_for_read(self, model, **hints):
+        if model._meta.app_label == 'eve':
+            return 'eve'
+        if model._meta.app_label == 'presta':
+            return 'presta'
+        return None
+
+    def db_for_write(self, model, **hints):
+        if model._meta.app_label == 'eve':
+            return 'eve'
+        if model._meta.app_label == 'presta':
+            return 'presta'
+        return None
+
+    def allow_relation(self, obj1, obj2, **hints):
+        if obj1._meta.app_label == 'eve' or \
+           obj2._meta.app_label == 'eve':
+           return True
+        if obj1._meta.app_label == 'presta' or \
+           obj2._meta.app_label == 'presta':
+           return True
+        return None
+
+    def allow_migrate(self, db, app_label, model=None, **hints):
+        if app_label == 'eve':
+            return db == 'eve'
+        if app_label == 'presta':
+            return db == 'presta'
+        return None
diff --git a/app/sandbox/__init__.py b/app/sandbox/__init__.py
deleted file mode 100644 (file)
index e69de29..0000000
diff --git a/app/sandbox/local_settings.py b/app/sandbox/local_settings.py
deleted file mode 100644 (file)
index 31e9a42..0000000
+++ /dev/null
@@ -1,109 +0,0 @@
-import os
-from django.utils.translation import ugettext_lazy as _
-
-DEBUG = True if os.environ.get('DEBUG', 'True') else False
-
-# Make these unique, and don't share it with anybody.
-SECRET_KEY = "+3b01&_6_m@@yb4f06$s0zno8vkybh81nbuj_q(xzk+xeih1+s"
-NEVERCACHE_KEY = "l11tr%#!uc@+%$51(&+%=&z6h9yrw42(jpcj$3_&6evtu6hl%z"
-
-# DATABASE_ROUTERS = ['eve.routers.EveRouter', 'festival.routers.FestivalRouter',]
-# DATABASE_ROUTERS = ['eve.routers.EveRouter',]
-
-DATABASES = {
-    'default': {
-     'ENGINE': 'django.db.backends.mysql',  # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
-         'USER': os.environ.get('DB_ENV_MYSQL_USER'),      # Not used with sqlite3.
-         'PASSWORD': os.environ.get('DB_ENV_MYSQL_PASSWORD'),  # Not used with sqlite3.
-         'NAME': os.environ.get('DB_ENV_MYSQL_DATABASE'),
-         'HOST': 'db',      # Set to empty string for localhost. Not used with sqlite3.
-         'PORT': '3306',      # Set to empty string for default. Not used with sqlite3.
-    },
-    'eve': {
-        'ENGINE': 'django.db.backends.postgresql_psycopg2',
-        'NAME': 'eve',
-        'USER': 'eve',
-        'PASSWORD': 'HmazS2frT',
-        'HOST': 'pgdb',
-        'PORT': '5432',
-    },
-    #'eve': {
-    #     'ENGINE': 'django.db.backends.postgresql_psycopg2',
-    #     'NAME': 'eve',
-    #     'USER': 'django',
-    #     'PASSWORD': 'q2nqzt0WGnwWé,256',
-    #     'HOST': 'eve.ircam.fr',
-    #     'PORT': '5432',
-    #},
-
-}
-
-DATABASE_ROUTERS = ['eve.routers.EveRouter',]
-
-
-# EXTENSIONS AND FORMATS
-# Allowed Extensions for File Upload. Lower case is important.
-FILEBROWSER_EXTENSIONS = {
-    'Folder': [''],
-    'Image': ['.jpg', '.jpeg', '.gif', '.png', '.tif', '.tiff'],
-    'Document': ['.pdf', '.doc', '.rtf', '.txt', '.xls', '.csv', '.docx'],
-    'Video': ['.mov', '.wmv', '.mpeg', '.mpg', '.avi', '.rm'],
-    'Audio': ['.mp3', '.mp4', '.wav', '.aiff', '.midi', '.m4p']
-    }
-
-# Define different formats for allowed selections.
-# This has to be a subset of EXTENSIONS.
-# e.g., add ?type=image to the browse-URL ...
-FILEBROWSER_SELECT_FORMATS = {
-    'File': ['Folder', 'Document'],
-    'Image': ['Image'],
-    'Media': ['Video', 'Audio'],
-    'Audio': ['Audio'],
-    'Document': ['Document'],
-    # for TinyMCE we can also define lower-case items
-    'image': ['Image'],
-    'file': ['Folder', 'Image', 'Document'],
-    'media': ['Video', 'Audio'],
-    'audio': ['Audio'],
-}
-
-EMAIL_HOST = 'smtp.ircam.fr'
-EMAIL_PORT = '25'
-DEFAULT_FROM_EMAIL = 'manifeste2016@ircam.fr'
-EMAIL_SUBJECT_PREFIX = "IRCAM Manifeste 2016"
-
-SITE_TITLE = 'Manifeste 2016'
-SITE_TAGLINE = 'Festival 2 juin | 2 juillet 2016'
-
-SILENCED_SYSTEM_CHECKS = ['fields.W342',]
-
-ADMIN_MENU_ORDER = (
-    (_("Content"), ("pages.Page", "blog.BlogPost", "mezzanine_agenda.Event",
-        "festival.Artist", "festival.Video", "festival.Audio", "festival.Playlist",
-        "festival.Featured",
-        "generic.ThreadedComment", (_("Media Library"), "fb_browse"),)),
-    (_("Site"), ("sites.Site", "redirects.Redirect", "conf.Setting")),
-    (_("Users"), ("auth.User", "auth.Group",)),
-    (_("Festival"), ("mezzanine_agenda.EventLocation",
-        "mezzanine_agenda.EventCategory", "mezzanine_agenda.EventPrice",
-        "festival.PageCategory",)),
-)
-
-SEARCH_MODEL_CHOICES = ()
-
-RATINGS_ACCOUNT_REQUIRED = True
-
-import warnings
-warnings.filterwarnings(
-        'ignore', r"DateTimeField .* received a naive datetime",
-        RuntimeWarning, r'django\.db\.models\.fields')
-
-EVENT_GOOGLE_MAPS_DOMAIN = 'maps.google.fr'
-EVENT_PER_PAGE = 50
-EVENT_USE_FEATURED_IMAGE = True
-EVENT_SHOP_URL = 'http://eve.ircam.fr/manifeste.php/manifestation/'
-EVENT_PASS_URL = 'http://eve.ircam.fr/manifeste.php/pass/'
-
-TINYMCE_SETUP_JS = "/static/js/tinymce_setup.js"
-
-SLUGIFY = 'django.template.defaultfilters.slugify'
diff --git a/app/sandbox/middleware.py b/app/sandbox/middleware.py
deleted file mode 100644 (file)
index 43a158a..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-from django.core.exceptions import MiddlewareNotUsed
-from django.conf import settings
-from django.core.management import call_command
-
-
-class StartupMiddleware(object):
-
-    def __init__(self):
-        up = False
-        print 'check..................................'
-        while not up:
-            try:
-                # # The following db settings name is django 1.2.  django < 1.2 will use settings.DATABASE_NAME
-                # if settings.DATABASES['default']['NAME'] == ':memory:':
-                call_command('syncdb', interactive=False)
-                call_command('collectstatic', interactive=False)
-                up = True
-            except:
-                print 'waiting...'
-                time.sleep(1)
-
-        raise MiddlewareNotUsed('Startup complete')
diff --git a/app/sandbox/routers.py b/app/sandbox/routers.py
deleted file mode 100644 (file)
index 7766b6d..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-
-
-class Router(object):
-    """
-    A router to control all database operations between the 2 apps
-    """
-    def db_for_read(self, model, **hints):
-        if model._meta.app_label == 'eve':
-            return 'eve'
-        if model._meta.app_label == 'presta':
-            return 'presta'
-        return None
-
-    def db_for_write(self, model, **hints):
-        if model._meta.app_label == 'eve':
-            return 'eve'
-        if model._meta.app_label == 'presta':
-            return 'presta'
-        return None
-
-    def allow_relation(self, obj1, obj2, **hints):
-        if obj1._meta.app_label == 'eve' or \
-           obj2._meta.app_label == 'eve':
-           return True
-        if obj1._meta.app_label == 'presta' or \
-           obj2._meta.app_label == 'presta':
-           return True
-        return None
-
-    def allow_migrate(self, db, app_label, model=None, **hints):
-        if app_label == 'eve':
-            return db == 'eve'
-        if app_label == 'presta':
-            return db == 'presta'
-        return None
diff --git a/app/sandbox/settings.py b/app/sandbox/settings.py
deleted file mode 100644 (file)
index e628545..0000000
+++ /dev/null
@@ -1,330 +0,0 @@
-
-from __future__ import absolute_import, unicode_literals
-import os
-from django.utils.translation import ugettext_lazy as _
-
-######################
-# MEZZANINE SETTINGS #
-######################
-
-# The following settings are already defined with default values in
-# the ``defaults.py`` module within each of Mezzanine's apps, but are
-# common enough to be put here, commented out, for conveniently
-# overriding. Please consult the settings documentation for a full list
-# of settings Mezzanine implements:
-# http://mezzanine.jupo.org/docs/configuration.html#default-settings
-
-# Controls the ordering and grouping of the admin menu.
-#
-# ADMIN_MENU_ORDER = (
-#     ("Content", ("pages.Page", "blog.BlogPost",
-#        "generic.ThreadedComment", (_("Media Library"), "fb_browse"),)),
-#     (_("Shop"), ("shop.Product", "shop.ProductOption", "shop.DiscountCode",
-#        "shop.Sale", "shop.Order")),
-#     ("Site", ("sites.Site", "redirects.Redirect", "conf.Setting")),
-#     ("Users", ("auth.User", "auth.Group",)),
-# )
-
-# A three item sequence, each containing a sequence of template tags
-# used to render the admin dashboard.
-#
-# DASHBOARD_TAGS = (
-#     ("blog_tags.quick_blog", "mezzanine_tags.app_list"),
-#     ("comment_tags.recent_comments",),
-#     ("mezzanine_tags.recent_actions",),
-# )
-
-# A sequence of templates used by the ``page_menu`` template tag. Each
-# item in the sequence is a three item sequence, containing a unique ID
-# for the template, a label for the template, and the template path.
-# These templates are then available for selection when editing which
-# menus a page should appear in. Note that if a menu template is used
-# that doesn't appear in this setting, all pages will appear in it.
-
-PAGE_MENU_TEMPLATES = (
-    (1, _("Top navigation bar"), "pages/menus/dropdown.html"),
-    # (2, _("Left-hand tree"), "pages/menus/tree.html"),
-    (2, _("Footer"), "pages/menus/footer.html"),
-)
-
-# A sequence of fields that will be injected into Mezzanine's (or any
-# library's) models. Each item in the sequence is a four item sequence.
-# The first two items are the dotted path to the model and its field
-# name to be added, and the dotted path to the field class to use for
-# the field. The third and fourth items are a sequence of positional
-# args and a dictionary of keyword args, to use when creating the
-# field instance. When specifying the field class, the path
-# ``django.models.db.`` can be omitted for regular Django model fields.
-#
-
-# EXTRA_MODEL_FIELDS = (
-#  )
-
-EXTRA_MODEL_FIELDS = (
-    )
-
-# Setting to turn on featured images for blog posts. Defaults to False.
-#
-BLOG_USE_FEATURED_IMAGE = True
-
-# If True, the django-modeltranslation will be added to the
-# INSTALLED_APPS setting.
-USE_MODELTRANSLATION = True
-
-# SEARCH_MODEL_CHOICES = ('shop.Product',)
-
-COMMENTS_ACCOUNT_REQUIRED = True
-
-########################
-# MAIN DJANGO SETTINGS #
-########################
-
-# Hosts/domain names that are valid for this site; required if DEBUG is False
-# See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
-ALLOWED_HOSTS = ['*']
-
-# Local time zone for this installation. Choices can be found here:
-# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
-# although not all choices may be available on all operating systems.
-# On Unix systems, a value of None will cause Django to use the same
-# timezone as the operating system.
-# If running in a Windows environment this must be set to the same as your
-# system time zone.
-TIME_ZONE = 'Europe/Paris'
-
-# If you set this to True, Django will use timezone-aware datetimes.
-USE_TZ = True
-
-# Language code for this installation. All choices can be found here:
-# http://www.i18nguy.com/unicode/language-identifiers.html
-LANGUAGE_CODE = "fr"
-
-# Supported languages
-LANGUAGES = (
-    ('fr', _('French')),
-    ('en', _('English')),
-)
-
-LOCALE_PATHS = ['locale',]
-
-# A boolean that turns on/off debug mode. When set to ``True``, stack traces
-# are displayed for error pages. Should always be set to ``False`` in
-# production. Best set to ``True`` in local_settings.py
-DEBUG = False
-
-# Whether a user's session cookie expires when the Web browser is closed.
-SESSION_EXPIRE_AT_BROWSER_CLOSE = True
-
-SITE_ID = 1
-
-# If you set this to False, Django will make some optimizations so as not
-# to load the internationalization machinery.
-USE_I18N = True
-USE_L10N = True
-
-AUTHENTICATION_BACKENDS = ("mezzanine.core.auth_backends.MezzanineBackend",)
-
-# The numeric mode to set newly-uploaded files to. The value should be
-# a mode you'd pass directly to os.chmod.
-FILE_UPLOAD_PERMISSIONS = 0o644
-
-# MAX_UPLOAD_SIZE = 429916160
-
-EVENT_SLUG = 'events'
-
-#############
-# DATABASES #
-#############
-
-DATABASES = {
-    "default": {
-        # Ends with "postgresql_psycopg2", "mysql", "sqlite3" or "oracle".
-        "ENGINE": "django.db.backends.sqlite3",
-        # DB name or path to database file if using sqlite3.
-        "NAME": "dev.db",
-        # Not used with sqlite3.
-        "USER": "",
-        # Not used with sqlite3.
-        "PASSWORD": "",
-        # Set to empty string for localhost. Not used with sqlite3.
-        "HOST": "",
-        # Set to empty string for default. Not used with sqlite3.
-        "PORT": "",
-    }
-}
-
-#########
-# PATHS #
-#########
-
-# Full filesystem path to the project.
-PROJECT_APP_PATH = os.path.dirname(os.path.abspath(__file__))
-PROJECT_APP = os.path.basename(PROJECT_APP_PATH)
-PROJECT_ROOT = BASE_DIR = os.path.dirname(PROJECT_APP_PATH)
-
-# Every cache key will get prefixed with this value - here we set it to
-# the name of the directory the project is in to try and use something
-# project specific.
-CACHE_MIDDLEWARE_KEY_PREFIX = PROJECT_APP
-
-# URL prefix for static files.
-# Example: "http://media.lawrence.com/static/"
-STATIC_URL = "/static/"
-
-# Absolute path to the directory static files should be collected to.
-# Don't put anything in this directory yourself; store your static files
-# in apps' "static/" subdirectories and in STATICFILES_DIRS.
-# Example: "/home/media/media.lawrence.com/static/"
-# STATIC_ROOT = os.path.join(PROJECT_ROOT, STATIC_URL.strip("/"))
-STATIC_ROOT = '/srv/static/'
-
-# URL that handles the media served from MEDIA_ROOT. Make sure to use a
-# trailing slash.
-# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
-MEDIA_URL = "/media/"
-
-# Absolute filesystem path to the directory that will hold user-uploaded files.
-# Example: "/home/media/media.lawrence.com/media/"
-# MEDIA_ROOT = os.path.join(PROJECT_ROOT, *MEDIA_URL.strip("/").split("/"))
-MEDIA_ROOT = '/srv/media/'
-
-# Package/module name to import the root urlpatterns from for the project.
-ROOT_URLCONF = "%s.urls" % PROJECT_APP
-
-
-################
-# APPLICATIONS #
-################
-
-INSTALLED_APPS = [
-    "modeltranslation",
-    "django.contrib.admin",
-    "django.contrib.auth",
-    "django.contrib.contenttypes",
-    "django.contrib.redirects",
-    "django.contrib.sessions",
-    "django.contrib.sites",
-    "django.contrib.staticfiles",
-    "mezzanine.boot",
-    "mezzanine.conf",
-    "django.contrib.sitemaps",
-    "mezzanine.core",
-    "mezzanine.generic",
-    "mezzanine.pages",
-    "mezzanine.blog",
-    "mezzanine.forms",
-    "mezzanine.galleries",
-    "mezzanine.twitter",
-    "mezzanine.accounts",
-    # "mezzanine.mobile",
-    # "eve",
-    "festival",
-    "meta",
-    'mezzanine_agenda',
-]
-
-# Add Migration Module path see : https://github.com/stephenmcd/mezzanine/blob/master/docs/model-customization.rst#field-injection-caveats
-MIGRATION_MODULES = {
-    "blog": "migrations.blog",
-    "forms": "migrations.forms",
-    "galleries": "migrations.galleries",
-    "pages": "migrations.pages",
-    "conf": "migrations.conf",
-    "mezzanine_agenda": "migrations.mezzanine_agenda",
-}
-
-MODELTRANSLATION_TRANSLATION_FILES = (
-    'translations',
-)
-
-TEMPLATES = [{'APP_DIRS': True,
-               'BACKEND': 'django.template.backends.django.DjangoTemplates',
-               'DIRS': ('/srv/app/templates',),
-               'OPTIONS': {'builtins': ['mezzanine.template.loader_tags'],
-                           'context_processors': ('django.contrib.auth.context_processors.auth',
-                                                  'django.contrib.messages.context_processors.messages',
-                                                  'django.core.context_processors.debug',
-                                                  'django.core.context_processors.i18n',
-                                                  'django.core.context_processors.static',
-                                                  'django.core.context_processors.media',
-                                                  'django.core.context_processors.request',
-                                                  'django.core.context_processors.tz',
-                                                  'mezzanine.conf.context_processors.settings',
-                                                  'mezzanine.pages.context_processors.page')}}]
-
-# List of middleware classes to use. Order is important; in the request phase,
-# these middleware classes will be applied in the order given, and in the
-# response phase the middleware will be applied in reverse order.
-MIDDLEWARE_CLASSES = (
-    # 'sandbox.middleware.StartupMiddleware',
-    "mezzanine.core.middleware.UpdateCacheMiddleware",
-    'django.contrib.sessions.middleware.SessionMiddleware',
-    # Uncomment if using internationalisation or localisation
-    'django.middleware.locale.LocaleMiddleware',
-    'django.middleware.common.CommonMiddleware',
-    'django.middleware.csrf.CsrfViewMiddleware',
-    'django.contrib.auth.middleware.AuthenticationMiddleware',
-    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
-    'django.contrib.messages.middleware.MessageMiddleware',
-    'django.middleware.clickjacking.XFrameOptionsMiddleware',
-
-    "mezzanine.core.request.CurrentRequestMiddleware",
-    "mezzanine.core.middleware.RedirectFallbackMiddleware",
-    "mezzanine.core.middleware.TemplateForDeviceMiddleware",
-    "mezzanine.core.middleware.TemplateForHostMiddleware",
-    "mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware",
-    "mezzanine.core.middleware.SitePermissionMiddleware",
-    # Uncomment the following if using any of the SSL settings:
-    # "mezzanine.core.middleware.SSLRedirectMiddleware",
-    "mezzanine.pages.middleware.PageMiddleware",
-    "mezzanine.core.middleware.FetchFromCacheMiddleware",
-)
-
-# Store these package names here as they may change in the future since
-# at the moment we are using custom forks of them.
-PACKAGE_NAME_FILEBROWSER = "filebrowser_safe"
-PACKAGE_NAME_GRAPPELLI = "grappelli_safe"
-
-#########################
-# OPTIONAL APPLICATIONS #
-#########################
-
-# These will be added to ``INSTALLED_APPS``, only if available.
-OPTIONAL_APPS = (
-    "debug_toolbar",
-    "django_extensions",
-    "compressor",
-    PACKAGE_NAME_FILEBROWSER,
-    PACKAGE_NAME_GRAPPELLI,
-)
-
-##################
-# LOCAL SETTINGS #
-##################
-
-# Allow any settings to be defined in local_settings.py which should be
-# ignored in your version control system allowing for settings to be
-# defined per machine.
-try:
-    from .local_settings import *
-except ImportError as e:
-    if "local_settings" not in str(e):
-        raise e
-
-
-####################
-# DYNAMIC S ETTINGS #
-####################
-
-# set_dynamic_settings() will rewrite globals based on what has been
-# defined so far, in order to provide some better defaults where
-# applicable. We also allow this settings module to be imported
-# without Mezzanine installed, as the case may be when using the
-# fabfile, where setting the dynamic settings below isn't strictly
-# required.
-try:
-    from mezzanine.utils.conf import set_dynamic_settings
-except ImportError:
-    pass
-else:
-    set_dynamic_settings(globals())
diff --git a/app/sandbox/urls.py b/app/sandbox/urls.py
deleted file mode 100644 (file)
index f952c63..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-from __future__ import unicode_literals
-
-import django.views.i18n
-from django.conf.urls import patterns, include, url
-from django.conf.urls.i18n import i18n_patterns
-from django.contrib import admin
-
-from mezzanine.core.views import direct_to_template
-from mezzanine.conf import settings
-
-admin.autodiscover()
-
-# Add the urlpatterns for any custom Django applications here.
-# You can also change the ``home`` view to add your own functionality
-# to the project's homepage.
-
-urlpatterns = [
-    # Change the admin prefix here to use an alternate URL for the
-    # admin interface, which would be marginally more secure.
-    url("^admin/", include(admin.site.urls)),
-    ]
-
-if settings.USE_MODELTRANSLATION:
-    urlpatterns += [
-        url('^i18n/$', django.views.i18n.set_language, name='set_language'),
-        ]
-
-
-urlpatterns += [
-    url(r'^festival/', include('festival.urls')),
-    url("^%s/" % settings.EVENT_SLUG, include("mezzanine_agenda.urls")),
-
-    # We don't want to presume how your homepage works, so here are a
-    # few patterns you can use to set it up.
-
-    # HOMEPAGE AS STATIC TEMPLATE
-    # ---------------------------
-    # This pattern simply loads the index.html template. It isn't
-    # commented out like the others, so it's the default. You only need
-    # one homepage pattern, so if you use a different one, comment this
-    # one out.
-
-    url("^styles/$", direct_to_template, {"template": "styles.html"}, name="styles"),
-    url("^$", direct_to_template, {"template": "index.html"}, name="home"),
-
-    # HOMEPAGE AS AN EDITABLE PAGE IN THE PAGE TREE
-    # ---------------------------------------------
-    # This pattern gives us a normal ``Page`` object, so that your
-    # homepage can be managed via the page tree in the admin. If you
-    # use this pattern, you'll need to create a page in the page tree,
-    # and specify its URL (in the Meta Data section) as "/", which
-    # is the value used below in the ``{"slug": "/"}`` part. Make
-    # sure to uncheck all templates for the "show in menus" field
-    # when you create the page, since the link to the homepage is
-    # always hard-coded into all the page menus that display navigation
-    # on the site. Also note that the normal rule of adding a custom
-    # template per page with the template name using the page's slug
-    # doesn't apply here, since we can't have a template called
-    # "/.html" - so for this case, the template "pages/index.html" can
-    # be used.
-
-    # url("^$", "mezzanine.pages.views.page", {"slug": "/"}, name="home"),
-
-    # HOMEPAGE FOR A BLOG-ONLY SITE
-    # -----------------------------
-    # This pattern points the homepage to the blog post listing page,
-    # and is useful for sites that are primarily blogs. If you use this
-    # pattern, you'll also need to set BLOG_SLUG = "" in your
-    # ``settings.py`` module, and delete the blog page object from the
-    # page tree in the admin if it was installed.
-
-    # url("^$", "mezzanine.blog.views.blog_post_list", name="home"),
-
-    # MEZZANINE'S URLS
-    # ----------------
-    # ADD YOUR OWN URLPATTERNS *ABOVE* THE LINE BELOW.
-    # ``mezzanine.urls`` INCLUDES A *CATCH ALL* PATTERN
-    # FOR PAGES, SO URLPATTERNS ADDED BELOW ``mezzanine.urls``
-    # WILL NEVER BE MATCHED!
-
-    # If you'd like more granular control over the patterns in
-    # ``mezzanine.urls``, go right ahead and take the parts you want
-    # from it, and use them directly below instead of using
-    # ``mezzanine.urls``.
-    url("^", include("mezzanine.urls")),
-
-    # MOUNTING MEZZANINE UNDER A PREFIX
-    # ---------------------------------
-    # You can also mount all of Mezzanine's urlpatterns under a
-    # URL prefix if desired. When doing this, you need to define the
-    # ``SITE_PREFIX`` setting, which will contain the prefix. Eg:
-    # SITE_PREFIX = "my/site/prefix"
-    # For convenience, and to avoid repeating the prefix, use the
-    # commented out pattern below (commenting out the one above of course)
-    # which will make use of the ``SITE_PREFIX`` setting. Make sure to
-    # add the import ``from django.conf import settings`` to the top
-    # of this file as well.
-    # Note that for any of the various homepage patterns above, you'll
-    # need to use the ``SITE_PREFIX`` setting as well.
-
-    # ("^%s/" % settings.SITE_PREFIX, include("mezzanine.urls"))
-]
-
-# Adds ``STATIC_URL`` to the context of error pages, so that error
-# pages can use JS, CSS and images.
-handler404 = "mezzanine.core.views.page_not_found"
-handler500 = "mezzanine.core.views.server_error"
diff --git a/app/scripts/app.sh b/app/scripts/app.sh
new file mode 100644 (file)
index 0000000..962cf9a
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/sh
+
+# paths
+app='/srv/app'
+manage=$app'/manage.py'
+wsgi=$app'/wsgi.py'
+static='/srv/static/'
+media='/srv/media/'
+src='/srv/src/'
+
+# uwsgi params
+port=8000
+processes=2
+threads=2
+autoreload=3
+uid='www-data'
+gid='www-data'
+patterns='*.js;*.css;*.jpg;*.jpeg;*.gif;*.png;*.svg;*.ttf;*.eot;*.woff;*.woff2'
+
+# Staging
+# pip install psycopg2
+# pip install -U https://forge.ircam.fr/p/django-eve/source/download/dev/
+
+chown -R $uid:$gid $media
+
+# waiting for other services
+sh $app/scripts/wait.sh
+
+# waiting for available database
+# python $app/wait.py
+# python $manage wait-for-db-connection
+
+# django init
+# python $manage syncdb --noinput
+python $manage migrate --noinput
+python $manage collectstatic --noinput
+python $manage create-admin-user
+
+# app start
+if [ $1 = "--runserver" ]
+then
+    python $manage runserver 0.0.0.0:8000
+else
+    # static files auto update
+    watchmedo shell-command --patterns="$patterns" --recursive \
+        --command='python '$manage' collectstatic --noinput' $app &
+
+    uwsgi --socket :$port --wsgi-file $wsgi --chdir $app --master \
+    --processes $processes --threads $threads \
+    --uid $uid --gid $gid \
+    --py-autoreload $autoreload
+fi
diff --git a/app/scripts/wait.sh b/app/scripts/wait.sh
new file mode 100644 (file)
index 0000000..202c4d1
--- /dev/null
@@ -0,0 +1,16 @@
+#!/bin/sh
+
+set -e
+
+host=$(env | grep _TCP_ADDR | cut -d = -f 2)
+port=$(env | grep _TCP_PORT | cut -d = -f 2)
+
+echo -n "waiting for TCP connection to $host:$port..."
+
+while ! nc -w 1 $host $port 2>/dev/null
+do
+  echo -n .
+  sleep 1
+done
+
+echo 'ok'
diff --git a/app/settings.py b/app/settings.py
new file mode 100644 (file)
index 0000000..e48f923
--- /dev/null
@@ -0,0 +1,330 @@
+
+from __future__ import absolute_import, unicode_literals
+import os
+from django.utils.translation import ugettext_lazy as _
+
+######################
+# MEZZANINE SETTINGS #
+######################
+
+# The following settings are already defined with default values in
+# the ``defaults.py`` module within each of Mezzanine's apps, but are
+# common enough to be put here, commented out, for conveniently
+# overriding. Please consult the settings documentation for a full list
+# of settings Mezzanine implements:
+# http://mezzanine.jupo.org/docs/configuration.html#default-settings
+
+# Controls the ordering and grouping of the admin menu.
+#
+# ADMIN_MENU_ORDER = (
+#     ("Content", ("pages.Page", "blog.BlogPost",
+#        "generic.ThreadedComment", (_("Media Library"), "fb_browse"),)),
+#     (_("Shop"), ("shop.Product", "shop.ProductOption", "shop.DiscountCode",
+#        "shop.Sale", "shop.Order")),
+#     ("Site", ("sites.Site", "redirects.Redirect", "conf.Setting")),
+#     ("Users", ("auth.User", "auth.Group",)),
+# )
+
+# A three item sequence, each containing a sequence of template tags
+# used to render the admin dashboard.
+#
+# DASHBOARD_TAGS = (
+#     ("blog_tags.quick_blog", "mezzanine_tags.app_list"),
+#     ("comment_tags.recent_comments",),
+#     ("mezzanine_tags.recent_actions",),
+# )
+
+# A sequence of templates used by the ``page_menu`` template tag. Each
+# item in the sequence is a three item sequence, containing a unique ID
+# for the template, a label for the template, and the template path.
+# These templates are then available for selection when editing which
+# menus a page should appear in. Note that if a menu template is used
+# that doesn't appear in this setting, all pages will appear in it.
+
+PAGE_MENU_TEMPLATES = (
+    (1, _("Top navigation bar"), "pages/menus/dropdown.html"),
+    # (2, _("Left-hand tree"), "pages/menus/tree.html"),
+    (2, _("Footer"), "pages/menus/footer.html"),
+)
+
+# A sequence of fields that will be injected into Mezzanine's (or any
+# library's) models. Each item in the sequence is a four item sequence.
+# The first two items are the dotted path to the model and its field
+# name to be added, and the dotted path to the field class to use for
+# the field. The third and fourth items are a sequence of positional
+# args and a dictionary of keyword args, to use when creating the
+# field instance. When specifying the field class, the path
+# ``django.models.db.`` can be omitted for regular Django model fields.
+#
+
+# EXTRA_MODEL_FIELDS = (
+#  )
+
+EXTRA_MODEL_FIELDS = (
+    )
+
+# Setting to turn on featured images for blog posts. Defaults to False.
+#
+BLOG_USE_FEATURED_IMAGE = True
+
+# If True, the django-modeltranslation will be added to the
+# INSTALLED_APPS setting.
+USE_MODELTRANSLATION = True
+
+# SEARCH_MODEL_CHOICES = ('shop.Product',)
+
+COMMENTS_ACCOUNT_REQUIRED = True
+
+########################
+# MAIN DJANGO SETTINGS #
+########################
+
+# Hosts/domain names that are valid for this site; required if DEBUG is False
+# See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
+ALLOWED_HOSTS = ['*']
+
+# Local time zone for this installation. Choices can be found here:
+# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
+# although not all choices may be available on all operating systems.
+# On Unix systems, a value of None will cause Django to use the same
+# timezone as the operating system.
+# If running in a Windows environment this must be set to the same as your
+# system time zone.
+TIME_ZONE = 'Europe/Paris'
+
+# If you set this to True, Django will use timezone-aware datetimes.
+USE_TZ = True
+
+# Language code for this installation. All choices can be found here:
+# http://www.i18nguy.com/unicode/language-identifiers.html
+LANGUAGE_CODE = "fr"
+
+# Supported languages
+LANGUAGES = (
+    ('fr', _('French')),
+    ('en', _('English')),
+)
+
+LOCALE_PATHS = ['locale',]
+
+# A boolean that turns on/off debug mode. When set to ``True``, stack traces
+# are displayed for error pages. Should always be set to ``False`` in
+# production. Best set to ``True`` in local_settings.py
+DEBUG = False
+
+# Whether a user's session cookie expires when the Web browser is closed.
+SESSION_EXPIRE_AT_BROWSER_CLOSE = True
+
+SITE_ID = 1
+
+# If you set this to False, Django will make some optimizations so as not
+# to load the internationalization machinery.
+USE_I18N = True
+USE_L10N = True
+
+AUTHENTICATION_BACKENDS = ("mezzanine.core.auth_backends.MezzanineBackend",)
+
+# The numeric mode to set newly-uploaded files to. The value should be
+# a mode you'd pass directly to os.chmod.
+FILE_UPLOAD_PERMISSIONS = 0o644
+
+# MAX_UPLOAD_SIZE = 429916160
+
+EVENT_SLUG = 'events'
+
+#############
+# DATABASES #
+#############
+
+DATABASES = {
+    "default": {
+        # Ends with "postgresql_psycopg2", "mysql", "sqlite3" or "oracle".
+        "ENGINE": "django.db.backends.sqlite3",
+        # DB name or path to database file if using sqlite3.
+        "NAME": "dev.db",
+        # Not used with sqlite3.
+        "USER": "",
+        # Not used with sqlite3.
+        "PASSWORD": "",
+        # Set to empty string for localhost. Not used with sqlite3.
+        "HOST": "",
+        # Set to empty string for default. Not used with sqlite3.
+        "PORT": "",
+    }
+}
+
+#########
+# PATHS #
+#########
+
+# Full filesystem path to the project.
+PROJECT_APP_PATH = os.path.dirname(os.path.abspath(__file__))
+PROJECT_APP = os.path.basename(PROJECT_APP_PATH)
+PROJECT_ROOT = BASE_DIR = os.path.dirname(PROJECT_APP_PATH)
+
+# Every cache key will get prefixed with this value - here we set it to
+# the name of the directory the project is in to try and use something
+# project specific.
+CACHE_MIDDLEWARE_KEY_PREFIX = PROJECT_APP
+
+# URL prefix for static files.
+# Example: "http://media.lawrence.com/static/"
+STATIC_URL = "/static/"
+
+# Absolute path to the directory static files should be collected to.
+# Don't put anything in this directory yourself; store your static files
+# in apps' "static/" subdirectories and in STATICFILES_DIRS.
+# Example: "/home/media/media.lawrence.com/static/"
+# STATIC_ROOT = os.path.join(PROJECT_ROOT, STATIC_URL.strip("/"))
+STATIC_ROOT = '/srv/static/'
+
+# URL that handles the media served from MEDIA_ROOT. Make sure to use a
+# trailing slash.
+# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
+MEDIA_URL = "/media/"
+
+# Absolute filesystem path to the directory that will hold user-uploaded files.
+# Example: "/home/media/media.lawrence.com/media/"
+# MEDIA_ROOT = os.path.join(PROJECT_ROOT, *MEDIA_URL.strip("/").split("/"))
+MEDIA_ROOT = '/srv/media/'
+
+# Package/module name to import the root urlpatterns from for the project.
+ROOT_URLCONF = "urls"
+
+
+################
+# APPLICATIONS #
+################
+
+INSTALLED_APPS = [
+    "modeltranslation",
+    "django.contrib.admin",
+    "django.contrib.auth",
+    "django.contrib.contenttypes",
+    "django.contrib.redirects",
+    "django.contrib.sessions",
+    "django.contrib.sites",
+    "django.contrib.staticfiles",
+    "mezzanine.boot",
+    "mezzanine.conf",
+    "django.contrib.sitemaps",
+    "mezzanine.core",
+    "mezzanine.generic",
+    "mezzanine.pages",
+    "mezzanine.blog",
+    "mezzanine.forms",
+    "mezzanine.galleries",
+    "mezzanine.twitter",
+    "mezzanine.accounts",
+    # "mezzanine.mobile",
+    # "eve",
+    "festival",
+    "meta",
+    'mezzanine_agenda',
+]
+
+# Add Migration Module path see : https://github.com/stephenmcd/mezzanine/blob/master/docs/model-customization.rst#field-injection-caveats
+MIGRATION_MODULES = {
+    "blog": "migrations.blog",
+    "forms": "migrations.forms",
+    "galleries": "migrations.galleries",
+    "pages": "migrations.pages",
+    "conf": "migrations.conf",
+    "mezzanine_agenda": "migrations.mezzanine_agenda",
+}
+
+MODELTRANSLATION_TRANSLATION_FILES = (
+    'translations',
+)
+
+TEMPLATES = [{'APP_DIRS': True,
+               'BACKEND': 'django.template.backends.django.DjangoTemplates',
+               'DIRS': ('/srv/app/templates',),
+               'OPTIONS': {'builtins': ['mezzanine.template.loader_tags'],
+                           'context_processors': ('django.contrib.auth.context_processors.auth',
+                                                  'django.contrib.messages.context_processors.messages',
+                                                  'django.core.context_processors.debug',
+                                                  'django.core.context_processors.i18n',
+                                                  'django.core.context_processors.static',
+                                                  'django.core.context_processors.media',
+                                                  'django.core.context_processors.request',
+                                                  'django.core.context_processors.tz',
+                                                  'mezzanine.conf.context_processors.settings',
+                                                  'mezzanine.pages.context_processors.page')}}]
+
+# List of middleware classes to use. Order is important; in the request phase,
+# these middleware classes will be applied in the order given, and in the
+# response phase the middleware will be applied in reverse order.
+MIDDLEWARE_CLASSES = (
+    # 'sandbox.middleware.StartupMiddleware',
+    "mezzanine.core.middleware.UpdateCacheMiddleware",
+    'django.contrib.sessions.middleware.SessionMiddleware',
+    # Uncomment if using internationalisation or localisation
+    'django.middleware.locale.LocaleMiddleware',
+    'django.middleware.common.CommonMiddleware',
+    'django.middleware.csrf.CsrfViewMiddleware',
+    'django.contrib.auth.middleware.AuthenticationMiddleware',
+    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
+    'django.contrib.messages.middleware.MessageMiddleware',
+    'django.middleware.clickjacking.XFrameOptionsMiddleware',
+
+    "mezzanine.core.request.CurrentRequestMiddleware",
+    "mezzanine.core.middleware.RedirectFallbackMiddleware",
+    "mezzanine.core.middleware.TemplateForDeviceMiddleware",
+    "mezzanine.core.middleware.TemplateForHostMiddleware",
+    "mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware",
+    "mezzanine.core.middleware.SitePermissionMiddleware",
+    # Uncomment the following if using any of the SSL settings:
+    # "mezzanine.core.middleware.SSLRedirectMiddleware",
+    "mezzanine.pages.middleware.PageMiddleware",
+    "mezzanine.core.middleware.FetchFromCacheMiddleware",
+)
+
+# Store these package names here as they may change in the future since
+# at the moment we are using custom forks of them.
+PACKAGE_NAME_FILEBROWSER = "filebrowser_safe"
+PACKAGE_NAME_GRAPPELLI = "grappelli_safe"
+
+#########################
+# OPTIONAL APPLICATIONS #
+#########################
+
+# These will be added to ``INSTALLED_APPS``, only if available.
+OPTIONAL_APPS = (
+    "debug_toolbar",
+    "django_extensions",
+    "compressor",
+    PACKAGE_NAME_FILEBROWSER,
+    PACKAGE_NAME_GRAPPELLI,
+)
+
+##################
+# LOCAL SETTINGS #
+##################
+
+# Allow any settings to be defined in local_settings.py which should be
+# ignored in your version control system allowing for settings to be
+# defined per machine.
+try:
+    from local_settings import *
+except ImportError as e:
+    if "local_settings" not in str(e):
+        raise e
+
+
+####################
+# DYNAMIC S ETTINGS #
+####################
+
+# set_dynamic_settings() will rewrite globals based on what has been
+# defined so far, in order to provide some better defaults where
+# applicable. We also allow this settings module to be imported
+# without Mezzanine installed, as the case may be when using the
+# fabfile, where setting the dynamic settings below isn't strictly
+# required.
+try:
+    from mezzanine.utils.conf import set_dynamic_settings
+except ImportError:
+    pass
+else:
+    set_dynamic_settings(globals())
diff --git a/app/urls.py b/app/urls.py
new file mode 100644 (file)
index 0000000..f952c63
--- /dev/null
@@ -0,0 +1,107 @@
+from __future__ import unicode_literals
+
+import django.views.i18n
+from django.conf.urls import patterns, include, url
+from django.conf.urls.i18n import i18n_patterns
+from django.contrib import admin
+
+from mezzanine.core.views import direct_to_template
+from mezzanine.conf import settings
+
+admin.autodiscover()
+
+# Add the urlpatterns for any custom Django applications here.
+# You can also change the ``home`` view to add your own functionality
+# to the project's homepage.
+
+urlpatterns = [
+    # Change the admin prefix here to use an alternate URL for the
+    # admin interface, which would be marginally more secure.
+    url("^admin/", include(admin.site.urls)),
+    ]
+
+if settings.USE_MODELTRANSLATION:
+    urlpatterns += [
+        url('^i18n/$', django.views.i18n.set_language, name='set_language'),
+        ]
+
+
+urlpatterns += [
+    url(r'^festival/', include('festival.urls')),
+    url("^%s/" % settings.EVENT_SLUG, include("mezzanine_agenda.urls")),
+
+    # We don't want to presume how your homepage works, so here are a
+    # few patterns you can use to set it up.
+
+    # HOMEPAGE AS STATIC TEMPLATE
+    # ---------------------------
+    # This pattern simply loads the index.html template. It isn't
+    # commented out like the others, so it's the default. You only need
+    # one homepage pattern, so if you use a different one, comment this
+    # one out.
+
+    url("^styles/$", direct_to_template, {"template": "styles.html"}, name="styles"),
+    url("^$", direct_to_template, {"template": "index.html"}, name="home"),
+
+    # HOMEPAGE AS AN EDITABLE PAGE IN THE PAGE TREE
+    # ---------------------------------------------
+    # This pattern gives us a normal ``Page`` object, so that your
+    # homepage can be managed via the page tree in the admin. If you
+    # use this pattern, you'll need to create a page in the page tree,
+    # and specify its URL (in the Meta Data section) as "/", which
+    # is the value used below in the ``{"slug": "/"}`` part. Make
+    # sure to uncheck all templates for the "show in menus" field
+    # when you create the page, since the link to the homepage is
+    # always hard-coded into all the page menus that display navigation
+    # on the site. Also note that the normal rule of adding a custom
+    # template per page with the template name using the page's slug
+    # doesn't apply here, since we can't have a template called
+    # "/.html" - so for this case, the template "pages/index.html" can
+    # be used.
+
+    # url("^$", "mezzanine.pages.views.page", {"slug": "/"}, name="home"),
+
+    # HOMEPAGE FOR A BLOG-ONLY SITE
+    # -----------------------------
+    # This pattern points the homepage to the blog post listing page,
+    # and is useful for sites that are primarily blogs. If you use this
+    # pattern, you'll also need to set BLOG_SLUG = "" in your
+    # ``settings.py`` module, and delete the blog page object from the
+    # page tree in the admin if it was installed.
+
+    # url("^$", "mezzanine.blog.views.blog_post_list", name="home"),
+
+    # MEZZANINE'S URLS
+    # ----------------
+    # ADD YOUR OWN URLPATTERNS *ABOVE* THE LINE BELOW.
+    # ``mezzanine.urls`` INCLUDES A *CATCH ALL* PATTERN
+    # FOR PAGES, SO URLPATTERNS ADDED BELOW ``mezzanine.urls``
+    # WILL NEVER BE MATCHED!
+
+    # If you'd like more granular control over the patterns in
+    # ``mezzanine.urls``, go right ahead and take the parts you want
+    # from it, and use them directly below instead of using
+    # ``mezzanine.urls``.
+    url("^", include("mezzanine.urls")),
+
+    # MOUNTING MEZZANINE UNDER A PREFIX
+    # ---------------------------------
+    # You can also mount all of Mezzanine's urlpatterns under a
+    # URL prefix if desired. When doing this, you need to define the
+    # ``SITE_PREFIX`` setting, which will contain the prefix. Eg:
+    # SITE_PREFIX = "my/site/prefix"
+    # For convenience, and to avoid repeating the prefix, use the
+    # commented out pattern below (commenting out the one above of course)
+    # which will make use of the ``SITE_PREFIX`` setting. Make sure to
+    # add the import ``from django.conf import settings`` to the top
+    # of this file as well.
+    # Note that for any of the various homepage patterns above, you'll
+    # need to use the ``SITE_PREFIX`` setting as well.
+
+    # ("^%s/" % settings.SITE_PREFIX, include("mezzanine.urls"))
+]
+
+# Adds ``STATIC_URL`` to the context of error pages, so that error
+# pages can use JS, CSS and images.
+handler404 = "mezzanine.core.views.page_not_found"
+handler500 = "mezzanine.core.views.server_error"
index 877edbd3018d591cd0701829479949438781e577..1fb048ab21a9374c1c349d4eef56b5005982729c 100644 (file)
@@ -4,7 +4,7 @@ import os, time
 from django.core.management import call_command
 
 up = False
-os.environ.setdefault("DJANGO_SETTINGS_MODULE", "sandbox.settings")
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "settings")
 
 while not up:
     try:
index aa519c45c10f69fce7493ab5b577428fee6a5cea..bc6fde2b2588188f4512ac6a69c61652a1e762b6 100644 (file)
@@ -1,18 +1,10 @@
-"""
-WSGI config for diggersdigest project.
-
-It exposes the WSGI callable as a module-level variable named ``application``.
-
-For more information on this file, see
-https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
-"""
+#!/usr/bin/python
+# -*- coding: utf-8 -*-
 
 import os
+import sys
 from django.core.wsgi import get_wsgi_application
-from mezzanine.utils.conf import real_project_name
-
-settings_module = "%s.settings" % real_project_name("sandbox")
-
-os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings_module)
 
+sys.path.append(os.path.dirname('.'))
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", 'settings')
 application = get_wsgi_application()
index 21b2192443f500f4a45a30bc095257b01f91e90a..7ab6d84ff29248a3da8e6985d1223f528f83d795 100644 (file)
@@ -49,7 +49,7 @@ pgdb:
 
 app:
   build: .
-  command: /bin/sh deploy/start_app.sh
+  command: /bin/sh scripts/app.sh
   volumes:
     - ./app/:/srv/app
     - ./lib/mezzanine-agenda/:/srv/lib/mezzanine-agenda
@@ -68,7 +68,7 @@ nginx:
   ports:
     - "80:80"
   volumes:
-    - ./app/deploy/nginx-app.conf:/etc/nginx/conf.d/default.conf
+    - ./etc/nginx.conf:/etc/nginx/conf.d/default.conf
     - ./data/var/log/nginx/:/var/log/nginx
   volumes_from:
     - data
index ffd7fd277ab372c7e112b4ba695f69eb4e1a98a8..2236339cfdd97ae209f3d785aec39d152b3e3fef 100644 (file)
@@ -20,7 +20,7 @@
 
 
 app:
-  command: /bin/sh deploy/start_app.sh --runserver
+  command: /bin/sh scripts/app.sh --runserver
   volumes:
     - ./app/:/srv/app
   ports:
diff --git a/etc/nginx.conf b/etc/nginx.conf
new file mode 100644 (file)
index 0000000..3f89e87
--- /dev/null
@@ -0,0 +1,27 @@
+server_tokens off;
+
+server {
+       listen 80;
+       server_name messiaen.ircam.fr nginx;
+       charset utf-8;
+
+       access_log /var/log/nginx/app-access.log;
+       error_log /var/log/nginx/app-error.log;
+
+       # max upload size
+       client_max_body_size 4096M; # adjust to taste
+
+       # Django media
+       location /media {
+                       alias /srv/media; # your Django project's media files - amend as required
+       }
+       # Django static
+       location /static {
+               alias /srv/static; # your Django project's static files - amend as required
+       }
+
+       location / {
+            uwsgi_pass app:8000;
+            include /etc/nginx/uwsgi_params;
+       }
+}