Giter Club home page Giter Club logo

core_main_app's Introduction

Core Main App

This Django reusable app contains the main functionalities for the curator core project.

Pre-requisites

For automated and manual install, the following software are needed:

  • python
  • pip
  • virtual env (conda or venv)

In addition, for manual setup, git is needed.

Installation

Automated installation

$ pip install core_main_app

Manual installation

$ git clone https://github.com/usnistgov/core_main_app.git
$ cd core_main_app
$ python setup.py
$ pip install sdist/*.tar.gz

Configuration

Edit the setting.py file

Add the "core_main_app" and "tz_detect" under INSTALLED_APPS as such:

INSTALLED_APPS = [
    ...
    "tz_detect",
    "core_main_app",
]

Add the middleware required by tz_detect:

MIDDLEWARE = (
    ...
    'tz_detect.middleware.TimezoneMiddleware',
)

Edit the urls.py file

Add the core_main_app urls to the Django project as such.

url(r'^', include("core_main_app.urls")),

Internationalization (i18n)

Before running the project, don't forget to compile the translation file at project level. i18n uses the gettext package, so please make sure it is installed prior to using this command.

$ python manage.py compilemessages

Enable SSL connection

Please follow these steps to configure the connection to any system running over HTTPS (including the local instance).

  • Create a folder for SSL certificates,
  • Copy the certificate in the folder,
  • Run c_rehash on the folder (needs to be done every time a new certificate is added to the folder),
  • Update the SSL_CERTIFICATES_DIR setting to point to the SSL certificate folder previously created.
$ mkdir certs
$ cp cdcs.crt certs/
$ c_rehash certs/

Enable Redis Server authentication

Please follow these steps to enable authentication on the redis server. Depending on the way Redis is started on the machine, the method may differ.

You can follow instructions at https://redis.io/topics/security#authentication-feature to enable authentication: * Open the file redis.conf (e.g. /usr/local/etc/redis.conf), * Uncomment the authentication setting (# requirepass foobared), * It is recommended to replace the default password (foobared) by a strong and long password, * Restart the Redis Server.

You should then update the CDCS settings using a Redis connection URL with the password chosen in the previous steps.

BROKER_URL = 'redis://:<password>@localhost:6379/0'
CELERY_RESULT_BACKEND = 'redis://:<password>@localhost:6379/0'

Enable SMTP server

Please follow these steps to configure the SMTP server:

  • Set these constants in your setting.py file (all these constants are required)
EMAIL_HOST = 'smtp.myserver.com'
EMAIL_PORT = 587
DEFAULT_FROM_EMAIL = 'TestSite Team <[email protected]>'
  • These optional constants can be added in your setting.py according to your SMTP server configuration
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'testsite_app'
EMAIL_HOST_PASSWORD = 'mys3cr3tp4ssw0rd'

Enable History

Django Simple History allows keeping track of changes made to an object stored in the CDCS database. First, install and configure the package. See the django-simple-history documentation.

Then, set the DJANGO_SIMPLE_HISTORY_MODELS setting with a list of models to track. At the moment, this feature is only available for the Data model.

DJANGO_SIMPLE_HISTORY_MODELS=["Data"]

Register models to track by updating project files. For example in mdcs/mdcs_home/admin.py, add the following lines:

from core_main_app.utils.admin_site.model_admin_class import register_simple_history_models
from django.conf import settings

DJANGO_SIMPLE_HISTORY_MODELS = getattr(settings, "DJANGO_SIMPLE_HISTORY_MODELS", None)
register_simple_history_models(DJANGO_SIMPLE_HISTORY_MODELS)

Documentation

Documentation has been generated using Sphinx. To generate a local version of the docs, please clone the repository and run:

$ cd docs/
$ make html

Or, directly using Sphinx:

$ cd docs/
$ sphinx-build -b html . ../dist/_docs

Development

Development version

A development version of this package is available, containing tests and formatting dependencies. To automatically install the development version, run:

$ pip install .[develop]

The development dependencies are located in requirements.dev.txt and can be installed manually using:

$ pip install -r requirements.dev.txt

Code formatting

To ensure consistent formatting across the codebase, the development team is using black. When contributing to this package, install black as part of the development packages and run black /path/to/core_main_app before submitting the contribution.

Tests

To play the test suite created for this package, download the git repository, install the development dependencies and run:

$ python runtests.py

Sending email

To test the email being sent, console backend will print the email instead of sending the real email. By default, the console backend writes to stdout

To specify this backend, add the following in your settings:

EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'

core_main_app's People

Contributors

alidaoudi1 avatar augustinchini avatar guillaume-sousa avatar knc6 avatar pdessauw avatar pierre-rigodiat avatar xavierschmitt avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.