class Development(LoggingMixin, EnvWithRealAuth): DEBUG = True SECRET_KEY = get_random_string(length=32) DATABASE_URL = values.DatabaseURLValue(environ_required=True, environ_prefix='') DATABASES = DATABASE_URL INSTALLED_APPS = BaseSettings.INSTALLED_APPS + [ 'django_extensions', 'django_nose', 'raven.contrib.django.raven_compat', 'corsheaders' ] CACHES = values.CacheURLValue(environ_name='REDIS_URL') RAVEN_CONFIG = {'dsn': BaseSettings.SENTRY_PRIVATE_DSN} TEST_RUNNER = 'django_nose.NoseTestSuiteRunner' MIDDLEWARE_CLASSES = BaseSettings.MIDDLEWARE_CLASSES + \ ['corsheaders.middleware.CorsMiddleware'] CORS_ALLOW_CREDENTIALS = True CORS_ORIGIN_ALLOW_ALL = True BROKER_URL = values.Value(environ_prefix='', environ_name='REDIS_URL') CELERY_RESULT_BACKEND = values.Value(environ_prefix='', environ_name='REDIS_URL')
class Production(EnvWithRealAuth): DEBUG = False SECRET_KEY = values.SecretValue(environ_prefix='') DATABASE_URL = values.DatabaseURLValue(environ_required=True, environ_prefix='') BROKER_URL = values.Value(environ_prefix='', environ_name='REDIS_URL') CELERY_RESULT_BACKEND = values.Value(environ_required=True, environ_prefix='', environ_name='REDIS_URL') CACHES = values.CacheURLValue(environ_name='REDIS_URL') DATABASES = DATABASE_URL INSTALLED_APPS = BaseSettings.INSTALLED_APPS + [ 'corsheaders', 'raven.contrib.django.raven_compat' ] MIDDLEWARE_CLASSES = BaseSettings.MIDDLEWARE_CLASSES + \ ['corsheaders.middleware.CorsMiddleware'] CORS_ALLOW_CREDENTIALS = True ALLOWED_HOSTS = ['*'] CORS_ORIGIN_ALLOW_ALL = True RAVEN_CONFIG = {'dsn': BaseSettings.SENTRY_PRIVATE_DSN} DEFAULT_FROM_EMAIL = values.Value(environ_name='FRONTEND_URI', environ_prefix='')
class Production(Common): ########## INSTALLED_APPS INSTALLED_APPS = Common.INSTALLED_APPS ########## END INSTALLED_APPS ########## SECRET KEY SECRET_KEY = values.SecretValue() ########## END SECRET KEY ########## SITE CONFIGURATION # Hosts/domain names that are valid for this site # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts ALLOWED_HOSTS = ["*"] ########## END SITE CONFIGURATION ########## TEMPLATE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs TEMPLATE_LOADERS = (('django.template.loaders.cached.Loader', ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', )), ) ########## END TEMPLATE CONFIGURATION ########## CACHING # Only do this here. CACHES = values.CacheURLValue(default="memcached://127.0.0.1:11211")
class Test(FragDenStaatBase): CELERY_TASK_ALWAYS_EAGER = True CELERY_TASK_EAGER_PROPAGATES = True ALLOWED_HOSTS = ('localhost', 'testserver') DEBUG = False PASSWORD_HASHERS = [ 'django.contrib.auth.hashers.MD5PasswordHasher', ] MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage' CACHES = values.CacheURLValue('locmem://') TEST_SELENIUM_DRIVER = values.Value('chrome') ROOT_URLCONF = 'tests.urls' GEOIP_PATH = None DATABASES = values.DatabaseURLValue( 'postgis://*****:*****@localhost:5432/fragdenstaat_de' ) ELASTICSEARCH_INDEX_PREFIX = 'fds_test' ELASTICSEARCH_DSL = { 'default': { 'hosts': 'localhost:9200' }, } FIXTURE_DIRS = [os.path.join(THEME_ROOT, '..', 'tests', 'fixtures')]
class Test(FragDenStaatBase): CELERY_TASK_ALWAYS_EAGER = True CELERY_TASK_EAGER_PROPAGATES = True ALLOWED_HOSTS = ("localhost", "testserver") DEBUG = False PASSWORD_HASHERS = [ "django.contrib.auth.hashers.MD5PasswordHasher", ] MESSAGE_STORAGE = "django.contrib.messages.storage.cookie.CookieStorage" CACHES = values.CacheURLValue("locmem://") TEST_SELENIUM_DRIVER = values.Value("chrome") ROOT_URLCONF = "tests.urls" GEOIP_PATH = None DATABASES = values.DatabaseURLValue( "postgis://*****:*****@localhost:5432/fragdenstaat_at" ) ELASTICSEARCH_INDEX_PREFIX = "fds_test" ELASTICSEARCH_DSL = { "default": { "hosts": "localhost:9200" }, } FIXTURE_DIRS = [os.path.join(THEME_ROOT, "..", "tests", "fixtures")]
class Development(Base): DOTENV = os.path.join(Base.BASE_DIR, '.development') CORS_ORIGIN_ALLOW_ALL = True CACHES = values.CacheURLValue('dummy://') Base.INSTALLED_APPS.insert(0, 'whitenoise.runserver_nostatic')
class Staging(Common): """ The in-staging settings. """ ALLOWED_HOSTS = ['forsa-staging.herokuapp.com', 'staging.forsa.om'] DEBUG = values.BooleanValue(True) DEBUG_TOOLBAR = values.BooleanValue(True) MIDDLEWARE = Common.MIDDLEWARE + [ 'debug_toolbar.middleware.DebugToolbarMiddleware' ] INTERNAL_IPS = values.ListValue() # Security SECURE_BROWSER_XSS_FILTER = values.BooleanValue(True) SECURE_CONTENT_TYPE_NOSNIFF = values.BooleanValue(True) SECURE_REDIRECT_EXEMPT = values.ListValue([]) X_FRAME_OPTIONS = 'DENY' # Amazon S3 settings AWS_ACCESS_KEY_ID = values.Value() AWS_SECRET_ACCESS_KEY = values.Value() AWS_STORAGE_BUCKET_NAME = values.Value() AWS_S3_CUSTOM_DOMAIN = values.Value() AWS_S3_OBJECT_PARAMETERS = { 'CacheControl': 'max-age=86400', } # Static assets AWS_LOCATION = 'static' STATICFILES_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage' STATIC_URL = "https://%s/%s/" % (AWS_S3_CUSTOM_DOMAIN, AWS_LOCATION) # Media assets DEFAULT_FILE_STORAGE = 'forsa.storage_backends.S3HashedFilenameStorage' THUMBNAIL_FORCE_OVERWRITE = True ADMIN_URL = values.Value() CACHES = values.CacheURLValue()
class Production(BaseSettings): DEBUG = values.BooleanValue(False) ALLOWED_HOSTS = values.ListValue( ['*'], environ_prefix="{{cookiecutter.repo_name}}".upper()) SECRET_KEY = values.SecretValue( environ_prefix="{{cookiecutter.repo_name}}".upper()) DATABASES = values.DatabaseURLValue( 'sqlite://dev.db', alias='default', environ_prefix="{{cookiecutter.repo_name}}".upper()) CACHES = values.CacheURLValue( 'locmem://', alias='default', environ_prefix="{{cookiecutter.repo_name}}".upper()) STATICFILES_STORAGE = 'django.contrib.staticfiles.storage.CachedStaticFilesStorage' TEMPLATE_LOADERS = ( #'django.template.loaders.cached.Loader', 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', ) SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
class Base(Configuration): DEBUG = values.BooleanValue(True) DATABASES = values.DatabaseURLValue('spatialite:///dev.db') SPATIALITE_LIBRARY_PATH = '/usr/local/lib/mod_spatialite.dylib' CONN_MAX_AGE = None INSTALLED_APPS = values.ListValue([ 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'django_comments', 'django.contrib.flatpages', 'django.contrib.sitemaps', 'django.contrib.humanize', 'django.contrib.gis', # overwrite management command in # django_elasticsearch_dsl 'froide.helper', # external 'django_elasticsearch_dsl', 'taggit', 'storages', 'treebeard', 'django_filters', 'leaflet', # Semi-external 'filingcabinet', # local 'froide.foirequest', 'froide.foirequestfollower', 'froide.frontpage', 'froide.georegion', 'froide.publicbody', 'froide.document', 'froide.account', 'froide.bounce', 'froide.team', 'froide.foisite', 'froide.problem', 'froide.accesstoken', 'froide.guide', 'froide.comments', 'froide.campaign', # API 'oauth2_provider', 'rest_framework', ]) CACHES = values.CacheURLValue('dummy://') # ############# Site Configuration ######### # Make this unique, and don't share it with anybody. SECRET_KEY = 'make_me_unique!!' SITE_NAME = values.Value('Froide') SITE_EMAIL = values.Value('*****@*****.**') SITE_URL = values.Value('http://*****:*****@example.com'), ) MANAGERS = ADMINS INTERNAL_IPS = values.TupleValue(('127.0.0.1', )) # ############## PATHS ############### PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__)) LOCALE_PATHS = values.TupleValue( (os.path.abspath(os.path.join(PROJECT_ROOT, '..', "locale")), )) GEOIP_PATH = None # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" MEDIA_ROOT = values.Value( os.path.abspath(os.path.join(PROJECT_ROOT, "..", "files"))) # 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 = values.Value('/files/') # Sub path in MEDIA_ROOT that will hold FOI attachments FOI_MEDIA_PATH = values.Value('foi') FOI_MEDIA_URL = values.Value('/files/') FOI_MEDIA_DOMAIN = values.Value('') FOI_MEDIA_TOKENS = False FOI_MEDIA_TOKEN_EXPIRY = 2 * 60 # 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 = values.Value( os.path.abspath(os.path.join(PROJECT_ROOT, "..", "public"))) # Additional locations of static files STATICFILES_DIRS = (os.path.join(PROJECT_ROOT, "static"), ) # ########## URLs ################# ROOT_URLCONF = values.Value('froide.urls') # URL prefix for static files. # Example: "http://media.lawrence.com/static/" # URL that handles the static files like app media. # Example: "http://media.lawrence.com" STATIC_URL = values.Value('/static/') USE_X_ACCEL_REDIRECT = values.BooleanValue(False) X_ACCEL_REDIRECT_PREFIX = values.Value('/protected') # ## URLs that can be translated to a secret value SECRET_URLS = values.DictValue({"admin": "admin"}) # ######## Backends, Finders, Processors, Classes #### AUTH_USER_MODEL = values.Value('account.User') PASSWORD_HASHERS = [ 'django.contrib.auth.hashers.PBKDF2PasswordHasher', 'froide.account.hashers.PBKDF2WrappedSHA1PasswordHasher', ] # List of finder classes that know how to find static files in # various locations. STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'django.contrib.staticfiles.finders.FileSystemFinder', ) TEMPLATES = [{ 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ os.path.join(PROJECT_ROOT, "templates"), ], 'OPTIONS': { 'debug': values.BooleanValue(DEBUG), 'loaders': [ 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', ], 'context_processors': [ 'django.template.context_processors.debug', 'django.template.context_processors.i18n', 'django.template.context_processors.media', 'django.template.context_processors.static', 'django.template.context_processors.request', 'django.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'froide.helper.context_processors.froide', 'froide.helper.context_processors.site_settings', 'froide.helper.context_processors.block_helper' ] } }] MIDDLEWARE = [ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'oauth2_provider.middleware.OAuth2TokenMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] COMMENTS_APP = 'froide.comments' # ######### I18N and L10N ################## # 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 = values.Value('Europe/Berlin') USE_TZ = values.BooleanValue(True) # Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGE_CODE = values.Value('en') LANGUAGES = ( ('en', _('English')), ('es', _('Spanish')), ('fi-fi', _('Finnish (Finland)')), ('de', _('German')), ('da-dk', _('Danish (Denmark)')), ('it', _('Italian')), ('pt', _('Portuguese')), ('sv-se', _('Swedish (Sweden)')), ('sv-fi', _('Swedish (Finland)')), ('zh-cn', _('Chinese (Simplified)')), ('zh-hk', _('Chinese (Traditional, Hong Kong)')), ) # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = values.BooleanValue(True) # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale USE_L10N = values.BooleanValue(True) DATE_FORMAT = values.Value("d. F Y") SHORT_DATE_FORMAT = values.Value("d.m.Y") DATE_INPUT_FORMATS = values.TupleValue(("%d.%m.%Y", )) SHORT_DATETIME_FORMAT = values.Value("d.m.Y H:i") DATETIME_INPUT_FORMATS = values.TupleValue(("%d.%m.%Y %H:%M", )) TIME_FORMAT = values.Value("H:i") TIME_INPUT_FORMATS = values.TupleValue(("%H:%M", )) HOLIDAYS = [ (1, 1), # New Year's Day (12, 25), # Christmas (12, 26) # Second day of Christmas ] # Weekends are non-working days HOLIDAYS_WEEKENDS = True # Calculates other holidays based on easter sunday HOLIDAYS_FOR_EASTER = (0, -2, 1, 39, 50, 60) # ######## Logging ########## # A sample logging configuration. LOGGING = { 'version': 1, 'disable_existing_loggers': True, 'root': { 'level': 'WARNING', 'handlers': [], }, 'filters': { 'require_debug_false': { '()': 'django.utils.log.RequireDebugFalse' } }, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' }, }, 'handlers': { 'mail_admins': { 'level': 'ERROR', 'filters': ['require_debug_false'], 'class': 'django.utils.log.AdminEmailHandler' }, 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', } }, 'loggers': { 'froide': { 'handlers': ['console'], 'propagate': True, 'level': 'DEBUG', }, 'django.request': { 'handlers': ['mail_admins'], 'level': 'ERROR', 'propagate': True, }, 'django.db.backends': { 'level': 'ERROR', 'handlers': ['console'], 'propagate': False, } } } # ######## Security ########### CSRF_COOKIE_SECURE = False CSRF_FAILURE_VIEW = values.Value('froide.account.views.csrf_failure') # Change this # ALLOWED_HOSTS = () ALLOWED_REDIRECT_HOSTS = () SESSION_COOKIE_AGE = values.IntegerValue(3628800) # six weeks SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_SECURE = False # ######## FilingCabinet Document #### # FILINGCABINET_DOCUMENT_MODEL = 'document.Document' # FILINGCABINET_DOCUMENTCOLLECTION_MODEL = 'document.DocumentCollection' FILINGCABINET_DOCUMENT_MODEL = 'document.Document' FILINGCABINET_DOCUMENTCOLLECTION_MODEL = 'document.DocumentCollection' # ######## Celery ############# CELERY_BEAT_SCHEDULE = { 'fetch-mail': { 'task': 'froide.foirequest.tasks.fetch_mail', 'schedule': crontab(), }, 'detect-asleep': { 'task': 'froide.foirequest.tasks.detect_asleep', 'schedule': crontab(hour=0, minute=0), }, 'detect-overdue': { 'task': 'froide.foirequest.tasks.detect_overdue', 'schedule': crontab(hour=0, minute=0), }, 'update-foirequestfollowers': { 'task': 'froide.foirequestfollower.tasks.batch_update', 'schedule': crontab(hour=0, minute=0), }, 'classification-reminder': { 'task': 'froide.foirequest.tasks.classification_reminder', 'schedule': crontab(hour=7, minute=0, day_of_week=6), }, 'bounce-checker': { 'task': 'froide.bounce.tasks.check_bounces', 'schedule': crontab(hour=3, minute=0), }, 'account-maintenance': { 'task': 'froide.account.tasks.account_maintenance_task', 'schedule': crontab(hour=4, minute=0) } } CELERY_TASK_ALWAYS_EAGER = values.BooleanValue(True) CELERY_TASK_ROUTES = { 'froide.foirequest.tasks.fetch_mail': { "queue": "emailfetch" }, 'froide.foirequest.tasks.process_mail': { "queue": "email" }, 'djcelery_email_send_multiple': { "queue": "emailsend" }, 'froide.helper.tasks.*': { "queue": "searchindex" }, } CELERY_TIMEZONE = 'UTC' # We need to serialize email data as binary # which doesn't work well in JSON CELERY_TASK_SERIALIZER = 'pickle' CELERY_RESULT_SERIALIZER = 'pickle' CELERY_ACCEPT_CONTENT = ['pickle'] CELERY_EMAIL_TASK_CONFIG = {'queue': 'emailsend'} # ######## Search ########### ELASTICSEARCH_INDEX_PREFIX = 'froide' ELASTICSEARCH_DSL = { 'default': { 'hosts': 'localhost:9200' }, } ELASTICSEARCH_DSL_SIGNAL_PROCESSOR = 'django_elasticsearch_dsl.signals.RealTimeSignalProcessor' # ######### API ######### # Do not include xml by default, so lxml doesn't need to be present TASTYPIE_DEFAULT_FORMATS = ['json'] OAUTH2_PROVIDER = { 'SCOPES': { 'read:user': _('Access to user status'), 'read:profile': _('Read user profile information'), 'read:email': _('Read user email'), 'read:request': _('Read your (private) requests'), 'make:request': _('Make requests on your behalf'), 'follow:request': _('Follow/Unfollow requests'), } } OAUTH2_PROVIDER_APPLICATION_MODEL = 'account.Application' LOGIN_URL = 'account-login' REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'oauth2_provider.contrib.rest_framework.OAuth2Authentication', 'rest_framework.authentication.SessionAuthentication', ), 'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticatedOrReadOnly', ), 'DEFAULT_PAGINATION_CLASS': 'froide.helper.api_utils.CustomLimitOffsetPagination', 'PAGE_SIZE': 50, 'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend', ), 'DEFAULT_RENDERER_CLASSES': ( 'rest_framework.renderers.JSONRenderer', 'froide.helper.api_renderers.CustomPaginatedCSVRenderer', # 'rest_framework.renderers.BrowsableAPIRenderer', ) } # ######### Froide settings ######## FROIDE_CONFIG = dict( user_can_hide_web=True, public_body_officials_public=True, public_body_officials_email_public=False, request_public_after_due_days=14, payment_possible=True, currency="Euro", default_law=1, search_engine_query= "http://www.google.de/search?as_q=%(query)s&as_epq=&as_oq=&as_eq=&hl=en&lr=&cr=&as_ft=i&as_filetype=&as_qdr=all&as_occt=any&as_dt=i&as_sitesearch=%(domain)s&as_rights=&safe=images", greetings=[rec(r"Dear (?:Mr\.?|Mr?s\.? .*?)")], redact_salutation=r"(?:Mr\.?|Mr?s\.?)", custom_replacements=[], closings=[rec(r"Sincerely yours,?")], public_body_boosts={}, autocomplete_body_boosts={}, dryrun=False, read_receipt=False, delivery_receipt=False, dsn=False, delivery_reporter=None, request_throttle= None, # Set to [(15, 7 * 24 * 60 * 60),] for 15 requests in 7 days dryrun_domain="testmail.example.com", allow_pseudonym=False, doc_conversion_binary=None, # replace with libreoffice instance doc_conversion_call_func=None, # see settings_test for use content_urls={ 'terms': '/terms/', 'privary': '/privacy/', 'about': '/about/', 'help': '/help/', }, message_handlers={ 'email': 'froide.foirequest.message_handlers.EmailMessageHandler' }, max_attachment_size=1024 * 1024 * 10, # 10 MB bounce_enabled=False, bounce_max_age=60 * 60 * 24 * 14, # 14 days bounce_format='bounce+{token}@example.com', auto_reply_subject_regex=rec('^(Auto-?Reply|Out of office)'), auto_reply_email_regex=rec('^auto(reply|responder)@')) TESSERACT_DATA_PATH = values.Value('/usr/local/share/tessdata') # ###### Email ############## # Django settings EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' EMAIL_SUBJECT_PREFIX = values.Value('[Froide] ') SERVER_EMAIL = values.Value('*****@*****.**') DEFAULT_FROM_EMAIL = values.Value('*****@*****.**') # Official Notification Mail goes through # the normal Django SMTP Backend EMAIL_HOST = values.Value("") EMAIL_PORT = values.IntegerValue(587) EMAIL_HOST_USER = values.Value("") EMAIL_HOST_PASSWORD = values.Value("") EMAIL_USE_TLS = values.BooleanValue(True) # Froide special case settings # IMAP settings for fetching mail FOI_EMAIL_PORT_IMAP = values.IntegerValue(993) FOI_EMAIL_HOST_IMAP = values.Value("imap.example.com") FOI_EMAIL_ACCOUNT_NAME = values.Value("*****@*****.**") FOI_EMAIL_ACCOUNT_PASSWORD = values.Value("") FOI_EMAIL_USE_SSL = values.BooleanValue(True) # SMTP settings for sending FoI mail FOI_EMAIL_HOST_USER = values.Value(FOI_EMAIL_ACCOUNT_NAME) FOI_EMAIL_HOST_FROM = values.Value(FOI_EMAIL_HOST_USER) FOI_EMAIL_HOST_PASSWORD = values.Value(FOI_EMAIL_ACCOUNT_PASSWORD) FOI_EMAIL_HOST = values.Value("smtp.example.com") FOI_EMAIL_PORT = values.IntegerValue(587) FOI_EMAIL_USE_TLS = values.BooleanValue(True) # The FoI Mail can use a different account FOI_EMAIL_DOMAIN = values.Value("example.com") FOI_EMAIL_TEMPLATE = None # Example: # FOI_EMAIL_TEMPLATE = lambda user_name, secret: "{username}.{secret}@{domain}" % (user_name, secret, FOI_EMAIL_DOMAIN) # Is the message you can send from fixed # or can you send from any address you like? FOI_EMAIL_FIXED_FROM_ADDRESS = values.BooleanValue(True) BOUNCE_EMAIL_HOST_IMAP = values.Value('') BOUNCE_EMAIL_PORT_IMAP = values.Value(993) BOUNCE_EMAIL_ACCOUNT_NAME = values.Value('') BOUNCE_EMAIL_ACCOUNT_PASSWORD = values.Value('') BOUNCE_EMAIL_USE_SSL = values.Value(False)
class Production(Common): DEBUG = True # This ensures that Django will be able to detect a secure connection # properly on Heroku. SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # INSTALLED_APPS INSTALLED_APPS = Common.INSTALLED_APPS # END INSTALLED_APPS # DATABASE DATABASES = values.DatabaseURLValue('postgres://*****:*****@localhost/marmix', environ_prefix='MARMIX') # END DATABASE # SECRET KEY SECRET_KEY = values.SecretValue(environ_prefix='MARMIX') # END SECRET KEY # django-secure INSTALLED_APPS += ("djangosecure", ) # set this to 60 seconds and then to 518400 when you can prove it works SECURE_HSTS_SECONDS = 60 SECURE_HSTS_INCLUDE_SUBDOMAINS = values.BooleanValue(True) SECURE_FRAME_DENY = values.BooleanValue(True) SECURE_CONTENT_TYPE_NOSNIFF = values.BooleanValue(True) SECURE_BROWSER_XSS_FILTER = values.BooleanValue(True) SESSION_COOKIE_SECURE = values.BooleanValue(False) SESSION_COOKIE_HTTPONLY = values.BooleanValue(True) #SECURE_SSL_REDIRECT = values.BooleanValue(True) # end django-secure # SITE CONFIGURATION # Hosts/domain names that are valid for this site # See https://docs.djangoproject.com/en/1.6/ref/settings/#allowed-hosts ALLOWED_HOSTS = ["*"] # END SITE CONFIGURATION # EMAIL EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend' DEFAULT_FROM_EMAIL = values.Value('MarMix <*****@*****.**>') EMAIL_HOST = values.Value('mx.ga-fl.net') EMAIL_SUBJECT_PREFIX = values.Value('[MarMix] ', environ_prefix='MARMIX') EMAIL_USE_TLS = True # END EMAIL # MSSQL MSSQL_HOST = values.Value('data.marmix.ch', environ_prefix='MARMIX') MSSQL_DATABASE = values.Value('test', environ_prefix='MARMIX') MSSQL_USER = values.Value('test', environ_prefix='MARMIX') MSSQL_PASSWORD = values.SecretValue(environ_prefix='MARMIX') # TEMPLATE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs TEMPLATE_LOADERS = ( ('django.template.loaders.cached.Loader', ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', )), ) # END TEMPLATE CONFIGURATION # CACHING # Only do this here because thanks to django-pylibmc-sasl and pylibmc # memcacheify is painful to install on windows. CACHES = values.CacheURLValue(default="memcached://127.0.0.1:11211", environ_prefix='MARMIX') # END CACHING ACCOUNT_DEFAULT_HTTP_PROTOCOL = 'https' # Your production stuff: Below this line define 3rd party libary settings LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'filters': { 'require_debug_false': { '()': 'django.utils.log.RequireDebugFalse' }, 'require_debug_true': { '()': 'django.utils.log.RequireDebugTrue' }, }, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' }, 'simple': { 'format': '%(levelname)s %(message)s' }, }, 'handlers': { 'mail_admins': { 'level': 'ERROR', 'filters': ['require_debug_false'], 'class': 'django.utils.log.AdminEmailHandler' }, 'file_debug': { 'level': 'INFO', 'filters': ['require_debug_false'], 'class': 'logging.FileHandler', 'filename': '/var/log/marmix/django-debug.log', 'formatter': 'verbose', }, 'console': { 'level': 'DEBUG', 'filters': ['require_debug_true'], 'class': 'logging.StreamHandler', 'formatter': 'simple', }, }, 'loggers': { '': { 'handlers': ['file_debug', 'mail_admins', 'console'], 'level': 'DEBUG', 'propagate': True, }, } }
class Common(Configuration): # APP CONFIGURATION DJANGO_APPS = ( # Default Django apps: 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', # Useful template tags: # 'django.contrib.humanize', # Admin 'django.contrib.admin', ) THIRD_PARTY_APPS = ( 'crispy_forms', # Form layouts 'avatar', # for user avatars 'allauth', # registration 'allauth.account', # registration 'allauth.socialaccount', # registration ) # Apps specific for this project go here. LOCAL_APPS = ( 'users', # custom users app # Your stuff: custom apps go here ) # See: https://docs.djangoproject.com/en/dev/ref/settings/#installed-apps INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + LOCAL_APPS # END APP CONFIGURATION # MIDDLEWARE CONFIGURATION MIDDLEWARE_CLASSES = ( # Make sure djangosecure.middleware.SecurityMiddleware is listed first 'djangosecure.middleware.SecurityMiddleware', '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', ) # END MIDDLEWARE CONFIGURATION # MIGRATIONS CONFIGURATION MIGRATION_MODULES = { 'sites': 'contrib.sites.migrations' } # END MIGRATIONS CONFIGURATION # DEBUG # See: https://docs.djangoproject.com/en/dev/ref/settings/#debug DEBUG = values.BooleanValue(False) # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug TEMPLATE_DEBUG = DEBUG # END DEBUG # SECRET CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#secret-key # Note: This key only used for development and testing. # In production, this is changed to a values.SecretValue() setting SECRET_KEY = values.SecretValue() # END SECRET CONFIGURATION # FIXTURE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-FIXTURE_DIRS FIXTURE_DIRS = ( join(BASE_DIR, 'fixtures'), ) # END FIXTURE CONFIGURATION # EMAIL CONFIGURATION EMAIL_BACKEND = values.Value('django.core.mail.backends.smtp.EmailBackend') # END EMAIL CONFIGURATION # MANAGER CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#admins ADMINS = ( ("""Jay""", '*****@*****.**'), ) # See: https://docs.djangoproject.com/en/dev/ref/settings/#managers MANAGERS = ADMINS # END MANAGER CONFIGURATION # DATABASE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#databases DATABASES = values.DatabaseURLValue(environ_prefix="DJANGO") # END DATABASE CONFIGURATION # CACHING CACHES = values.CacheURLValue(environ_prefix="DJANGO") # END CACHING # GENERAL CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#time-zone TIME_ZONE = 'Europe/Berlin' # See: https://docs.djangoproject.com/en/dev/ref/settings/#language-code LANGUAGE_CODE = 'en-us' # See: https://docs.djangoproject.com/en/dev/ref/settings/#site-id SITE_ID = 1 # See: https://docs.djangoproject.com/en/dev/ref/settings/#use-i18n USE_I18N = True # See: https://docs.djangoproject.com/en/dev/ref/settings/#use-l10n USE_L10N = True # See: https://docs.djangoproject.com/en/dev/ref/settings/#use-tz USE_TZ = True # END GENERAL CONFIGURATION # TEMPLATE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-context-processors TEMPLATE_CONTEXT_PROCESSORS = ( 'django.contrib.auth.context_processors.auth', 'allauth.account.context_processors.account', 'allauth.socialaccount.context_processors.socialaccount', 'django.core.context_processors.debug', 'django.core.context_processors.i18n', 'django.core.context_processors.media', 'django.core.context_processors.static', 'django.core.context_processors.tz', 'django.contrib.messages.context_processors.messages', 'django.core.context_processors.request', # Your stuff: custom template context processers go here ) # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs TEMPLATE_DIRS = ( join(BASE_DIR, 'templates'), ) TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', ) # See: http://django-crispy-forms.readthedocs.org/en/latest/install.html#template-packs CRISPY_TEMPLATE_PACK = 'bootstrap3' # END TEMPLATE CONFIGURATION # STATIC FILE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root STATIC_ROOT = join(os.path.dirname(BASE_DIR), 'staticfiles') # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url STATIC_URL = '/static/' # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS STATICFILES_DIRS = ( join(BASE_DIR, 'static'), ) # See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#staticfiles-finders STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ) # END STATIC FILE CONFIGURATION # MEDIA CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#media-root MEDIA_ROOT = join(BASE_DIR, 'media') # See: https://docs.djangoproject.com/en/dev/ref/settings/#media-url MEDIA_URL = '/media/' # END MEDIA CONFIGURATION # URL Configuration ROOT_URLCONF = 'urls' # See: https://docs.djangoproject.com/en/dev/ref/settings/#wsgi-application WSGI_APPLICATION = 'wsgi.application' # End URL Configuration # AUTHENTICATION CONFIGURATION AUTHENTICATION_BACKENDS = ( 'django.contrib.auth.backends.ModelBackend', 'allauth.account.auth_backends.AuthenticationBackend', ) # Some really nice defaults ACCOUNT_AUTHENTICATION_METHOD = 'username' ACCOUNT_EMAIL_REQUIRED = True ACCOUNT_EMAIL_VERIFICATION = 'mandatory' # END AUTHENTICATION CONFIGURATION # Custom user app defaults # Select the correct user model AUTH_USER_MODEL = 'users.User' LOGIN_REDIRECT_URL = 'users:redirect' LOGIN_URL = 'account_login' # END Custom user app defaults # SLUGLIFIER AUTOSLUG_SLUGIFY_FUNCTION = 'slugify.slugify' # END SLUGLIFIER # LOGGING CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#logging # A sample logging configuration. The only tangible logging # performed by this configuration is to send an email to # the site admins on every HTTP 500 error when DEBUG=False. # See http://docs.djangoproject.com/en/dev/topics/logging for # more details on how to customize your logging configuration. LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'filters': { 'require_debug_false': { '()': 'django.utils.log.RequireDebugFalse' } }, 'handlers': { 'mail_admins': { 'level': 'ERROR', 'filters': ['require_debug_false'], 'class': 'django.utils.log.AdminEmailHandler' } }, 'loggers': { 'django.request': { 'handlers': ['mail_admins'], 'level': 'ERROR', 'propagate': True, }, } } # END LOGGING CONFIGURATION @classmethod def post_setup(cls): cls.DATABASES['default']['ATOMIC_REQUESTS'] = True # Your common stuff: Below this line define 3rd party library settings #CELERY import djcelery djcelery.setup_loader() INSTALLED_APPS += ('djcelery', ) CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler" BROKER_URL = values.SecretValue()
class BaseConfig(Configuration): DEBUG = values.BooleanValue(False) TEMPLATE_DEBUG = values.BooleanValue(DEBUG) DATABASES = values.DatabaseURLValue( 'postgres://%2Fvar%2Flib%2Fpostgresql/sls_blog') SECRET_KEY = values.SecretValue() CACHES = values.CacheURLValue('locmem://default') # Build paths inside the project like this: BASE_DIR / 'subdir'. BASE_DIR = (Path(__file__).parent / '../..').resolve(strict=True) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/ ALLOWED_HOSTS = [] AUTH_USER_MODEL = 'slsblog_auth.User' # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'corsheaders', 'wagtail.contrib.forms', 'wagtail.contrib.redirects', "wagtail.contrib.search_promotions", "wagtail.contrib.modeladmin", 'wagtail.embeds', 'wagtail.sites', 'wagtail.users', 'wagtail.snippets', 'wagtail.documents', 'wagtail.images', 'wagtail.search', 'wagtail.admin', 'wagtail.core', 'modelcluster', 'taggit', 'wagtail.api.v2', 'rest_framework', "channels", "graphql_ws.django", "graphene_django", "grapple", 'sls_blog.auth', 'sls_blog.cms', 'wagtail_headless_preview', ] REST_FRAMEWORK = { 'DEFAULT_PERMISSION_CLASSES': ['rest_framework.permissions.DjangoModelPermissionsOrAnonReadOnly'], 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.BasicAuthentication', 'rest_framework.authentication.SessionAuthentication', 'rest_framework_simplejwt.authentication.JWTAuthentication', ) } MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'wagtail.contrib.redirects.middleware.RedirectMiddleware', ] ROOT_URLCONF = 'sls_blog.urls' WAGTAIL_SITE_NAME = 'Stevenlsjr Blog' WAGTAIL_I18N_ENABLED = True LANGUAGES = WAGTAIL_CONTENT_LANGUAGES = [ ('en-us', _("English (United States)")), ('en-gb', _("English (United Kingdom)")), ('es-es', _("Spanish (Spain)")), ('es-mx', _("Spanish (Mexico)")), ] CORS_ORIGIN_WHITELIST = values.ListValue(default=[]) CORS_ORIGIN_ALLOW_ALL = values.BooleanValue(default=False) 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 = 'sls_blog.wsgi.application' # ASGI_APPLICATION = 'sls_blog.asgi.application' ASGI_APPLICATION = "graphql_ws.django.routing.application" # Password validation # https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators 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', }, ] # Internationalization # https://docs.djangoproject.com/en/3.1/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/3.1/howto/static-files/ DEFAULT_FILE_STORAGE = values.Value( 'django.core.files.storage.FileSystemStorage') STATICFILES_STORAGE = values.Value( 'django.contrib.staticfiles.storage.StaticFilesStorage') AZURE_ACCOUNT_NAME = values.Value(environ_required=False) AZURE_ACCOUNT_KEY = values.Value(environ_required=False) AZURE_CONTAINER = values.Value(environ_required=False) PUBLIC_AZURE_CONTAINER = values.Value(environ_required=False) AZURE_CONNECTION_STRING = values.Value(default=None, environ_required=False) AZURE_CUSTOM_CONNECTION_STRING = values.Value(default=None, environ_required=False) PUBLIC_AZURE_CONTAINER = values.Value(environ_required=False) STATIC_URL = values.Value('/static/') MEDIA_URL = values.Value('/media/') STATIC_ROOT = values.PathValue(BASE_DIR / '.static') MEDIA_ROOT = values.PathValue(BASE_DIR / '.media') def GRAPHENE(self): cfg = { "SCHEMA": "grapple.schema.schema", "MIDDLEWARE": ["grapple.middleware.GrappleMiddleware"], "SUBSCRIPTION_PATH": "/subscriptions" } if self.DEBUG: cfg['MIDDLEWARE'].insert( 0, 'graphene_django.debug.DjangoDebugMiddleware') return cfg GRAPPLE = { 'APPS': { "slsblog_cms": "" }, 'EXPOSE_GRAPHIQL': values.BooleanValue(True) } BASE_URL = values.URLValue('http://localhost:8000') HEADLESS_PREVIEW_CLIENT_URLS = values.DictValue({ 'default': 'http://localhost:3000/preview', }) HEADLESS_PREVIEW_LIVE = values.BooleanValue(True)
class Base(Configuration): DEBUG = values.BooleanValue(True) TEMPLATE_DEBUG = values.BooleanValue(DEBUG) DATABASES = values.DatabaseURLValue('sqlite:///dev.db') CONN_MAX_AGE = None INSTALLED_APPS = values.ListValue([ 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'django_comments', 'django.contrib.flatpages', 'django.contrib.sitemaps', # external 'haystack', 'djcelery', 'taggit', 'floppyforms', 'overextends', 'tastypie', 'tastypie_swagger', 'storages', 'compressor', # local 'froide.foirequest', 'froide.foirequestfollower', 'froide.frontpage', 'froide.publicbody', 'froide.account', 'froide.redaction', 'froide.foisite', 'froide.helper', ]) CACHES = values.CacheURLValue('dummy://') # ############# Site Configuration ######### # Make this unique, and don't share it with anybody. SECRET_KEY = 'make_me_unique!!' SITE_NAME = values.Value('Froide') SITE_EMAIL = values.Value('*****@*****.**') SITE_URL = values.Value('http://*****:*****@example.com'), ) MANAGERS = ADMINS INTERNAL_IPS = values.TupleValue(('127.0.0.1', )) # ############## PATHS ############### PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__)) LOCALE_PATHS = values.TupleValue( (os.path.abspath(os.path.join(PROJECT_ROOT, '..', "locale")), )) GEOIP_PATH = None # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" MEDIA_ROOT = os.path.abspath(os.path.join(PROJECT_ROOT, "..", "files")) # Sub path in MEDIA_ROOT that will hold FOI attachments FOI_MEDIA_PATH = values.Value('foi') # 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.abspath(os.path.join(PROJECT_ROOT, "..", "public")) # Additional locations of static files STATICFILES_DIRS = (os.path.join(PROJECT_ROOT, "static"), ) COMPRESS_ENABLED = values.BooleanValue(False) COMPRESS_JS_FILTERS = ['compressor.filters.jsmin.JSMinFilter'] COMPRESS_CSS_FILTERS = [ 'compressor.filters.css_default.CssAbsoluteFilter', 'compressor.filters.cssmin.CSSMinFilter' ] COMPRESS_PARSER = 'compressor.parser.HtmlParser' # Additional locations of template files TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, "templates"), ) # ########## URLs ################# ROOT_URLCONF = values.Value('froide.urls') # 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 = values.Value('/files/') # URL prefix for static files. # Example: "http://media.lawrence.com/static/" # URL that handles the static files like app media. # Example: "http://media.lawrence.com" STATIC_URL = values.Value('/static/') USE_X_ACCEL_REDIRECT = values.BooleanValue(False) X_ACCEL_REDIRECT_PREFIX = values.Value('/protected') # ## URLs that can be translated to a secret value SECRET_URLS = values.DictValue({"admin": "admin"}) # ######## Backends, Finders, Processors, Classes #### AUTH_USER_MODEL = values.Value('account.User') CUSTOM_AUTH_USER_MODEL_DB = values.Value('') # List of finder classes that know how to find static files in # various locations. STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'django.contrib.staticfiles.finders.FileSystemFinder', 'compressor.finders.CompressorFinder', ) AUTHENTICATION_BACKENDS = [ "froide.helper.auth.EmailBackend", "django.contrib.auth.backends.ModelBackend", ] TEMPLATE_CONTEXT_PROCESSORS = ( '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.contrib.auth.context_processors.auth', 'django.contrib.messages.context_processors.messages', 'froide.helper.context_processors.froide', 'froide.helper.context_processors.site_settings') # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = [ 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', ] MIDDLEWARE_CLASSES = [ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', ] # ######### I18N and L10N ################## # 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 = values.Value('Europe/Berlin') USE_TZ = values.BooleanValue(True) # Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGE_CODE = values.Value('en-us') LANGUAGES = ( ('en', gettext('English')), ('es', gettext('Spanish')), ('fi-fi', gettext('Finnish (Finland)')), ('de', gettext('German')), ('da-dk', gettext('Danish (Denmark)')), ('it', gettext('Italian')), ('pt', gettext('Portuguese')), ('sv-se', gettext('Swedish (Sweden)')), ('sv-fi', gettext('Swedish (Finland)')), ('zh-cn', gettext('Chinese (Simplified)')), ('zh-hk', gettext('Chinese (Traditional, Hong Kong)')), ) # If you set this to False, Django will make some optimizations so as not # to load the internationalization machinery. USE_I18N = values.BooleanValue(True) # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale USE_L10N = values.BooleanValue(True) DATE_FORMAT = values.Value("d. F Y") SHORT_DATE_FORMAT = values.Value("d.m.Y") DATE_INPUT_FORMATS = values.TupleValue(("%d.%m.%Y", )) SHORT_DATETIME_FORMAT = values.Value("d.m.Y H:i") DATETIME_INPUT_FORMATS = values.TupleValue(("%d.%m.%Y %H:%M", )) TIME_FORMAT = values.Value("H:i") TIME_INPUT_FORMATS = values.TupleValue(("%H:%M", )) HOLIDAYS = [ (1, 1), # New Year's Day (12, 25), # Christmas (12, 26) # Second day of Christmas ] # Weekends are non-working days HOLIDAYS_WEEKENDS = True # Calculates other holidays based on easter sunday HOLIDAYS_FOR_EASTER = (0, -2, 1, 39, 50, 60) # ######## Logging ########## # A sample logging configuration. LOGGING = { 'version': 1, 'disable_existing_loggers': True, 'root': { 'level': 'WARNING', 'handlers': [], }, 'filters': { 'require_debug_false': { '()': 'django.utils.log.RequireDebugFalse' } }, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' }, }, 'handlers': { 'mail_admins': { 'level': 'ERROR', 'filters': ['require_debug_false'], 'class': 'django.utils.log.AdminEmailHandler' }, 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', } }, 'loggers': { 'froide': { 'handlers': ['console'], 'propagate': True, 'level': 'DEBUG', }, 'django.request': { 'handlers': ['mail_admins'], 'level': 'ERROR', 'propagate': True, }, 'django.db.backends': { 'level': 'ERROR', 'handlers': ['console'], 'propagate': False, } } } # ######## Security ########### CSRF_COOKIE_SECURE = False CSRF_COOKIE_HTTPONLY = True CSRF_FAILURE_VIEW = values.Value('froide.account.views.csrf_failure') # Change this # ALLOWED_HOSTS = () SESSION_COOKIE_AGE = values.IntegerValue(3628800) # six weeks SESSION_COOKIE_HTTPONLY = True SESSION_COOKIE_SECURE = False # ######## Celery ############# CELERY_RESULT_BACKEND = values.Value( 'djcelery.backends.database:DatabaseBackend') CELERYBEAT_SCHEDULER = values.Value( "djcelery.schedulers.DatabaseScheduler") CELERY_ALWAYS_EAGER = values.BooleanValue(True) CELERY_ROUTES = { 'froide.foirequest.tasks.fetch_mail': { "queue": "emailfetch" }, } CELERY_TIMEZONE = TIME_ZONE # ######## Haystack ########### HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': 'haystack.backends.simple_backend.SimpleEngine', } } # ######### Tastypie ######### TASTYPIE_SWAGGER_API_MODULE = values.Value('froide.urls.v1_api') # ######### Froide settings ######## FROIDE_THEME = None FROIDE_CONFIG = dict( create_new_publicbody=True, publicbody_empty=True, user_can_hide_web=True, public_body_officials_public=True, public_body_officials_email_public=False, request_public_after_due_days=14, payment_possible=True, currency="Euro", default_law=1, search_engine_query= "http://www.google.de/search?as_q=%(query)s&as_epq=&as_oq=&as_eq=&hl=en&lr=&cr=&as_ft=i&as_filetype=&as_qdr=all&as_occt=any&as_dt=i&as_sitesearch=%(domain)s&as_rights=&safe=images", greetings=[rec(u"Dear (?:Mr\.?|Ms\.? .*?)")], closings=[rec(u"Sincerely yours,?")], public_body_boosts={}, dryrun=False, request_throttle= None, # Set to [(15, 7 * 24 * 60 * 60),] for 15 requests in 7 days dryrun_domain="testmail.example.com", allow_pseudonym=False, doc_conversion_binary=None, # replace with libreoffice instance doc_conversion_call_func=None, # see settings_test for use ) # ###### Email ############## # Django settings EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' EMAIL_SUBJECT_PREFIX = values.Value('[Froide] ') SERVER_EMAIL = values.Value('*****@*****.**') DEFAULT_FROM_EMAIL = values.Value('*****@*****.**') # Official Notification Mail goes through # the normal Django SMTP Backend EMAIL_HOST = values.Value("") EMAIL_PORT = values.IntegerValue(587) EMAIL_HOST_USER = values.Value("") EMAIL_HOST_PASSWORD = values.Value("") EMAIL_USE_TLS = values.BooleanValue(True) # Froide special case settings # IMAP settings for fetching mail FOI_EMAIL_PORT_IMAP = values.IntegerValue(993) FOI_EMAIL_HOST_IMAP = values.Value("imap.example.com") FOI_EMAIL_ACCOUNT_NAME = values.Value("*****@*****.**") FOI_EMAIL_ACCOUNT_PASSWORD = values.Value("") FOI_EMAIL_USE_SSL = values.BooleanValue(True) # SMTP settings for sending FoI mail FOI_EMAIL_HOST_USER = values.Value(FOI_EMAIL_ACCOUNT_NAME) FOI_EMAIL_HOST_FROM = values.Value(FOI_EMAIL_HOST_USER) FOI_EMAIL_HOST_PASSWORD = values.Value(FOI_EMAIL_ACCOUNT_PASSWORD) FOI_EMAIL_HOST = values.Value("smtp.example.com") FOI_EMAIL_PORT = values.IntegerValue(537) FOI_EMAIL_USE_TLS = values.BooleanValue(True) # The FoI Mail can use a different account FOI_EMAIL_DOMAIN = values.Value("example.com") FOI_EMAIL_TEMPLATE = None # Example: # FOI_EMAIL_TEMPLATE = lambda user_name, secret: "{username}.{secret}@{domain}" % (user_name, secret, FOI_EMAIL_DOMAIN) # Is the message you can send from fixed # or can you send from any address you like? FOI_EMAIL_FIXED_FROM_ADDRESS = values.BooleanValue(True)
class Production(Common): ########## INSTALLED_APPS INSTALLED_APPS = Common.INSTALLED_APPS ########## END INSTALLED_APPS ########## SECRET KEY SECRET_KEY = values.SecretValue() ########## END SECRET KEY ########## django-secure INSTALLED_APPS += ("djangosecure", ) # set this to 60 seconds and then to 518400 when you can prove it works SECURE_HSTS_SECONDS = 60 SECURE_HSTS_INCLUDE_SUBDOMAINS = values.BooleanValue(True) SECURE_FRAME_DENY = values.BooleanValue(True) SECURE_CONTENT_TYPE_NOSNIFF = values.BooleanValue(True) SECURE_BROWSER_XSS_FILTER = values.BooleanValue(True) SESSION_COOKIE_SECURE = values.BooleanValue(False) SESSION_COOKIE_HTTPONLY = values.BooleanValue(True) SECURE_SSL_REDIRECT = values.BooleanValue(True) ########## end django-secure ########## SITE CONFIGURATION # Hosts/domain names that are valid for this site # See https://docs.djangoproject.com/en/1.6/ref/settings/#allowed-hosts ALLOWED_HOSTS = ["*"] ########## END SITE CONFIGURATION INSTALLED_APPS += ("gunicorn", ) INSTALLED_APPS += ("raven.contrib.django.raven_compat", ) RAVEN_CONFIG = { 'dsn': values.SecretValue(environ_prefix="", environ_name="SENTRY_DSN"), } ########## STORAGE CONFIGURATION # See: http://django-storages.readthedocs.org/en/latest/index.html INSTALLED_APPS += ( 'storages', ) # Set below to 'storages.backends.s3boto.S3BotoStorage' to use S3 # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings DEFAULT_FILE_STORAGE = values.Value(default='django.core.files.storage.FileSystemStorage') STATICFILES_STORAGE = values.Value(default=DEFAULT_FILE_STORAGE) # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings AWS_ACCESS_KEY_ID = values.SecretValue() AWS_SECRET_ACCESS_KEY = values.SecretValue() AWS_STORAGE_BUCKET_NAME = values.SecretValue() AWS_AUTO_CREATE_BUCKET = True AWS_QUERYSTRING_AUTH = False # see: https://github.com/antonagestam/collectfast AWS_PRELOAD_METADATA = True INSTALLED_APPS += ("collectfast", ) # AWS cache settings, don't change unless you know what you're doing: AWS_EXPIREY = 60 * 60 * 24 * 7 AWS_HEADERS = { 'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY, AWS_EXPIREY) } # Set below to 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME to # use S3 # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url STATIC_URL = values.Value(default='/static/') ########## END STORAGE CONFIGURATION ########## EMAIL DEFAULT_FROM_EMAIL = values.Value( '{{cookiecutter.project_name}} <noreply@{{cookiecutter.domain_name}}>') EMAIL_HOST = values.Value('smtp.mandrillapp.com') EMAIL_HOST_PASSWORD = values.SecretValue(environ_name="EMAIL_HOST_PASSWORD") EMAIL_HOST_USER = values.SecretValue(environ_name="EMAIL_HOST_USER") EMAIL_PORT = values.IntegerValue(587, environ_name="EMAIL_PORT") EMAIL_SUBJECT_PREFIX = values.Value('[{{cookiecutter.project_name}}] ', environ_name="EMAIL_SUBJECT_PREFIX") EMAIL_USE_TLS = True SERVER_EMAIL = EMAIL_HOST_USER ########## END EMAIL ########## TEMPLATE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs TEMPLATE_LOADERS = ( ('django.template.loaders.cached.Loader', ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', )), ) ########## END TEMPLATE CONFIGURATION ########## CACHING # Only do this here because thanks to django-pylibmc-sasl and pylibmc memcacheify is painful to install on windows. try: # See: https://github.com/rdegges/django-heroku-memcacheify from memcacheify import memcacheify CACHES = memcacheify() except ImportError: CACHES = values.CacheURLValue(default="memcached://127.0.0.1:11211")
class Production(Common): # This ensures that Django will be able to detect a secure connection # properly on Heroku. SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # INSTALLED_APPS INSTALLED_APPS = Common.INSTALLED_APPS # END INSTALLED_APPS # SECRET KEY SECRET_KEY = values.SecretValue() # END SECRET KEY # django-secure INSTALLED_APPS += ("djangosecure", ) # set this to 60 seconds and then to 518400 when you can prove it works SECURE_HSTS_SECONDS = 60 SECURE_HSTS_INCLUDE_SUBDOMAINS = values.BooleanValue(True) SECURE_FRAME_DENY = values.BooleanValue(True) SECURE_CONTENT_TYPE_NOSNIFF = values.BooleanValue(True) SECURE_BROWSER_XSS_FILTER = values.BooleanValue(True) SESSION_COOKIE_SECURE = values.BooleanValue(False) SESSION_COOKIE_HTTPONLY = values.BooleanValue(True) SECURE_SSL_REDIRECT = values.BooleanValue(True) # end django-secure # SITE CONFIGURATION # Hosts/domain names that are valid for this site # See https://docs.djangoproject.com/en/1.6/ref/settings/#allowed-hosts ALLOWED_HOSTS = ["*"] # END SITE CONFIGURATION INSTALLED_APPS += ("gunicorn", ) # STORAGE CONFIGURATION # See: http://django-storages.readthedocs.org/en/latest/index.html INSTALLED_APPS += ( 'storages', ) # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings STATICFILES_STORAGE = DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings AWS_ACCESS_KEY_ID = values.SecretValue() AWS_SECRET_ACCESS_KEY = values.SecretValue() AWS_STORAGE_BUCKET_NAME = values.SecretValue() AWS_AUTO_CREATE_BUCKET = True AWS_QUERYSTRING_AUTH = False # see: https://github.com/antonagestam/collectfast AWS_PRELOAD_METADATA = True INSTALLED_APPS += ('collectfast', ) # AWS cache settings, don't change unless you know what you're doing: AWS_EXPIRY = 60 * 60 * 24 * 7 AWS_HEADERS = { 'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % ( AWS_EXPIRY, AWS_EXPIRY) } # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url STATIC_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME # END STORAGE CONFIGURATION # EMAIL DEFAULT_FROM_EMAIL = values.Value('VolunteerApp <*****@*****.**>') EMAIL_HOST = values.Value('smtp.sendgrid.com') EMAIL_HOST_PASSWORD = values.SecretValue(environ_prefix="", environ_name="SENDGRID_PASSWORD") EMAIL_HOST_USER = values.SecretValue(environ_prefix="", environ_name="SENDGRID_USERNAME") EMAIL_PORT = values.IntegerValue(587, environ_prefix="", environ_name="EMAIL_PORT") EMAIL_SUBJECT_PREFIX = values.Value('[VolunteerApp] ', environ_name="EMAIL_SUBJECT_PREFIX") EMAIL_USE_TLS = True SERVER_EMAIL = EMAIL_HOST_USER # END EMAIL # TEMPLATE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs TEMPLATE_LOADERS = ( ('django.template.loaders.cached.Loader', ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', )), ) # END TEMPLATE CONFIGURATION # CACHING # Only do this here because thanks to django-pylibmc-sasl and pylibmc # memcacheify is painful to install on windows. try: # See: https://github.com/rdegges/django-heroku-memcacheify from memcacheify import memcacheify CACHES = memcacheify() except ImportError: CACHES = values.CacheURLValue(default="memcached://127.0.0.1:11211")
class Common(Configuration): # You'll likely want to add your own auth model. ADMINS = ( ('Colin Powell', '*****@*****.**'), ) MANAGERS = ADMINS # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(__file__)) sys.path.insert(0, os.path.join(BASE_DIR, 'codeformaine/apps')) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/ # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False ALLOWED_HOSTS = ['.codeformaine.org'] PUBLIC_ROOT = values.Value(os.path.join(BASE_DIR, 'public')) STATIC_ROOT = os.path.join(PUBLIC_ROOT.setup('PUBLIC_ROOT'), 'static') STATIC_URL = '/static/' STATICFILES_DIRS = ( os.path.join(BASE_DIR, "codeformaine/static"), ) MEDIA_ROOT = os.path.join(PUBLIC_ROOT.setup('PUBLIC_ROOT'), 'media') MEDIA_URL = "/media/" ADMIN_MEDIA_PREFIX = "/static/admin/" AWS_ACCESS_KEY_ID=values.Value('thiswontgetyouanywhere') AWS_SECRET_ACCESS_KEY=values.Value('thiswontgetyouanywhere') AWS_HEADERS = {'ExpiresDefault': 'access plus 30 days', 'Cache-Control': 'max-age=86400', } DEFAULT_BUCKET_PATH = "cfm-media" AWS_DEFAULT_DOMAIN = "" AWS_STORAGE_BUCKET_NAME = DEFAULT_BUCKET_PATH DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' DEFAULT_FROM_EMAIL = "Code for Maine <*****@*****.**>" SERVER_EMAIL = "Code for Maine <*****@*****.**>" EMAIL_SUBJECT_PREFIX = '[Code for Maine] ' CONTACT_EMAIL_SUBJECT = "New Message from Code for Maine.org" # Application definition INSTALLED_APPS = ( 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.admin', 'django.contrib.staticfiles', 'django.contrib.redirects', 'django.contrib.sitemaps', 'django.contrib.humanize', 'cms', 'menus', 'sekizai', 'treebeard', 'allauth', 'allauth.account', 'allauth.socialaccount', 'allauth.socialaccount.providers.github', 'allauth.socialaccount.providers.google', 'django_extensions', 'floppyforms', 'avatar', 'bootstrap3', 'markdown_deux', 'easy_thumbnails', 'filer', 'cmsplugin_filer_file', 'cmsplugin_filer_folder', 'cmsplugin_filer_image', 'cmsplugin_filer_teaser', 'cmsplugin_filer_video', 'djangocms_picture', 'djangocms_file', 'djangocms_link', 'djangocms_video', 'djangocms_googlemap', 'djangocms_snippet', 'djangocms_text_ckeditor', 'djangocms_flash', 'aldryn_search', 'storages', 'robots', 'django_nose', 'typogrify', 'brigade', ) TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [ os.path.join(BASE_DIR, "codeformaine/templates") ], 'APP_DIRS': True, 'OPTIONS': { 'context_processors': [ 'django.contrib.auth.context_processors.auth', 'django.template.context_processors.debug', 'django.template.context_processors.i18n', 'django.template.context_processors.media', 'django.template.context_processors.static', 'django.template.context_processors.tz', 'django.template.context_processors.request', 'django.contrib.messages.context_processors.messages', 'sekizai.context_processors.sekizai', 'cms.context_processors.cms_settings', ], }, }, ] MIDDLEWARE_CLASSES = [ 'cms.middleware.utils.ApphookReloadMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.locale.LocaleMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.contrib.redirects.middleware.RedirectFallbackMiddleware', 'cms.middleware.toolbar.ToolbarMiddleware', 'cms.middleware.language.LanguageCookieMiddleware', 'cms.middleware.page.CurrentPageMiddleware', 'cms.middleware.user.CurrentUserMiddleware', 'cms.middleware.toolbar.ToolbarMiddleware', 'cms.middleware.language.LanguageCookieMiddleware', ] THUMBNAIL_PROCESSORS = ( 'easy_thumbnails.processors.colorspace', 'easy_thumbnails.processors.autocrop', 'filer.thumbnail_processors.scale_and_crop_with_subject_location', 'easy_thumbnails.processors.filters', ) DEBUG_TOOLBAR_PANELS = [ 'debug_toolbar.panels.versions.VersionsPanel', 'debug_toolbar.panels.timer.TimerPanel', 'debug_toolbar.panels.settings.SettingsPanel', 'debug_toolbar.panels.headers.HeadersPanel', 'debug_toolbar.panels.request.RequestPanel', #'debug_toolbar.panels.sql.SQLPanel', 'debug_toolbar.panels.staticfiles.StaticFilesPanel', 'debug_toolbar.panels.templates.TemplatesPanel', 'debug_toolbar.panels.cache.CachePanel', 'debug_toolbar.panels.signals.SignalsPanel', 'debug_toolbar.panels.logging.LoggingPanel', #'debug_toolbar.panels.redirects.RedirectsPanel', ] TEXT_HTML_SANITIZE = False CKEDITOR_SETTINGS = { 'language': '{{ language }}', 'skin': 'moono', 'toolbar_CMS': [ ['Bold', 'Italic', 'Underline', 'Strike'], [ 'NumberedList', 'BulletedList', 'Outdent', 'Indent', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock' ], ['Link', 'Unlink'], ['cmsplugins', '-', 'ShowBlocks'], ['Styles'], ['RemoveFormat', 'Source'], ], } STATICFILES_FINDERS = ( "django.contrib.staticfiles.finders.FileSystemFinder", "django.contrib.staticfiles.finders.AppDirectoriesFinder", ) AUTH_PROFILE_MODULE = 'brigade.Worker' AUTHENTICATION_BACKENDS = ( "django.contrib.auth.backends.ModelBackend", "brigade.backends.EmailOrUsernameModelBackend", "allauth.account.auth_backends.AuthenticationBackend",) ROOT_URLCONF = 'codeformaine.urls' WSGI_APPLICATION = 'codeformaine.wsgi.application' DATABASES = values.DatabaseURLValue('sqlite:///{0}'.format( os.path.join(BASE_DIR, 'codeformaine.sqlite3'), environ=True)) NEVERCACHE_KEY = values.Value('Klkjsdfzx*JLSDFLKJSe89230aps=as.sdffslkxvl') CACHES = values.CacheURLValue('dummy://') # set env variable DJANGO_CACHCES=memcached://127.0.0.1:11211 to use Memcached # Internationalization # https://docs.djangoproject.com/en/1.6/topics/i18n/ LANGUAGE_CODE = 'en' CMS_PERMISSION = True CMS_PLACEHOLDER_CONF = {} CMS_TEMPLATES = ( ('default.html', 'Default'), ('homepage.html', 'Homepage'), ) CMS_LANGUAGES = { ## Customize this 'default': { 'public': True, 'hide_untranslated': False, 'redirect_on_fallback': True, }, 1: [ { 'public': True, 'code': 'en', 'hide_untranslated': False, 'name': gettext('en'), 'redirect_on_fallback': True, }, ], } BROKER_URL = values.Value('redis://localhost:6379/0') CELERY_RESULT_BACKEND=values.Value('djcelery.backends.database:DatabaseBackend') CELERY_TIMEZONE = values.Value('UTC') CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml'] from datetime import timedelta CELERYBEAT_SCHEDULE = { 'check-git-repos': { 'task': 'honey.tasks.check_git_repos', 'schedule': timedelta(seconds=60), 'args': () }, } TIME_ZONE = 'America/New_York' USE_I18N = True USE_L10N = True USE_TZ = True SITE_ID = 1 ALLOWED_HOSTS = values.Value('*') SESSION_EXPIRE_AT_BROWSER_CLOSE = True SESSION_SERIALIZER = 'django.contrib.sessions.serializers.PickleSerializer' PROJECT_DIRNAME = BASE_DIR.split(os.sep)[-1] CACHCES='djangopylibmc://127.0.0.1:11211' # Account activations automatically expire after this period ACCOUNT_ACTIVATION_DAYS = 7 LOGIN_EXEMPT_URLS = ['', '/', '/accounts/login/', 'login', '/accounts/signup/'] LOGIN_URL = '/accounts/login/' LOGIN_REDIRECT_URL = '/dashboard/' LOGOUT_URL = '/accounts/logout/' TINYMCE_DEFAULT_CONFIG = { 'theme': "advanced", 'plugins': "table,paste,pasteword,searchreplace,fullscreen", 'theme_advanced_buttons1': 'bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,|,styleselect,formatselect,fontselect,fontsizeselect', 'theme_advanced_buttons2': 'cut,copy,paste,pastetext,pasteword,|,search,replace,|,bullist,numlist,|,outdent,indent,blockquote,|,undo,redo,|,link,unlink,anchor,image,cleanup,help,code,|,insertdate,inserttime,preview,|,forecolor,backcolor', 'theme_advanced_buttons3': 'tablecontrols,|,hr,removeformat,visualaid,|,sub,sup,|,charmap,emotions,iespell,media,advhr,|,fullscreen', 'theme_advanced_toolbar_location': "top", 'theme_advanced_toolbar_align': 'left', 'theme_advanced_resizing': 'true', 'theme_advanced_statusbar_location': 'bottom', 'theme_advanced_resize_horizontal': 'true', 'height': '380', 'width': '100%' } ACCOUNT_ACTIVATION_DAYS = 7 ALDRYN_SEARCH_REGISTER_APPHOOK = True HAYSTACK_ROUTERS = ['aldryn_search.router.LanguageRouter',] HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine', 'PATH': os.path.join(BASE_DIR, 'whoosh_index'), 'STORAGE': 'file', 'POST_LIMIT': 128 * 1024 * 1024, 'INCLUDE_SPELLING': True, 'BATCH_SIZE': 100, }, } # A sample logging configuration. The only tangible logging # performed by this configuration is to send an email to # the site admins on every HTTP 500 error when DEBUG=False. # See http://docs.djangoproject.com/en/dev/topics/logging for # more details on how to customize your logging configuration. LOG_LEVEL = os.getenv('DJANGO_LOG_LEVEL', 'INFO') LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'verbose': { 'format' : "[%(asctime)s] %(levelname)s [%(name)s:%(lineno)s] %(message)s", 'datefmt' : "%d/%b/%Y %H:%M:%S" }, 'simple': { 'format': '%(levelname)s %(message)s' }, }, 'handlers': { 'mail_admins': { 'class': 'django.utils.log.AdminEmailHandler' }, 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'formatter': 'simple' }, 'null': { 'class': 'logging.NullHandler', }, }, 'loggers': { 'django.db.backends': { 'handlers': ['console'], 'level': 'DEBUG', 'propagate': False, }, 'django': { 'handlers': ['console'], 'level': LOG_LEVEL, 'propagate': True, }, 'downloads': { 'handlers': ['console'], 'level': LOG_LEVEL, 'propagate': True, } } }
class Production(Common): # This ensures that Django will be able to detect a secure connection # properly on Heroku. SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # INSTALLED_APPS INSTALLED_APPS = Common.INSTALLED_APPS # END INSTALLED_APPS # SECRET KEY SECRET_KEY = values.SecretValue() # END SECRET KEY # django-secure INSTALLED_APPS += ("djangosecure", ) # set this to 60 seconds and then to 518400 when you can prove it works SECURE_HSTS_SECONDS = 60 SECURE_HSTS_INCLUDE_SUBDOMAINS = values.BooleanValue(True) SECURE_FRAME_DENY = values.BooleanValue(True) SECURE_CONTENT_TYPE_NOSNIFF = values.BooleanValue(True) SECURE_BROWSER_XSS_FILTER = values.BooleanValue(True) SESSION_COOKIE_SECURE = values.BooleanValue(False) SESSION_COOKIE_HTTPONLY = values.BooleanValue(True) SECURE_SSL_REDIRECT = values.BooleanValue(True) # end django-secure # SITE CONFIGURATION # Hosts/domain names that are valid for this site # See https://docs.djangoproject.com/en/1.6/ref/settings/#allowed-hosts ALLOWED_HOSTS = ["*"] # END SITE CONFIGURATION INSTALLED_APPS += ("gunicorn", ) # STORAGE CONFIGURATION # See: http://django-storages.readthedocs.org/en/latest/index.html INSTALLED_APPS += ('storages', ) # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings STATICFILES_STORAGE = DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings AWS_ACCESS_KEY_ID = values.SecretValue() AWS_SECRET_ACCESS_KEY = values.SecretValue() AWS_STORAGE_BUCKET_NAME = values.SecretValue() AWS_AUTO_CREATE_BUCKET = True AWS_QUERYSTRING_AUTH = False # see: https://github.com/antonagestam/collectfast AWS_PRELOAD_METADATA = True INSTALLED_APPS += ("collectfast", ) # AWS cache settings, don't change unless you know what you're doing: AWS_EXPIREY = 60 * 60 * 24 * 7 AWS_HEADERS = { 'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY, AWS_EXPIREY) } # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings try: from S3 import CallingFormat AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN except ImportError: # TODO: Fix this where even if in Dev this class is called. pass # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url STATIC_URL = 'https://%s.s3.amazonaws.com/' % AWS_STORAGE_BUCKET_NAME # END STORAGE CONFIGURATION # S3 DIRECT # AWS configuration values are found under django-storages configuration # The region of your bucket, more info: # http://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region S3DIRECT_REGION = values.SecretValue() INSTALLED_APPS += ('s3direct', ) S3DIRECT_DESTINATIONS = { 'all': ('datapoints/largefiles', ), } # END S3 DIRECT # EMAIL DEFAULT_FROM_EMAIL = values.Value('lackawanna <*****@*****.**>') EMAIL_HOST = values.Value('smtp.sendgrid.com') EMAIL_HOST_PASSWORD = values.SecretValue(environ_prefix="", environ_name="SENDGRID_PASSWORD") EMAIL_HOST_USER = values.SecretValue(environ_prefix="", environ_name="SENDGRID_USERNAME") EMAIL_PORT = values.IntegerValue(587, environ_prefix="", environ_name="EMAIL_PORT") EMAIL_SUBJECT_PREFIX = values.Value('[lackawanna] ', environ_name="EMAIL_SUBJECT_PREFIX") EMAIL_USE_TLS = True SERVER_EMAIL = EMAIL_HOST_USER # END EMAIL # TEMPLATE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs TEMPLATE_LOADERS = (('django.template.loaders.cached.Loader', ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', )), ) # END TEMPLATE CONFIGURATION # CACHING # Only do this here because thanks to django-pylibmc-sasl and pylibmc # memcacheify is painful to install on windows. try: # See: https://github.com/rdegges/django-heroku-memcacheify from memcacheify import memcacheify CACHES = memcacheify() except ImportError: CACHES = values.CacheURLValue(default="memcached://127.0.0.1:11211") # END CACHING # Your production stuff: Below this line define 3rd party libary settings # Custom Authentication process (Admin has to verify the new user) # Customised Account Adapter ACCOUNT_ADAPTER = 'lackawanna.users.adapter.LackawannaAccountAdapter' # REST FRAMEWORK CONFIGURATION REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.BasicAuthentication', 'rest_framework.authentication.SessionAuthentication', ), 'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated', ), 'DEFAULT_FILTER_BACKENDS': ('rest_framework.filters.DjangoFilterBackend', ), 'DATETIME_FORMAT': 'iso-8601', 'DEFAULT_THROTTLE_CLASSES': ('rest_framework.throttling.AnonRateThrottle', 'rest_framework.throttling.UserRateThrottle'), 'DEFAULT_THROTTLE_RATES': { 'anon': '100/day', 'user': '******' } } # END REST FRAMEWORK CONFIGURATION # HAYSTACK CONFIGURATION HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor' HAYSTACK_CONNECTIONS = { 'default': { 'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine', 'URL': 'https://*****:*****@privet-5817764.us-east-1.bonsai.io/', 'INDEX_NAME': 'haystack' }, }
class Production(Common): # INSTALLED_APPS INSTALLED_APPS = Common.INSTALLED_APPS # END INSTALLED_APPS # SECRET KEY SECRET_KEY = values.SecretValue() # END SECRET KEY # django-secure INSTALLED_APPS += ("djangosecure", ) # set this to 60 seconds and then to 518400 when you can prove it works SECURE_HSTS_SECONDS = 60 SECURE_HSTS_INCLUDE_SUBDOMAINS = values.BooleanValue(True) SECURE_FRAME_DENY = values.BooleanValue(True) SECURE_CONTENT_TYPE_NOSNIFF = values.BooleanValue(True) SECURE_BROWSER_XSS_FILTER = values.BooleanValue(True) SESSION_COOKIE_SECURE = values.BooleanValue(False) SESSION_COOKIE_HTTPONLY = values.BooleanValue(True) SECURE_SSL_REDIRECT = values.BooleanValue(True) # end django-secure # SITE CONFIGURATION # Hosts/domain names that are valid for this site # See https://docs.djangoproject.com/en/1.6/ref/settings/#allowed-hosts ALLOWED_HOSTS = [ "client.pawz.co.uk", "provider.pawz.co.uk", "api.pawz.co.uk", "admin.pawz.co.uk", ] # END SITE CONFIGURATION SUBDOMAIN_URLCONFS = { None: 'project.urls', # no subdomain, e.g. ``example.com`` 'client': 'client.urls', 'provider': 'provider.urls', 'api': 'api.urls', 'admin': 'admin.urls', } # INSTALLED_APPS += ("", ) # STORAGE CONFIGURATION # See: http://django-storages.readthedocs.org/en/latest/index.html INSTALLED_APPS += ( # 'storages', ) # EMAIL DEFAULT_FROM_EMAIL = values.Value('Pawz API <*****@*****.**>') EMAIL_HOST = values.Value('smtp.sendgrid.com') EMAIL_HOST_PASSWORD = values.SecretValue(environ_prefix="", environ_name="SENDGRID_PASSWORD") EMAIL_HOST_USER = values.SecretValue(environ_prefix="", environ_name="SENDGRID_USERNAME") EMAIL_PORT = values.IntegerValue(587, environ_prefix="", environ_name="EMAIL_PORT") EMAIL_SUBJECT_PREFIX = values.Value('[Pawz API] ', environ_name="EMAIL_SUBJECT_PREFIX") EMAIL_USE_TLS = True SERVER_EMAIL = EMAIL_HOST_USER # END EMAIL # TEMPLATE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs TEMPLATE_LOADERS = ( ('django.template.loaders.cached.Loader', ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', )), ) # END TEMPLATE CONFIGURATION # CACHING # Only do this here because thanks to django-pylibmc-sasl and pylibmc # memcacheify is painful to install on windows. try: # See: https://github.com/rdegges/django-heroku-memcacheify from memcacheify import memcacheify CACHES = memcacheify() except ImportError: CACHES = values.CacheURLValue(default="memcached://127.0.0.1:11211")
class Dev(Base): # See https://docs.djangoproject.com/en/2.2/topics/cache/#dummy-caching-for-development CACHES = values.CacheURLValue("dummy://") # See http://whitenoise.evans.io/en/stable/django.html#using-whitenoise-in-development Base.INSTALLED_APPS.insert(0, "whitenoise.runserver_nostatic")
class Base(Configuration): # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) VERSION = '0.0.1' # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = values.Value(str(uuid.uuid4())) # SECURITY WARNING: don't run with debug turned on in production! DEBUG = values.BooleanValue(True) ALLOWED_HOSTS = values.ListValue(['api.ghrecommender.localhost']) SESSION_COOKIE_DOMAIN = values.Value('.ghrecommender.localhost') # Application definition INSTALLED_APPS = [ 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django_extensions', 'social_django', 'rest_framework', 'corsheaders', 'subscriptions', 'core', ] MIDDLEWARE = [ 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'corsheaders.middleware.CorsMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', ] ROOT_URLCONF = 'ghrecommender.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 = 'ghrecommender.wsgi.application' # Database # https://docs.djangoproject.com/en/1.10/ref/settings/#databases DATABASES = values.DatabaseURLValue( 'postgres://*****:*****@localhost/github') CACHES = values.CacheURLValue('redis://127.0.0.1:6379/1') SESSION_ENGINE = 'django.contrib.sessions.backends.signed_cookies' # Password validation # https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators 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', }, ] # Internationalization # https://docs.djangoproject.com/en/1.10/topics/i18n/ LANGUAGE_CODE = 'en-us' TIME_ZONE = 'UTC' USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/1.10/howto/static-files/ STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'static') # python-social-auth AUTHENTICATION_BACKENDS = ( 'social_core.backends.github.GithubOAuth2', 'django.contrib.auth.backends.ModelBackend', ) SOCIAL_AUTH_GITHUB_KEY = values.SecretValue() SOCIAL_AUTH_GITHUB_SECRET = values.SecretValue() SOCIAL_AUTH_GITHUB_SCOPE = ['user:email'] SOCIAL_AUTH_LOGIN_REDIRECT_URL = values.Value( 'http://ghrecommender.localhost:3000/app/recommendations/' ) # Frontend app SOCIAL_AUTH_REDIRECT_IS_HTTPS = values.BooleanValue(True) # django-rest-framework CORS_ORIGIN_ALLOW_ALL = False CORS_ALLOW_CREDENTIALS = True CORS_ORIGIN_WHITELIST = values.ListValue(['ghrecommender.localhost:3000']) REST_FRAMEWORK = { 'DEFAULT_AUTHENTICATION_CLASSES': ( 'rest_framework.authentication.SessionAuthentication', 'rest_framework.authentication.BasicAuthentication', ), 'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated', ), 'DEFAULT_PAGINATION_CLASS': 'rest_framework.pagination.LimitOffsetPagination', 'PAGE_SIZE': 100, 'DEFAULT_FILTER_BACKENDS': ('django_filters.rest_framework.DjangoFilterBackend', ), 'DEFAULT_THROTTLE_CLASSES': ( 'rest_framework.throttling.AnonRateThrottle', 'rest_framework.throttling.UserRateThrottle', ), 'DEFAULT_THROTTLE_RATES': { 'anon': '5/minute', 'user': '******', } } REST_FRAMEWORK_EXTENSIONS = { 'DEFAULT_CACHE_ERRORS': False, 'DEFAULT_CACHE_RESPONSE_TIMEOUT': 60 * 1, 'DEFAULT_OBJECT_CACHE_KEY_FUNC': 'rest_framework_extensions.utils.default_object_cache_key_func', } RPC_MODEL_URL = values.Value('http://localhost:4000/jsonrpc') MONGO_HOST = values.Value('127.0.0.1') ADMIN_URL = values.Value('admin')
class TestBase(Base): DEBUG = False @property def TEMPLATES(self): TEMP = super().TEMPLATES TEMP[0]['OPTIONS']['debug'] = True return TEMP def _fake_convert_pdf(self, infile, outpath): _, filename = os.path.split(infile) name, ext = filename.rsplit('.', 1) output = os.path.join(outpath, '%s.pdf' % name) args = ['cp', infile, output] return args, output @property def FROIDE_CONFIG(self): config = dict(super().FROIDE_CONFIG) config.update( dict(doc_conversion_call_func=self._fake_convert_pdf, default_law=10000, greetings=[ rec(r"Dear ((?:Mr\.?|Ms\.?) .*),?"), rec(r'Sehr geehrter? ((Herr|Frau) .*),?') ], closings=[ rec(r"Sincerely yours,?"), rec(r'Mit freundlichen Grüßen') ], public_body_officials_public=False)) return config @property def MEDIA_ROOT(self): return os.path.abspath( os.path.join(super().PROJECT_ROOT, "tests", "testdata")) ALLOWED_HOSTS = ('localhost', 'testserver') ELASTICSEARCH_INDEX_PREFIX = 'froide_test' MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage' CACHES = values.CacheURLValue('locmem://') TEST_SELENIUM_DRIVER = values.Value('chrome_headless') SECRET_URLS = values.DictValue({ "admin": "admin", "postmark_inbound": "postmark_inbound", "postmark_bounce": "postmark_bounce" }) EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' DEFAULT_FROM_EMAIL = '*****@*****.**' FOI_EMAIL_DOMAIN = 'fragdenstaat.de' CELERY_TASK_ALWAYS_EAGER = True CELERY_TASK_EAGER_PROPAGATES = True MIDDLEWARE = [ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', ] FROIDE_CSRF_MIDDLEWARE = 'django.middleware.csrf.CsrfViewMiddleware'
class Base(Core): """Settings that may change per-environment, some with defaults.""" SECRET_KEY = values.SecretValue() DEBUG = values.BooleanValue(default=False) ALLOWED_HOSTS = values.ListValue([]) # The URL under which this instance is running SITE_URL = values.URLValue('http://*****:*****@db/postgres') RQ_QUEUES = { 'default': { 'USE_REDIS_CACHE': 'default', } } CACHES = values.CacheURLValue( 'redis://redis:6379/0', environ_prefix=None, environ_name='REDIS_URL', ) LOGGING_USE_JSON = values.BooleanValue(False) def LOGGING(self): return { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'json': { '()': 'mozilla_cloud_services_logger.formatters.JsonLogFormatter', 'logger_name': 'atmo', }, 'verbose': { 'format': '%(levelname)s %(asctime)s %(name)s %(message)s', }, }, 'handlers': { 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'formatter': 'json' if self.LOGGING_USE_JSON else 'verbose', }, 'sentry': { 'level': 'ERROR', 'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler', }, }, 'loggers': { 'root': { 'level': 'INFO', 'handlers': ['sentry', 'console'], }, 'django.db.backends': { 'level': 'ERROR', 'handlers': ['console'], 'propagate': False, }, 'raven': { 'level': 'DEBUG', 'handlers': ['console'], 'propagate': False, }, 'sentry.errors': { 'level': 'DEBUG', 'handlers': ['console'], 'propagate': False, }, 'atmo': { 'level': 'DEBUG', 'handlers': ['console'], 'propagate': False, }, 'rq': { 'handlers': ['console', 'sentry'], 'level': 'DEBUG', 'propagate': False, }, }, }
class Base(Configuration): u"""Configuração comum para todos os ambientes.""" DEBUG = values.BooleanValue(False) ADMINS = values.SingleNestedTupleValue( (('Sergio Garcia', '*****@*****.**'), )) MANAGERS = values.SingleNestedTupleValue( (('Sergio Garcia', '*****@*****.**'), )) DATABASES = values.DatabaseURLValue( 'postgres://postgres@localhost/postgres') CACHES = values.CacheURLValue('locmem://') EMAIL = values.EmailURLValue('console://') EMAIL_SUBJECT_PREFIX = values.Value('[%s] ' % SITE_NAME) TIME_ZONE = values.Value('America/Sao_Paulo') LANGUAGE_CODE = values.Value('pt-br') USE_I18N = values.BooleanValue(True) USE_L10N = values.BooleanValue(True) USE_TZ = values.BooleanValue(True) MEDIA_ROOT = normpath(join(SITE_ROOT, 'media')) MEDIA_URL = values.Value('/media/') STATIC_ROOT = values.PathValue(normpath(join(SITE_ROOT, 'static'))) STATIC_URL = values.Value('/static/') STATICFILES_DIRS = (normpath(join(SITE_ROOT, 'bower_components')), ) STATICFILES_FINDERS = [ 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ] SECRET_KEY = values.SecretValue() ALLOWED_HOSTS = [] FIXTURE_DIRS = (normpath(join(SITE_ROOT, 'fixtures')), ) TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [normpath(join(SITE_ROOT, 'templates'))], 'APP_DIRS': True, 'OPTIONS': { '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.tz', 'django.contrib.messages.context_processors.messages', 'django.core.context_processors.request', ], 'debug': DEBUG }, }, ] MIDDLEWARE_CLASSES = [ 'corsheaders.middleware.CorsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.locale.LocaleMiddleware', 'gestaolivre.apps.utils.middleware.GlobalRequestMiddleware', ] ROOT_URLCONF = '%s.urls' % SITE_NAME DJANGO_APPS = ('django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.postgres', 'django.contrib.humanize', 'django.contrib.admin', 'mptt', 'django_mptt_admin', 'widget_tweaks', 'brazil_fields') LOCAL_APPS = ( 'gestaolivre.apps.cadastro', 'gestaolivre.apps.utils', ) INSTALLED_APPS = DJANGO_APPS + LOCAL_APPS LOGIN_REDIRECT_URL = '/' 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', }, ] WSGI_APPLICATION = '%s.wsgi.application' % SITE_NAME TEST_RUNNER = 'django.test.runner.DiscoverRunner' MIGRATION_MODULES = {} INSTALLED_APPS += ( 'rest_framework', 'rest_framework_jwt', 'corsheaders', ) REST_FRAMEWORK = values.DictValue({ 'PAGE_SIZE': 10, 'DEFAULT_PERMISSION_CLASSES': ('rest_framework.permissions.IsAuthenticated', ), 'DEFAULT_AUTHENTICATION_CLASSES': ( # 'rest_framework.authentication.SessionAuthentication', # 'rest_framework.authentication.BasicAuthentication', 'rest_framework_jwt.authentication.JSONWebTokenAuthentication', ), }) CORS_ORIGIN_ALLOW_ALL = values.Value(True) CORS_ALLOW_CREDENTIALS = values.Value(True) INSTALLED_APPS += ('compressor', ) STATICFILES_FINDERS += ('compressor.finders.CompressorFinder', ) COMPRESS_PRECOMPILERS = ( ('text/coffeescript', 'coffee --compile --stdio'), ('text/less', 'lessc --source-map-map-inline {infile} {outfile}'), ('text/x-sass', 'sass {infile} {outfile}'), ('text/x-scss', 'sass --scss {infile} {outfile}'), ) JWT_AUTH = values.DictValue({ 'JWT_EXPIRATION_DELTA': datetime.timedelta(minutes=5), 'JWT_REFRESH_EXPIRATION_DELTA': datetime.timedelta(days=7), 'JWT_ALLOW_REFRESH': True, 'JWT_AUTH_HEADER_PREFIX': 'Bearer', 'JWT_RESPONSE_PAYLOAD_HANDLER': jwt_response_payload_handler }) @classmethod def pre_setup(cls): u"""Executado antes da Configuração.""" super(Base, cls).pre_setup() @classmethod def setup(cls): u"""Executado depois da Configuração.""" super(Base, cls).setup() logging.info('Configurações comuns carregadas: %s', cls) @classmethod def post_setup(cls): u"""Executado depois da Configuração.""" super(Base, cls).post_setup() logging.debug("done setting up! \o/")
class Production(Common): ########## INSTALLED_APPS INSTALLED_APPS = Common.INSTALLED_APPS ########## END INSTALLED_APPS ########## SECRET KEY SECRET_KEY = values.SecretValue() ########## END SECRET KEY ########## django-secure INSTALLED_APPS += ("djangosecure", ) # set this to 60 seconds and then to 518400 when you can prove it works SECURE_HSTS_SECONDS = 60 SECURE_HSTS_INCLUDE_SUBDOMAINS = values.BooleanValue(True) SECURE_FRAME_DENY = values.BooleanValue(True) SECURE_CONTENT_TYPE_NOSNIFF = values.BooleanValue(True) SECURE_BROWSER_XSS_FILTER = values.BooleanValue(True) SESSION_COOKIE_SECURE = values.BooleanValue(False) SESSION_COOKIE_HTTPONLY = values.BooleanValue(True) SECURE_SSL_REDIRECT = values.BooleanValue(True) ########## end django-secure ########## SITE CONFIGURATION ALLOWED_HOSTS = ["*"] ########## END SITE CONFIGURATION INSTALLED_APPS += ("gunicorn", ) ########## STORAGE CONFIGURATION INSTALLED_APPS += ('storages', ) STATICFILES_STORAGE = DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' AWS_ACCESS_KEY_ID = values.SecretValue() AWS_SECRET_ACCESS_KEY = values.SecretValue() AWS_STORAGE_BUCKET_NAME = values.SecretValue() AWS_AUTO_CREATE_BUCKET = True AWS_QUERYSTRING_AUTH = False AWS_PRELOAD_METADATA = True INSTALLED_APPS += ("collectfast", ) AWS_EXPIREY = 60 * 60 * 24 * 7 AWS_HEADERS = { 'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY, AWS_EXPIREY) } STATIC_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME ########## END STORAGE CONFIGURATION ########## EMAIL DEFAULT_FROM_EMAIL = values.Value( '{{cookiecutter.project_name}} <{{cookiecutter.project_name}}-noreply@{{cookiecutter.domain_name}}>' ) EMAIL_HOST = values.Value('smtp.sendgrid.com') EMAIL_HOST_PASSWORD = values.SecretValue(environ_prefix="", environ_name="SENDGRID_PASSWORD") EMAIL_HOST_USER = values.SecretValue(environ_prefix="", environ_name="SENDGRID_USERNAME") EMAIL_PORT = values.IntegerValue(587, environ_prefix="", environ_name="EMAIL_PORT") EMAIL_SUBJECT_PREFIX = values.Value('[{{cookiecutter.project_name}}] ', environ_name="EMAIL_SUBJECT_PREFIX") EMAIL_USE_TLS = True SERVER_EMAIL = EMAIL_HOST_USER ########## END EMAIL ########## TEMPLATE CONFIGURATION TEMPLATE_LOADERS = (('django.template.loaders.cached.Loader', ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', )), ) ########## END TEMPLATE CONFIGURATION ########## CACHING CACHES = values.CacheURLValue(default="memcached://127.0.0.1:11211")
class Base(Core): """Configuration that may change per-environment, some with defaults.""" SECRET_KEY = values.SecretValue() DEBUG = values.BooleanValue(default=False) ALLOWED_HOSTS = values.ListValue([]) #: The URL under which this instance is running SITE_URL = values.URLValue('http://*****:*****@db/postgres') REDIS_URL_DEFAULT = 'redis://redis:6379/1' CACHES = values.CacheURLValue( REDIS_URL_DEFAULT, environ_prefix=None, environ_name='REDIS_URL', ) # Use redis as the Celery broker. CELERY_BROKER_URL = os.environ.get('REDIS_URL', REDIS_URL_DEFAULT) LOGGING_USE_JSON = values.BooleanValue(False) def LOGGING(self): return { 'version': 1, 'disable_existing_loggers': False, 'formatters': { 'json': { '()': 'dockerflow.logging.JsonLogFormatter', 'logger_name': 'atmo', }, 'verbose': { 'format': '%(levelname)s %(asctime)s %(name)s %(message)s', }, 'django.server': { '()': 'django.utils.log.ServerFormatter', 'format': '[%(server_time)s] %(message)s', }, }, 'handlers': { 'console': { 'level': 'DEBUG', 'class': 'logging.StreamHandler', 'formatter': 'json' if self.LOGGING_USE_JSON else 'verbose', }, 'sentry': { 'level': 'ERROR', 'class': 'raven.contrib.django.raven_compat.handlers.SentryHandler', }, 'django.server': { 'level': 'INFO', 'class': 'logging.StreamHandler', 'formatter': 'django.server', }, }, 'loggers': { 'root': { 'level': 'INFO', 'handlers': ['sentry', 'console'], }, 'django.db.backends': { 'level': 'ERROR', 'handlers': ['console'], 'propagate': False, }, 'django.server': { 'handlers': ['django.server'], 'level': 'INFO', 'propagate': False, }, 'raven': { 'level': 'DEBUG', 'handlers': ['console'], 'propagate': False, }, 'sentry.errors': { 'level': 'DEBUG', 'handlers': ['console'], 'propagate': False, }, 'atmo': { 'level': 'DEBUG', 'handlers': ['console'], 'propagate': False, }, 'celery.task': { 'level': 'DEBUG', 'handlers': ['console'], 'propagate': False, }, 'redbeat.schedulers': { 'level': 'DEBUG', 'handlers': ['console'], 'propagate': False, }, 'request.summary': { 'level': 'DEBUG', 'handlers': ['console'], 'propagate': False, }, }, }
class ProjectDefault(Configuration): """ The default settings from the Django project template. Django Configurations https://django-configurations.readthedocs.io """ # Build paths inside the project like this: BASE_DIR / "subdir". BASE_DIR = Path(__file__).resolve().parent.parent # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/stable/howto/deployment/checklist/ # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = values.SecretValue() # SECURITY WARNING: don't run with debug turned on in production! DEBUG = values.BooleanValue(True) ALLOWED_HOSTS = values.ListValue([]) # Application definition INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", ] MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "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 = "{{cookiecutter.project_slug}}.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 = "{{cookiecutter.project_slug}}.wsgi.application" # Database # https://docs.djangoproject.com/en/stable/ref/settings/#databases DATABASES = values.DatabaseURLValue() # Password validation # https://docs.djangoproject.com/en/stable/ref/settings/#auth-password-validators # fmt: off AUTH_PASSWORD_VALIDATORS = [ { "NAME": "django.contrib.auth.password_validation.UserAttributeSimilarityValidator", # noqa }, { "NAME": "django.contrib.auth.password_validation.MinimumLengthValidator", }, { "NAME": "django.contrib.auth.password_validation.CommonPasswordValidator", }, { "NAME": "django.contrib.auth.password_validation.NumericPasswordValidator", }, ] # fmt: on # Internationalization # https://docs.djangoproject.com/en/stable/topics/i18n/ LANGUAGE_CODE = "en-us" TIME_ZONE = "UTC" USE_I18N = True USE_L10N = True USE_TZ = True # Static files (CSS, JavaScript, Images) # https://docs.djangoproject.com/en/stable/howto/static-files/ STATIC_URL = "/static/" STATIC_ROOT = BASE_DIR / "static" # Stored files # https://docs.djangoproject.com/en/stable/topics/files/{% if cookiecutter.use_media == "Yes" %} # noqa MEDIA_URL = "/media/" MEDIA_ROOT = BASE_DIR / "media" # noqa{% else %} # MEDIA_URL = "/media/" # MEDIA_ROOT = BASE_DIR / "media"{% endif %} # Email Settings # https://docs.djangoproject.com/en/stable/topics/email/ ADMINS = values.SingleNestedTupleValue( (("admin", "errors@{{cookiecutter.domain_url}}"),) ) DEFAULT_FROM_EMAIL = values.EmailValue("info@{{cookiecutter.domain_url}}") EMAIL_SUBJECT_PREFIX = "[{{cookiecutter.project_name}}] " EMAIL_USE_LOCALTIME = True SERVER_EMAIL = values.EmailValue("server@{{cookiecutter.domain_url}}") # Email URL # https://django-configurations.readthedocs.io/en/stable/values/ EMAIL = values.EmailURLValue("console://") # Cache URL # https://django-configurations.readthedocs.io/en/stable/values/ CACHES = values.CacheURLValue("locmem://") # Translation # https://docs.djangoproject.com/en/stable/topics/i18n/translation/ # LANGUAGES = (("en", "English"), ("it", "Italiano")) # Clickjacking Protection # https://docs.djangoproject.com/en/stable/ref/clickjacking/ X_FRAME_OPTIONS = "SAMEORIGIN" # Default: 'SAMEORIGIN' # Default primary key field type # https://docs.djangoproject.com/en/stable/ref/settings/#default-auto-field DEFAULT_AUTO_FIELD = "django.db.models.BigAutoField" # Session auth # https://docs.djangoproject.com/en/stable/ref/settings/#sessions SESSION_COOKIE_DOMAIN = values.Value()
class Base(Settings): # Django settings for localshop project. PROJECT_ROOT = os.path.dirname(__file__) BASE_DIR = os.path.dirname(os.path.abspath(os.path.join(__file__, '..'))) CACHES = values.CacheURLValue('dummy://') django_debug = os.environ.get('DJANGO_DEBUG', 'False').upper() == 'TRUE' DEBUG = django_debug TEMPLATE_DEBUG = DEBUG ADMINS = ( # ('Your Name', '*****@*****.**'), ) MANAGERS = ADMINS DATABASES = values.DatabaseURLValue( 'sqlite:///' + os.path.join(DEFAULT_PATH, 'localshop.db')) # 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 = values.Value('UTC') # Language code for this installation. All choices can be found here: # http://www.i18nguy.com/unicode/language-identifiers.html LANGUAGE_CODE = 'en-us' 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 # If you set this to False, Django will not format dates, numbers and # calendars according to the current locale. USE_L10N = True # If you set this to False, Django will not use timezone-aware datetimes. USE_TZ = True # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/media/" # MEDIA_ROOT = 'files' MEDIA_ROOT = '/media' # 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 = 'assets' # URL prefix for static files. # Example: "http://media.lawrence.com/static/" STATIC_URL = '/assets/' STATIC_ROOT = values.Value( default=os.path.join(BASE_DIR, 'public', 'static')) # Additional locations of static files STATICFILES_DIRS = [os.path.join(PROJECT_ROOT, 'static')] STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage' # List of finder classes that know how to find static files in # various locations. STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', ) # Make this unique, and don't share it with anybody. SECRET_KEY = values.SecretValue() SESSION_COOKIE_AGE = 28 * 24 * 60 * 60 # 4 weeks # List of callables that know how to import templates from various sources. TEMPLATE_LOADERS = ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', #'django.template.loaders.eggs.Loader', ) 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.contrib.messages.context_processors.messages', ] MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.middleware.http.ConditionalGetMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', ) ROOT_URLCONF = 'localshop.urls' # Python dotted path to the WSGI application used by Django's runserver. WSGI_APPLICATION = 'localshop.wsgi.application' TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, 'templates'), ) MESSAGE_TAGS = {messages.ERROR: 'danger'} BROKER_URL = "django://" CELERY_ACCEPT_CONTENT = ['json'] CELERY_TASK_SERIALIZER = 'json' CELERY_RESULT_SERIALIZER = 'json' CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler' CELERYD_FORCE_EXECV = False CELERYBEAT_SCHEDULE = { # Executes every day at 1:00 AM 'every-day-1am': { 'task': 'localshop.apps.packages.tasks.update_packages', 'schedule': crontab(hour=1, minute=0), }, } INSTALLED_APPS = [ 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', 'django.contrib.admin', 'django.contrib.humanize', 'kombu.transport.django', 'djcelery', 'gunicorn', 'widget_tweaks', 'localshop', 'localshop.apps.accounts', 'localshop.apps.dashboard', 'localshop.apps.packages', 'localshop.apps.permissions', 'raven.contrib.django.raven_compat', ] # Auth settings AUTHENTICATION_BACKENDS = ( 'localshop.apps.accounts.backend.AccessKeyBackend', 'localshop.apps.accounts.backend.LDAPBackend', 'django_auth_ldap.backend.LDAPBackend', 'django.contrib.auth.backends.ModelBackend', ) LOGIN_URL = '/accounts/login' LOGIN_REDIRECT_URL = '/dashboard/' LOGOUT_URL = '/accounts/logout' AUTH_USER_MODEL = 'accounts.User' # A sample logging configuration. The only tangible logging # performed by this configuration is to send an email to # the site admins on every HTTP 500 error when DEBUG=False. # See http://docs.djangoproject.com/en/dev/topics/logging for # more details on how to customize your logging configuration. LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'root': { 'handlers': ['console'], 'propagate': True, 'level': 'DEBUG', }, 'handlers': { 'console': { 'level': 'INFO', 'class': 'logging.StreamHandler' }, }, 'formatters': { 'verbose': { 'format': '%(levelname)s %(asctime)s %(module)s %(process)d %(thread)d %(message)s' }, }, } EMAIL = values.EmailURLValue('smtp://localhost:25/') ALLOWED_HOSTS = ['*'] LOCALSHOP_DELETE_FILES = False DEFAULT_FILE_STORAGE = values.Value( 'storages.backends.overwrite.OverwriteStorage') LOCALSHOP_HTTP_PROXY = None LOCALSHOP_ISOLATED = False LOCALSHOP_RELEASE_OVERWRITE = True # Use X-Forwarded-For header as the source for the client's IP. # Use where you have Nginx/Apache/etc as a reverse proxy infront of Localshop/Gunicorn. LOCALSHOP_USE_PROXIED_IP = False LOCALSHOP_VERSIONING_TYPE = None # AWS S3 Settings AWS_ACCESS_KEY_ID = values.Value() AWS_SECRET_ACCESS_KEY = values.Value() AWS_STORAGE_BUCKET_NAME = values.Value() # LDAP Authentication AUTH_LDAP_GLOBAL_OPTIONS = { ldap.OPT_X_TLS_REQUIRE_CERT: ldap.OPT_X_TLS_NEVER, } AUTH_LDAP_START_TLS = True AUTH_LDAP_SERVER_URI = os.environ.get('AUTH_LDAP_SERVER_URI', 'ldap://ldapsample.com') AUTH_LDAP_BIND_DN = os.environ.get('AUTH_LDAP_BIND_DN', 'cn=username,dc=ldapsample,dc=com') AUTH_LDAP_BIND_PASSWORD = os.environ.get('AUTH_LDAP_BIND_PASSWORD', 'sompass') #AUTH_LDAP_USER_DN_TEMPLATE = "uid=%(user)s,ou=users,dc=ldapsample,dc=com" if 'AUTH_LDAP_USER_DN_TEMPLATE' in os.environ: AUTH_LDAP_USER_DN_TEMPLATE = os.environ['AUTH_LDAP_USER_DN_TEMPLATE'] AUTH_LDAP_USER_SEARCH_BASE = os.environ.get( 'AUTH_LDAP_USER_SEARCH_BASE', 'ou=users,dc=ldapsample,dc=com') AUTH_LDAP_USER_SEARCH_QUERY = os.environ.get('AUTH_LDAP_USER_SEARCH_QUERY', '(uid=%(user)s)') AUTH_LDAP_USER_SEARCH = LDAPSearch(AUTH_LDAP_USER_SEARCH_BASE, ldap.SCOPE_SUBTREE, AUTH_LDAP_USER_SEARCH_QUERY)
class Production(Common): # INSTALLED_APPS INSTALLED_APPS = Common.INSTALLED_APPS # END INSTALLED_APPS # SECRET KEY SECRET_KEY = values.SecretValue() # END SECRET KEY # django-secure INSTALLED_APPS += ("djangosecure", ) # set this to 60 seconds and then to 518400 when you can prove it works SECURE_HSTS_SECONDS = 60 SECURE_HSTS_INCLUDE_SUBDOMAINS = values.BooleanValue(True) SECURE_FRAME_DENY = values.BooleanValue(True) SECURE_CONTENT_TYPE_NOSNIFF = values.BooleanValue(True) SECURE_BROWSER_XSS_FILTER = values.BooleanValue(True) SESSION_COOKIE_SECURE = values.BooleanValue(False) SESSION_COOKIE_HTTPONLY = values.BooleanValue(True) SECURE_SSL_REDIRECT = values.BooleanValue(True) # end django-secure # SITE CONFIGURATION # Hosts/domain names that are valid for this site # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts ALLOWED_HOSTS = ["*"] # END SITE CONFIGURATION INSTALLED_APPS += ("gunicorn", ) # STORAGE CONFIGURATION # See: http://django-storages.readthedocs.org/en/latest/index.html INSTALLED_APPS += ('storages', ) # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings try: from S3 import CallingFormat AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN except ImportError: pass STATICFILES_STORAGE = DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' AWS_ACCESS_KEY_ID = values.SecretValue() AWS_SECRET_ACCESS_KEY = values.SecretValue() AWS_STORAGE_BUCKET_NAME = values.SecretValue() AWS_AUTO_CREATE_BUCKET = True AWS_QUERYSTRING_AUTH = False # see: https://github.com/antonagestam/collectfast AWS_PRELOAD_METADATA = True INSTALLED_APPS += ("collectfast", ) # AWS cache settings, don't change unless you know what you're doing: AWS_EXPIREY = 60 * 60 * 24 * 7 AWS_HEADERS = { 'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % ( AWS_EXPIREY, AWS_EXPIREY) } # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url STATIC_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME # END STORAGE CONFIGURATION # Email DEFAULT_FROM_EMAIL = values.Value('Vault <*****@*****.**>') EMAIL_HOST = values.Value('smtp.sendgrid.com') EMAIL_HOST_PASSWORD = values.SecretValue(environ_prefix="", environ_name="SENDGRID_PASSWORD") EMAIL_HOST_USER = values.SecretValue(environ_prefix="", environ_name="SENDGRID_USERNAME") EMAIL_PORT = values.IntegerValue(587, environ_prefix="", environ_name="EMAIL_PORT") EMAIL_SUBJECT_PREFIX = values.Value('[] ', environ_name="EMAIL_SUBJECT_PREFIX") EMAIL_USE_TLS = True SERVER_EMAIL = DEFAULT_FROM_EMAIL # END EMAIL try: # see: https://github.com/rdegges/django-heroku-memcacheify#install # Avoids installing of pylibmc on development enviroment from memcacheify import memcacheify CACHES = memcacheify() except ImportError: CACHES = values.CacheURLValue(default="memcached://127.0.0.1:11211") # TEMPLATE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs TEMPLATE_LOADERS = ( ('django.template.loaders.cached.Loader', ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', )), ) # END TEMPLATE CONFIGURATION # Your production stuff: Below this line define 3rd party libary settings
class Test(Base): DEBUG = False TEMPLATE_DEBUG = True def _fake_convert_pdf(self, infile, outpath): _, filename = os.path.split(infile) name, ext = filename.rsplit('.', 1) output = os.path.join(outpath, '%s.pdf' % name) args = ['cp', infile, output] return args, output @property def FROIDE_CONFIG(self): config = dict(super(Test, self).FROIDE_CONFIG) config.update( dict(doc_conversion_call_func=self._fake_convert_pdf, default_law=10000, greetings=[ rec(u"Dear ((?:Mr\.?|Ms\.?) .*),?"), rec(u'Sehr geehrter? ((Herr|Frau) .*),?') ], closings=[ rec(u"Sincerely yours,?"), rec(u'Mit freundlichen Grüßen') ], public_body_officials_public=False)) return config @property def MEDIA_ROOT(self): return os.path.abspath( os.path.join(super(Test, self).PROJECT_ROOT, "tests", "testdata")) MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage' CACHES = values.CacheURLValue('locmem://') TEST_SELENIUM_DRIVER = values.Value('phantomjs') USE_X_ACCEL_REDIRECT = True SECRET_URLS = values.DictValue({ "admin": "admin", "postmark_inbound": "postmark_inbound", "postmark_bounce": "postmark_bounce" }) EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' DEFAULT_FROM_EMAIL = '*****@*****.**' FOI_EMAIL_DOMAIN = 'fragdenstaat.de' @property def HAYSTACK_CONNECTIONS(self): return { 'default': { 'ENGINE': 'haystack.backends.whoosh_backend.WhooshEngine', 'PATH': os.path.join( super(Test, self).PROJECT_ROOT, 'tests/froide_test_whoosh_db'), }, } CELERY_RESULT_BACKEND = 'djcelery.backends.database:DatabaseBackend' CELERYBEAT_SCHEDULER = "djcelery.schedulers.DatabaseScheduler" CELERY_ALWAYS_EAGER = True CELERY_EAGER_PROPAGATES_EXCEPTIONS = True 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', ]
class Production(Common): # INSTALLED_APPS INSTALLED_APPS = Common.INSTALLED_APPS # END INSTALLED_APPS # DATABASE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#databases DATABASES = values.DatabaseURLValue( 'postgres://*****:*****@localhost/animate_web') # END DATABASE CONFIGURATION # SECRET KEY SECRET_KEY = 'w)ca-a0xdt1!*m%uf0829_)^&w@(=x&ygzeymy1=1av)z#^*%e' # END SECRET KEY # django-secure INSTALLED_APPS += ( "djangosecure", "s3_folder_storage", # static and media to S3 seperately ) # set this to 60 seconds and then to 518400 when you can prove it works SECURE_HSTS_SECONDS = 60 SECURE_HSTS_INCLUDE_SUBDOMAINS = values.BooleanValue(True) SECURE_FRAME_DENY = values.BooleanValue(True) SECURE_CONTENT_TYPE_NOSNIFF = values.BooleanValue(True) SECURE_BROWSER_XSS_FILTER = values.BooleanValue(True) SESSION_COOKIE_SECURE = values.BooleanValue(False) SESSION_COOKIE_HTTPONLY = values.BooleanValue(True) SECURE_SSL_REDIRECT = values.BooleanValue(True) # end django-secure # SITE CONFIGURATION # Hosts/domain names that are valid for this site # See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts ALLOWED_HOSTS = ["*"] # END SITE CONFIGURATION INSTALLED_APPS += ("gunicorn", ) # STORAGE CONFIGURATION # See: http://django-storages.readthedocs.org/en/latest/index.html INSTALLED_APPS += ('storages', ) # See: http://django-storages.readthedocs.org/en/latest/backends/amazon-S3.html#settings try: from S3 import CallingFormat AWS_CALLING_FORMAT = CallingFormat.SUBDOMAIN except ImportError: pass STATICFILES_STORAGE = DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage' AWS_ACCESS_KEY_ID = values.Value('AKIAIEF4J3Q2TEXCN4PA') AWS_SECRET_ACCESS_KEY = values.Value( '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') AWS_STORAGE_BUCKET_NAME = values.Value('animate_web') AWS_AUTO_CREATE_BUCKET = True AWS_QUERYSTRING_AUTH = False # see: https://github.com/antonagestam/collectfast AWS_PRELOAD_METADATA = True INSTALLED_APPS += ("collectfast", ) # AWS cache settings, don't change unless you know what you're doing: AWS_EXPIREY = 60 * 60 * 24 * 7 AWS_HEADERS = { 'Cache-Control': 'max-age=%d, s-maxage=%d, must-revalidate' % (AWS_EXPIREY, AWS_EXPIREY) } # See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url STATIC_URL = 'https://s3.amazonaws.com/%s/' % AWS_STORAGE_BUCKET_NAME # END STORAGE CONFIGURATION try: # see: https://github.com/rdegges/django-heroku-memcacheify#install # Avoids installing of pylibmc on development enviroment from memcacheify import memcacheify CACHES = memcacheify() except ImportError: CACHES = values.CacheURLValue(default="memcached://127.0.0.1:11211") # TEMPLATE CONFIGURATION # See: https://docs.djangoproject.com/en/dev/ref/settings/#template-dirs TEMPLATE_LOADERS = (('django.template.loaders.cached.Loader', ( 'django.template.loaders.filesystem.Loader', 'django.template.loaders.app_directories.Loader', )), )