Activating bcmagic model & initial data.
[htsworkflow.git] / htsworkflow / frontend / settings.py
1 """
2 Generate settings for the Django Application.
3
4 To make it easier to customize the application the settings can be 
5 defined in a configuration file read by ConfigParser.
6
7 The options understood by this module are (with their defaults):
8
9   [frontend]
10   email_host=localhost
11   email_port=25
12   database_engine=sqlite3
13   database_name=/path/to/db
14
15   [admins]
16   #name1=email1
17
18   [allowed_hosts]
19   #name1=ip
20   localhost=127.0.0.1
21   
22   [allowed_analysis_hosts]
23   #name1=ip
24   localhost=127.0.0.1
25
26 """
27 import ConfigParser
28 import os
29
30 # make epydoc happy
31 __docformat__ = "restructuredtext en"
32
33 def options_to_list(dest, section_name):
34   """
35   Load a options from section_name and store in a dictionary
36   """
37   if options.has_section(section_name):
38     for name in options.options(section_name):
39       dest.append( options.get(section_name, name) )
40       
41 def options_to_dict(dest, section_name):
42   """
43   Load a options from section_name and store in a dictionary
44   """
45   if options.has_section(section_name):
46     for name in options.options(section_name):
47       dest[name] = options.get(section_name, name)
48
49 # define your defaults here
50 options = ConfigParser.SafeConfigParser(
51            { 'email_host': 'localhost',
52              'email_port': '25', 
53              'database_engine': 'sqlite3',
54              'database_name': 
55                os.path.abspath('/htsworkflow/htswfrontend/dev_fctracker.db'),
56              'time_zone': 'America/Los_Angeles',
57              'default_pm': '5',
58              'link_flowcell_storage_device_url': "http://localhost:8000/inventory/lts/link/"
59            })
60
61 options.read([os.path.expanduser("~/.htsworkflow.ini"),
62               '/etc/htsworkflow.ini',])
63
64 # OptionParser will use the dictionary passed into the config parser as
65 # 'Default' values in any section. However it still needs an empty section
66 # to exist in order to retrieve anything.
67 if not options.has_section('frontend'):
68     options.add_section('frontend')
69
70 # Django settings for elandifier project.
71
72 DEBUG = True
73 TEMPLATE_DEBUG = DEBUG
74
75 ADMINS = []
76 options_to_list(ADMINS, 'admins')
77
78 MANAGERS = ADMINS
79
80 EMAIL_HOST = options.get('frontend', 'email_host')
81 EMAIL_PORT = int(options.get('frontend', 'email_port'))
82
83 # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'ado_mssql'.
84 DATABASE_ENGINE = options.get('frontend', 'database_engine')
85
86 # Or path to database file if using sqlite3.
87 DATABASE_NAME = options.get('frontend', 'database_name' )
88 DATABASE_USER = ''             # Not used with sqlite3.
89 DATABASE_PASSWORD = ''         # Not used with sqlite3.
90 DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
91 DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.
92
93 # Local time zone for this installation. Choices can be found here:
94 # http://www.postgresql.org/docs/8.1/static/datetime-keywords.html#DATETIME-TIMEZONE-SET-TABLE
95 # although not all variations may be possible on all operating systems.
96 # If running in a Windows environment this must be set to the same as your
97 # system time zone.
98 TIME_ZONE = options.get('frontend', 'time_zone')
99
100 # Language code for this installation. All choices can be found here:
101 # http://www.w3.org/TR/REC-html40/struct/dirlang.html#langcodes
102 # http://blogs.law.harvard.edu/tech/stories/storyReader$15
103 LANGUAGE_CODE = 'en-us'
104
105 SITE_ID = 1
106
107 # If you set this to False, Django will make some optimizations so as not
108 # to load the internationalization machinery.
109 USE_I18N = True
110
111 # Absolute path to the directory that holds media.
112 # Example: "/home/media/media.lawrence.com/"
113 MEDIA_ROOT = os.path.abspath(os.path.split(__file__)[0]) + '/static/'
114
115 # URL that handles the media served from MEDIA_ROOT.
116 # Example: "http://media.lawrence.com"
117 MEDIA_URL = '/static/'
118
119 # URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
120 # trailing slash.
121 # Examples: "http://foo.com/media/", "/media/".
122 ADMIN_MEDIA_PREFIX = '/media/'
123
124 # Make this unique, and don't share it with anybody.
125 SECRET_KEY = '(ekv^=gf(j9f(x25@a7r+8)hqlz%&_1!tw^75l%^041#vi=@4n'
126
127 # List of callables that know how to import templates from various sources.
128 TEMPLATE_LOADERS = (
129     'django.template.loaders.filesystem.load_template_source',
130     'django.template.loaders.app_directories.load_template_source',
131 #     'django.template.loaders.eggs.load_template_source',
132 )
133
134 MIDDLEWARE_CLASSES = (
135     'django.middleware.common.CommonMiddleware',
136     'django.contrib.sessions.middleware.SessionMiddleware',
137     'django.contrib.auth.middleware.AuthenticationMiddleware',
138     'django.middleware.doc.XViewMiddleware',
139 )
140
141 ROOT_URLCONF = 'htsworkflow.frontend.urls'
142
143 TEMPLATE_DIRS = (
144     # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
145     # Always use forward slashes, even on Windows.
146     # Don't forget to use absolute paths, not relative paths.
147     os.path.join(os.path.split(__file__)[0], 'templates'),
148 )
149
150 INSTALLED_APPS = (
151     'django.contrib.admin',
152     'django.contrib.auth',
153     'django.contrib.contenttypes',
154     'django.contrib.humanize',
155     'django.contrib.sessions',
156     'django.contrib.sites',
157     'htsworkflow.frontend.eland_config',
158     'htsworkflow.frontend.samples',
159     # modules from htsworkflow branch
160     'htsworkflow.frontend.experiments',
161     'htsworkflow.frontend.analysis', 
162     'htsworkflow.frontend.reports',
163     'htsworkflow.frontend.inventory',
164     'htsworkflow.frontend.bcmagic',
165     'django.contrib.databrowse',
166 )
167
168 # Project specific settings
169
170 ALLOWED_IPS={'127.0.0.1': '127.0.0.1'}
171 options_to_dict(ALLOWED_IPS, 'allowed_hosts')
172
173 ALLOWED_ANALYS_IPS = {'127.0.0.1': '127.0.0.1'}
174 options_to_dict(ALLOWED_ANALYS_IPS, 'allowed_analysis_hosts')
175 #UPLOADTO_HOME = os.path.abspath('../../uploads')
176 #UPLOADTO_CONFIG_FILE = os.path.join(UPLOADTO_HOME, 'eland_config')
177 #UPLOADTO_ELAND_RESULT_PACKS = os.path.join(UPLOADTO_HOME, 'eland_results')
178 #UPLOADTO_BED_PACKS = os.path.join(UPLOADTO_HOME, 'bed_packs')
179 RESULT_HOME_DIR='/Users/diane/proj/solexa/results/flowcells'
180
181 LINK_FLOWCELL_STORAGE_DEVICE_URL = options.get('frontend', 'link_flowcell_storage_device_url')
182