Skip to content

Settings

Andy Byers edited this page Jun 23, 2019 · 2 revisions

Janeway utilises the Django Framework, and the majority of its settings.py variables are well documented on the Django site.

Secret Key

In our example_settings.py this is set to a random string of characters. Before you put Janeway into a prodction environment you must change this.

Debug

The DEBUG variable determines if Django renders error information rather than a 500 error. Should be True in Development and False in Production.

Allowed Hosts

This setting determines what hosts and domains that Janeway can server. We set this to [*] so that you can add new journals easily, however you can set it to a list of domains that are allowed eg ['www.example.com' 'secure.example.com']. Janeway's middleware handles allowing all hosts by redirecting those that don't match to the DEFAULT_HOST setting (see below).

Templates

The Templates setting is a list of dictionaries that do a couple of things:

  1. Determine which template backend you wish to use (Janeway can currently only use DjangoTemplates).
  2. Determine which directories to look in for templates (you can use this to override templates without actually changing the core of Janeway).
  3. Adds context processors which inject settings into templates.
  4. Loaders - to determine how to load templates into Django (we use a custom middleware loader to ensure that the correct set of templates is loaded for each journal and press).
  5. Builtins - loads a tag, automatically, across all templates.

Settings Export

This list allows us to export settings from settings.py into templates so these variables are available to use in templates.

This project is maintained by Jakub Roztocil - https://github.com/jakubroztocil

Default Host

This is used in the event that someone attempts to hit a domain that isn't yet configured as a journal ie. user attempts to connect to journal_one.example.com but its not set up yet, they will be redirected to the DEFAULT_HOST

This setting should look like: DEFAULT_HOST = 'https://www.example.com'

Databases

We wont go into a full explaination of Databases within Django as its complex and they have written good documentation on it already, however, we will say that although Janeway by default uses MySQL in example_settings, it will work perfectly with other DB backends supported by Django inc:

Locale Paths

This setting is used to find the location of Django Locales files for translating the front end. We automatically add folders for each plugin.

  • LOCALE_PATHS documentation: ttps://docs.djangoproject.com/en/1.11/ref/settings/#locale-paths

Media Root and Media URL

These settings are used to serve media files. In production this folder should be served by your web server (apache/nginx/whatever) as Django isn't suitable for serving content quickly. When DEBUG is set to True, however, Django will server the media folder for you, though you should only use this in the development environment.

Static Root, Staticfiles Dirs and Static URL

These settings are used to server static content, unlike media (which can be uploaded by users), the static folder should be used to store CSS & JS files. Themes each have a build_assets.py which is a file that will generate and/or copy CSS and JS files into the Static Folder.

Summernote Config

For rich HTML fields, Janeway uses DJANGO SUMMERNOTE, and the example settings includes a default config for summernote, you can find out more on their documentation page.

Email Backend et al.

This group of settings allows you to setup email within Janeway/Django. The default Email Backend is SMTP and comes with the following settings:

EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = ''
EMAIL_PORT = ''
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_USE_TLS = True

Information on SMTP details can be found on your Email Provider's website. At Birkbeck we utilise Mailgun for email as its quite easy to setup and doesn't require management of email servers. Django and Janeway also have a backend specifically for Mailgun so email can be setup like this:

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
MAILGUN_ACCESS_KEY = 'key-yourmailgunaccesskey'
MAILGUN_SERVER_NAME = 'example.com'

Django mailgun is maiuntained by Bradley Whittington

Plugin Hooks

The plugin_hooks setting is use to setup plugin's template hooks. When Django is started, each plugin register's its hooks and they are stored in this variable.

Notify Funcs

This works the same as above, but for notification plugins

ORCiD

ORCiD is an identifcation system for academia. Janeway enables you to allow users to login with ORCiD. See the Setting Up ORCiD Login section for more info on how to obtain a Secret and ID for the below settings.

ORCID_API_URL = 'https://pub.orcid.org/v1.2_rc7/'
ORCID_URL = 'https://orcid.org/oauth/authorize'
ORCID_TOKEN_URL = 'https://pub.orcid.org/oauth/token'
ORCID_CLIENT_SECRET = ''
ORCID_CLIENT_ID = ''

S3

Janeway can utilise Amazon's S3 service to store your backups using the backup command. If you want to use S3 for backups, you need to complete the S3 details, you can obtain these from the AWS Console.

S3_ACCESS_KEY = ''
S3_SECRET_KEY = ''
S3_BUCKET_NAME = ''
END_POINT = 'eu-west-2'  # eg. eu-west-1
S3_HOST = 's3.eu-west-2.amazonaws.com'  # eg. s3.eu-west-1.amazonaws.com

Backup

These settings tell the backup command how it should operate

BACKUP_TYPE = 'directory'  # s3 or directory
BACKUP_DIR = '/path/to/backup/dir/'
BACKUP_EMAIL = False  # If set to True, will send an email each time backup is run

If BACKUP_TYPE is set to 'directory' you will need to provide a path in 'BACKUP_DIR' if it is set to 's3' you must have completed the section above.

URL Config

This setting determines if we should use domains or paths to get the current journal or press

URL_CONFIG = 'domain'  # path or domain

See more information on our path based journals page.

Recaptcha

Recaptcha (v2) is a system used to stop bots from submitting form data to your server. You don't have to use it but it is highly recommended.

All you need to do is add a label, select reCAPTCHA V2 and add a list of domains you will use it with. If you have already added reCAPTCHA you can supplement an existing domain list with the new ones you require.

CAPTCHA_TYPE = 'select a value'  # should be either simple_math or recaptcha to enable captcha fields
RECAPTCHA_PRIVATE_KEY = 'your private key'
RECAPTCHA_PUBLIC_KEY = 'your public key'

Wiki has moved to read the docs.

Clone this wiki locally