Skip to content

Commit

Permalink
Merge branch 'release/v17.11.22'
Browse files Browse the repository at this point in the history
  • Loading branch information
ivan-c committed Dec 5, 2017
2 parents 6cd3e5e + 783153c commit 2d7d46d
Show file tree
Hide file tree
Showing 148 changed files with 29,671 additions and 2,954 deletions.
12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,22 +42,22 @@ env:
matrix:
include:
- env: TOXENV=py27
- env: TOXENV=translations PERSISTENCE_FILE="https://raw.githubusercontent.com/uwcirg/TrueNTH-USA-site-config/develop/site_persistence_file.json"
- env: TOXENV=translations PERSISTENCE_FILE="https://raw.githubusercontent.com/uwcirg/ePROMs-site-config/develop/site_persistence_file.json"
- env: TOXENV=translations PERSISTENCE_DIR="gil"
- env: TOXENV=translations PERSISTENCE_DIR="eproms"
- env: TOXENV=docs
services: []
addons: {}
- env: TOXENV=build
- env: TOXENV=build-artifacts
services:
- docker
addons: {}
- env: TOXENV=ui
addons:
postgresql: "9.4"
sauce_connect: true
# Build artifacts only (no testing)
allow_failures:
- env: TOXENV=ui
- env: TOXENV=build-artifacts

before_install:
# Fetch all remote branches instead of just the currently checked out one
Expand Down Expand Up @@ -94,7 +94,7 @@ deploy:
- develop
- master
condition:
- $TOXENV = build
- $TOXENV = build-artifacts
- -v ARTIFACTORY_API_KEY
- -v ARTIFACTORY_DEB_REPO
script:
Expand All @@ -111,7 +111,7 @@ deploy:
- develop
- master
condition:
- $TOXENV = build
- $TOXENV = build-artifacts
- -v ARTIFACTORY_API_KEY
script:
- ./bin/docker-push.sh
Expand Down
43 changes: 29 additions & 14 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -108,30 +108,45 @@ Write to the respective GOOGLE\_CONSUMER\_KEY and
GOOGLE\_CONSUMER\_SECRET variables in the same ``application.cfg``
configuration file.

Install the Lastest Package (and Dependencies)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Install the Lastest Package and Dependencies (by hand)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To update your Shared Services installation run the ``deploy.sh`` script
as described below.
Instruct ``pip`` to install the correct version of all dependencies into the
virtual environment. This idempotent step can be run anytime to confirm the
correct libraries are installed:

.. code:: bash
pip install -r requirements.txt
Sync Database and Config Files (by hand)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

This script will: \* Update the project with the latest code \* Install
any dependencies, if necessary \* Perform any database migrations, if
necessary \* Seed any new data to the database, if necessary \* Restart
apache, if served by apache
The idempotent ``sync`` function takes necessary steps to build tables,
upgrade the database schema and run ``seed`` to populate with static data.
Safe to run on existing or brand new databases.

.. code:: bash
$ cd $PROJECT_HOME
$ ./bin/deploy.sh -fv # -f to force a run, -v for verbose output
FLASK_APP=manage.py flask sync
Install the Lastest Package, Dependencies and Syncronize DB (via script)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To update your Shared Services installation run the ``deploy.sh`` script
(this step replaces the two previous hand run steps).

This script will:

When running deploy.sh for the first time, add the -i flag to initialize
the database. Do not add this flag when running deploy.sh on a working
database.
* Update the project with the latest code
* Install any dependencies, if necessary
* Perform any database migrations, if necessary
* Seed any new data to the database, if necessary

.. code:: bash
$ cd $PROJECT_HOME
$ ./bin/deploy.sh -fvi # -i to initialize the database
$ ./bin/deploy.sh
To see all available options run:

Expand Down
6 changes: 3 additions & 3 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
"description": "Fully qualified domain name of system, excluding protocol (HTTP/S). See App Name",
"value": "HEROKU_APP_NAME.herokuapp.com"
},
"PERSISTENCE_FILE": {
"description": "Site-specific configuration file, defaults to TrueNTH",
"value": "https://raw.githubusercontent.com/uwcirg/TrueNTH-USA-site-config/develop/site_persistence_file.json"
"PERSISTENCE_DIR": {
"description": "Site-specific configuration directory, defaults to gil",
"value": "gil"
}
},
"addons": [
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ENV \
PORT="${PORT:-8008}" \
FLASK_APP="${PROJECT_DIR}/bin/manage.py" \
PATH="${PROJECT_DIR}/bin:${PATH}" \
PERSISTENCE_FILE="${PERSISTENCE_FILE:-https://raw.githubusercontent.com/uwcirg/TrueNTH-USA-site-config/develop/site_persistence_file.json}"
PERSISTENCE_DIR="${PERSISTENCE_DIR:-gil}"

EXPOSE "${PORT}"

Expand Down
2 changes: 1 addition & 1 deletion docker/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ services:
env_file:
- portal.env
environment:
- PERSISTENCE_FILE=${PERSISTENCE_FILE:-https://raw.githubusercontent.com/uwcirg/TrueNTH-USA-site-config/develop/site_persistence_file.json}
- PERSISTENCE_DIR=${PERSISTENCE_DIR:-gil}
- PGUSER=${PGUSER:-postgres}
- PGPASSWORD=${PGPASSWORD:-""}
- PGHOST=${PGHOST:-db}
Expand Down
1 change: 1 addition & 0 deletions docs/source/code.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ below by module.
:maxdepth: 2

portal
portal_config
portal_models
portal_views
45 changes: 20 additions & 25 deletions docs/source/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -32,19 +32,20 @@ class. Most are self explanitory or include inline comments for clarification.
Of special note, the one used to control which set of values are pulled in
by `Site Persistence`_.

PERSISTENCE_FILE::
PERSISTENCE_DIR::

See also Site Persistence, this controls which persistence file the
`FLASK_APP=manage.py flask seed` command uses to load persistence data and build
the `site.cfg` file.
See also Site Persistence, this controls which persistence directory the
`FLASK_APP=manage.py flask sync` command uses to load persistence data
and build the `site.cfg` file. The value is relative to the
`portal/config` directory.

For TrueNTH:

PERSISTENCE_FILE='https://raw.githubusercontent.com/uwcirg/TrueNTH-USA-site-config/master/site_persistence_file.json'
PERSISTENCE_DIR='gil'

For ePROMs:

PERSISTENCE_FILE='https://raw.githubusercontent.com/uwcirg/ePROMs-site-config/master/site_persistence_file.json'
PERSISTENCE_DIR='eproms'

Site Persistence
================
Expand All @@ -64,34 +65,28 @@ will include codified business rules and required data to support them.

Database tables included:

- Organizations
- Interventions
- AccessStrategies
- AppText
- CommunicationRequest
- Interventions
- Organizations
- Questionnaires
- QuestionnaireBanks
- ScheduledJobs

Both importing and exporting use the value of ``PERSISTENCE_FILE``.
Its value is initially looked up in the configuration file(s) and subsequently
as an environment variable - with the first well defined value taking
precedence.
Both importing and exporting use the value of ``PERSISTENCE_DIR``.
Its value is initially looked for as an environment variable, and if not
found, the configuration value of 'GIL' is used. (With 'GIL' set, the `gil`
configuration directory is used, othersise, `eproms`).

Export
------
A site persistence file can be generated by setting the config value
`PERSISTENCE_FILE` to any writable file on the local filesystem, and executing:
Site persistence files can be generated in the ``PERSISTENCE_DIR``. See
above for correct setting. To generate persistence files from current
database values, execute::

```FLASK_APP=manage.py flask export_site```

The resulting file can be added to a repository for ease of use by other users.
Existing repositories include:

- `TrueNTH-site-config <https://github.com/uwcirg/TrueNTH-USA-site-config>`_
- `ePROMs-site-config <https://github.com/uwcirg/ePROMs-site-config>`_

.. note::

For exports, **PERSISTENCE_FILE** must point to a writable file on the local
filesystem.

Import
------
As a final step in the ``seed`` process, site persistence brings the
Expand Down
45 changes: 0 additions & 45 deletions docs/source/development.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,51 +15,6 @@ System-specific text (app_text)

`app_text <configuration.html#apptext>`_

Internationalization (i18n)
===========================
We use gettext for this within python files; we also use `Liferay to manage content in different languages <http://tiny.cc/truenth_liferay#heading=h.ei0lyxrk4ix0>`_.

Surround all strings with ``_( )`` and it will automatically attempt to find a translation, like:

| _('CELLPHONE')
This should automatically be available in any template file.

.. note::

we are moving to a model where en_US is used as the key here, with no
need to use an english .po file.*

For adding new translations, you need to add the blank translation to the .pot file:

| # <optional comment pointing to where in the code the translation is used>
| msgid "Cellphone"
| msgstr ""
You can create a new .pot file with all extracted translations from the code by running the following pybabel command:

$ pybabel extract -F instance/babel.cfg -o portal/translations/messages.pot portal/

You should then update the .pot file with all translation strings from the apptext/interventions tables using the following:

$ FLASK_APP=manage.py flask translations

You can then use pybabel to update existing .po translation files (this command will only add new translations, it won't remove or modify any existing ones). For example, to update the en_AU translation file::

$ pybabel update -i portal/translations/messages.pot -d portal/translations -l en_AU --no-wrap

Next, update the new translations in the .po file with the output string:

| # <optional comment pointing to where in the code the translation is used>
| msgid "Cellphone"
| msgstr "Mobile"
Finally, compile all existing .po files into .mo files::

$ pybabel compile -f -d portal/translations/


Outside documentation `jinja i18n-extension <http://jinja.pocoo.org/docs/dev/extensions/#i18n-extension>`_ and `gettext <https://docs.python.org/dev/library/gettext.html>`_

System-specific pages
=====================
Expand Down
1 change: 1 addition & 0 deletions docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Contents:
user_experience
sessions
development
internationalization
code
docker
contributing
55 changes: 55 additions & 0 deletions docs/source/internationalization.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
Internationalization
********************

.. contents::
:depth: 3
:local:

Indicating Translatable Strings
===============================
We use gettext for this within python files; we also use `Liferay to manage content in different languages <http://tiny.cc/truenth_liferay#heading=h.ei0lyxrk4ix0>`_.

Surround all strings with ``_( )`` and it will automatically attempt to find a translation, like:

| _('CELLPHONE')
This should automatically be available in any template file.

.. note::

we are moving to a model where en_US is used as the key here, with no
need to use an english .po file.*

For adding new translations, you need to add the blank translation to the .pot file:

| # <optional comment pointing to where in the code the translation is used>
| msgid "Cellphone"
| msgstr ""
Updating Translation Files
==========================
GNU Gettext translation files consist of a single Portable Object Template file (POT file) and Portable Object (PO file) for each localization (language).

Updating POT files
------------------
To update the .pot file with all source strings from the apptext/interventions tables run the following command::

$ FLASK_APP=manage.py flask translations

Updating PO files
-----------------
To update the PO files with the latest translations from Smartling, run the following command::

$ FLASK_APP=manage.py flask translation_download

Initializing Translation Files
==============================
You can create a new .pot file with all extracted translations from the code by running the following pybabel command::

$ pybabel extract -F instance/babel.cfg -o portal/translations/messages.pot portal/

External Documentation
======================
`jinja i18n-extension <http://jinja.pocoo.org/docs/dev/extensions/#i18n-extension>`_

`gettext <https://docs.python.org/dev/library/gettext.html>`_
6 changes: 0 additions & 6 deletions docs/source/portal.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,9 @@ Portal
.. automodule:: portal.celery_worker
:members:
.. automodule:: portal.config
:members:

.. automodule:: portal.extensions
:members:

.. automodule:: portal.site_persistence
:members:

.. automodule:: portal.system_uri
:members:

Expand Down
7 changes: 7 additions & 0 deletions docs/source/portal_config.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Portal.Config
=============
.. automodule:: portal.config.config
:members:

.. automodule:: portal.config.site_persistence
:members:
1 change: 0 additions & 1 deletion instance/application.cfg.default
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ FB_CONSUMER_KEY = '<App ID from Facebook>'
FB_CONSUMER_SECRET = '<App Secret from Facebook>'
GOOGLE_CONSUMER_KEY = '<App ID from Google>'
GOOGLE_CONSUMER_SECRET = '<App Secret from Google>'
PERSISTENCE_FILE='https://raw.githubusercontent.com/uwcirg/TrueNTH-USA-site-config/master/site_persistence_file.json'
SQLALCHEMY_DATABASE_URI = 'postgresql://user:password@localhost/dbname'
SERVER_NAME = '<the name and port number of the server (e.g.: 'myapp.dev:5000')>'
CONTACT_SENDTO_EMAIL = '<email address(es) that should receive contact form submissions>'
Loading

0 comments on commit 2d7d46d

Please sign in to comment.