/
settings.py
172 lines (136 loc) · 5.1 KB
/
settings.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
"""
Django settings for dmp_project project.
"""
import csv
import os
import dj_database_url
from django.core.management.utils import get_random_secret_key
from decimal import Decimal
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.getenv('SECRET_KEY', get_random_secret_key())
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.getenv('DEBUG', False)
ALLOWED_HOSTS = os.getenv('ALLOWED_HOSTS', '*').split(',')
INSTALLED_APPS = [
'music_publisher.apps.MusicPublisherConfig',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'whitenoise.middleware.WhiteNoiseMiddleware',
'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',
]
ROOT_URLCONF = 'dmp_project.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'dmp_project.wsgi.application'
DATABASES = {
'default': dj_database_url.config(
default='sqlite:///{}'.format(os.path.join(BASE_DIR, 'db.sqlite3')))}
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.'
'UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.'
'MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.'
'CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.'
'NumericPasswordValidator',
},
]
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = os.getenv('STATIC_URL', '/static/')
STATIC_ROOT = os.getenv('STATIC_ROOT', os.path.join(BASE_DIR, 'static'))
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "dmp_project", "static"),
]
TIME_INPUT_FORMATS = [
'%H:%M:%S', # '14:30:59'
'%M:%S', # '14:30'
]
path = os.path.join(BASE_DIR, 'music_publisher', 'societies.csv')
with open(path, 'r') as f:
reader = csv.reader(f)
SOCIETIES = sorted(
((str(row[0]), '{} ({})'.format(row[1], row[2]))
for row in reader),
key=lambda row: row[1])
LOGIN_URL = '/login/'
DATA_UPLOAD_MAX_NUMBER_FIELDS = None
# The name of the publisher. Use no comma in the name!
PUBLISHER_NAME = os.getenv('PUBLISHER', 'DJANGO-MUSIC-PUBLISHER')
# CWR Delivery code, issued by collecting societies
PUBLISHER_CODE = os.getenv('PUBLISHER_CODE', '')
# IPI Name # is required, issued by collecting societies
PUBLISHER_IPI_NAME = os.getenv('PUBLISHER_IPI_NAME', '')
# IPI Base # is rarely used, issued by collecting societies
PUBLISHER_IPI_BASE = os.getenv('PUBLISHER_IPI_BASE', None)
# Affiliation societies for performance, mechanical and sync rights
# Numerical value as string without the leading zero:
# '52' for PRS, '44' for MCPS, '10' for ASCAP, '34' for HFA. etc.
# see music_publisher/societies.csv
PUBLISHER_SOCIETY_PR = os.getenv('PUBLISHER_SOCIETY_PR', None)
PUBLISHER_SOCIETY_MR = os.getenv('PUBLISHER_SOCIETY_MR', None)
PUBLISHER_SOCIETY_SR = os.getenv('PUBLISHER_SOCIETY_SR', None)
# Set to True for societies that require society-assigned agreement numbers
# PRS/MCPS, BUMA/STEMRA, Scandinavian societies.
REQUIRE_SAAN = os.getenv('REQUIRE_SAAN', False)
# Set to True if you have a standard publishing agreement with writers
REQUIRE_PUBLISHER_FEE = os.getenv('REQUIRE_PUBLISHER_FEE', False)
# Shares transferred to the original publisher, default to 50%/100%/100%
PUBLISHING_AGREEMENT_PUBLISHER_PR = Decimal(
os.getenv('PUBLISHER_AGREEMENT_PR', '0.5'))
PUBLISHING_AGREEMENT_PUBLISHER_MR = Decimal(
os.getenv('PUBLISHER_AGREEMENT_PR', '1.0'))
PUBLISHING_AGREEMENT_PUBLISHER_SR = Decimal(
os.getenv('PUBLISHER_AGREEMENT_PR', '1.0'))
# Error reporting aggregator, see https://sentry.io
SENTRY_DSN = os.getenv('SENTRY_DSN')
if SENTRY_DSN:
import sentry_sdk
from sentry_sdk.integrations.django import DjangoIntegration
sentry_sdk.init(
dsn=SENTRY_DSN,
integrations=[DjangoIntegration()],
send_default_pii=True
)
sentry_sdk.capture_message('Starting.')
CSRF_COOKIE_SECURE = not DEBUG
SESSION_COOKIE_SECURE = not DEBUG
SECURE_HSTS_SECONDS = 0 if DEBUG else 300
SECURE_HSTS_PRELOAD = DEBUG