2019-02-03 19:24:30 +00:00
|
|
|
# Contributing
|
|
|
|
|
2021-10-31 22:11:07 +00:00
|
|
|
Baby Buddy's maintainers accept and encourage contributions via GitHub [Issues](https://github.com/babybuddy/babybuddy/issues)
|
2020-02-07 06:16:57 +00:00
|
|
|
and [Pull Requests](https://github.com/babybuddy/babybuddy/pulls). Maintainers
|
|
|
|
and users may also be found at [babybuddy/Lobby](https://gitter.im/babybuddy/Lobby)
|
2020-01-19 16:49:45 +00:00
|
|
|
on Gitter.
|
2019-02-03 19:24:30 +00:00
|
|
|
|
2021-10-30 21:52:49 +00:00
|
|
|
## Pull request process
|
2019-02-03 19:24:30 +00:00
|
|
|
|
|
|
|
1. Fork this repository and commit your changes.
|
|
|
|
1. Make and commit tests for any new features or major functionality changes.
|
|
|
|
1. Run `gulp lint` and `gulp test` (see [Gulp Commands](#gulp-commands)) and
|
|
|
|
ensure that all tests pass.
|
2021-10-31 22:11:07 +00:00
|
|
|
1. Updated static assets if necessary and commit the `/static` folder (see [`gulp updatestatic`](#updatestatic)).
|
2020-02-07 06:16:57 +00:00
|
|
|
1. Open a [new pull request](https://github.com/babybuddy/babybuddy/compare) against
|
2019-02-03 19:24:30 +00:00
|
|
|
the `master` branch.
|
|
|
|
|
2021-10-31 22:11:07 +00:00
|
|
|
Maintainers will review new pull requests will as soon as possible, and we will
|
|
|
|
do our best to provide feedback and support potential contributors.
|
2019-02-03 19:24:30 +00:00
|
|
|
|
2021-10-30 21:52:49 +00:00
|
|
|
## Translation
|
2019-04-19 03:24:07 +00:00
|
|
|
|
2021-10-30 21:52:49 +00:00
|
|
|
### POEditor
|
2019-04-20 13:38:29 +00:00
|
|
|
|
2021-10-31 22:11:07 +00:00
|
|
|
Baby Buddy uses [POEditor](https://poeditor.com/) for translation contributions.
|
2020-01-19 16:49:45 +00:00
|
|
|
Interested contributors can [join translation of Baby Buddy](https://poeditor.com/join/project/QwQqrpTIzn)
|
2019-04-20 13:38:29 +00:00
|
|
|
for access to a simple, web-based frontend for adding/editing translation files
|
|
|
|
to the project.
|
|
|
|
|
2021-10-30 21:52:49 +00:00
|
|
|
### Manual
|
2019-04-20 13:38:29 +00:00
|
|
|
|
2020-01-19 16:49:45 +00:00
|
|
|
Baby Buddy has support for translation/localization. A manual translation
|
|
|
|
process will look something like this:
|
2019-04-19 03:24:07 +00:00
|
|
|
|
|
|
|
1. Set up a development environment (see [Development](#development) below).
|
2020-01-19 16:49:45 +00:00
|
|
|
|
|
|
|
1. Run `gulp makemessages -l xx` where `xx` is a specific locale code in the
|
2021-10-31 22:11:07 +00:00
|
|
|
[ISO 639-1 format](https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes) (e.g.,
|
|
|
|
"il" for Italian or "es" for Spanish). This creates a new translation file at
|
2020-01-19 16:49:45 +00:00
|
|
|
`locale/xx/LC_MESSAGES/django.po`, or updates one if it exists.
|
|
|
|
|
|
|
|
1. Open the created/updated `django.po` file and update the header template
|
|
|
|
with license and contact info.
|
|
|
|
|
2019-04-19 03:24:07 +00:00
|
|
|
1. Start translating! Each translatable string will have a `msgid` value with
|
|
|
|
the string in English and a corresponding (empty) `msgstr` value where a
|
|
|
|
translated string can be filled in.
|
2020-01-19 16:49:45 +00:00
|
|
|
|
2019-04-19 03:24:07 +00:00
|
|
|
1. Once all strings have been translated, run `gulp compilemessages -l xx` to
|
|
|
|
compile an optimized translation file (`locale/xx/LC_MESSAGES/django.mo`).
|
2020-01-19 16:49:45 +00:00
|
|
|
|
2019-04-19 03:24:07 +00:00
|
|
|
1. To expose the new translation as a user setting, add the locale code to the
|
|
|
|
`LANGUAGES` array in the base settings file (`babybuddy/settings/base.py`).
|
2020-01-19 16:49:45 +00:00
|
|
|
|
2020-07-30 02:48:23 +00:00
|
|
|
1. Check if Plotly offers a translation (in `node_modules/plotly.js/dist/`) for
|
2020-01-19 16:49:45 +00:00
|
|
|
the language. If it does:
|
|
|
|
|
2021-12-21 21:45:50 +00:00
|
|
|
1. Add the Plotly translation file path to [`gulpfile.config.js`](/gulpfile.config.js) in
|
2020-01-20 15:13:12 +00:00
|
|
|
`scriptsConfig.graph`.
|
|
|
|
|
|
|
|
1. Build, collect, and commit the `/static` folder (see
|
2020-01-28 03:48:28 +00:00
|
|
|
[`gulp updatestatic`](#updatestatic)).
|
2020-01-19 16:49:45 +00:00
|
|
|
|
2020-07-30 02:48:23 +00:00
|
|
|
1. Check if Moment offers a translation (in `node_modules/moment/locale/`) for
|
|
|
|
the language. If it does:
|
|
|
|
|
2021-12-21 21:45:50 +00:00
|
|
|
1. Add the Moment translation file path to [`gulpfile.config.js`](/gulpfile.config.js) in
|
2020-07-30 02:48:23 +00:00
|
|
|
`scriptsConfig.vendor`.
|
|
|
|
|
|
|
|
1. Build, collect, and commit the `/static` folder (see
|
|
|
|
[`gulp updatestatic`](#updatestatic)).
|
|
|
|
|
2019-04-19 03:24:07 +00:00
|
|
|
1. Run the development server, log in, and update the user language to test the
|
|
|
|
newly translated strings.
|
|
|
|
|
2020-01-19 16:49:45 +00:00
|
|
|
Once the translation is complete, commit the new files and changes to a fork
|
|
|
|
and [create a pull request](#pull-request-process) for review.
|
2019-04-19 03:24:07 +00:00
|
|
|
|
|
|
|
For more information on the Django translation process, see Django's
|
2020-01-19 16:49:45 +00:00
|
|
|
documentation section: [Translation](https://docs.djangoproject.com/en/3.0/topics/i18n/translation/).
|
2019-04-19 03:24:07 +00:00
|
|
|
|
2019-02-03 19:24:30 +00:00
|
|
|
## Development
|
|
|
|
|
|
|
|
### Requirements
|
|
|
|
|
2020-01-04 14:37:42 +00:00
|
|
|
- Python 3.6+, pip, pipenv
|
2021-11-19 14:38:24 +00:00
|
|
|
- NVM (NodeJS 14.x and NPM 7.x)
|
2019-02-03 19:24:30 +00:00
|
|
|
- Gulp
|
2021-07-06 20:35:40 +00:00
|
|
|
- Possibly `libpq-dev`
|
2021-10-30 21:52:49 +00:00
|
|
|
- This is necessary if `psycopg2` can't find an appropriate prebuilt binary.
|
2019-02-03 19:24:30 +00:00
|
|
|
|
|
|
|
### Installation
|
|
|
|
|
2021-06-16 13:33:21 +00:00
|
|
|
1. Install pipenv per [Installing pipenv](https://pipenv.pypa.io/en/latest/install/#installing-pipenv)
|
2019-02-03 19:24:30 +00:00
|
|
|
|
|
|
|
1. Install required Python packages, including dev packages
|
|
|
|
|
2021-11-19 14:38:24 +00:00
|
|
|
pipenv install --three --dev
|
2019-02-03 19:24:30 +00:00
|
|
|
|
2021-07-06 20:35:40 +00:00
|
|
|
- If this fails, install `libpq-dev` (e.g. `sudo apt install libpq-dev`) and try again.
|
2021-11-19 14:38:24 +00:00
|
|
|
|
|
|
|
1. Installed Node 14.x (if necessary)
|
|
|
|
|
|
|
|
nvm install 14
|
|
|
|
|
|
|
|
1. Activate Node 14.x
|
|
|
|
|
|
|
|
nvm use
|
2021-07-06 20:35:40 +00:00
|
|
|
|
2019-02-03 19:24:30 +00:00
|
|
|
1. Install Gulp CLI
|
|
|
|
|
2021-11-19 14:38:24 +00:00
|
|
|
npm install -g gulp-cli
|
2019-02-03 19:24:30 +00:00
|
|
|
|
|
|
|
1. Install required Node packages
|
|
|
|
|
2021-02-13 05:29:56 +00:00
|
|
|
npm install
|
2019-02-03 19:24:30 +00:00
|
|
|
|
|
|
|
1. Set, at least, the `DJANGO_SETTINGS_MODULE` environment variable
|
|
|
|
|
2021-02-13 05:29:56 +00:00
|
|
|
export DJANGO_SETTINGS_MODULE=babybuddy.settings.development
|
2019-02-03 19:24:30 +00:00
|
|
|
|
|
|
|
This process will differ based on the host OS. The above example is for
|
2021-12-22 16:05:27 +00:00
|
|
|
Linux-based systems. See [Configuration](/configuration) for other
|
2021-10-31 22:11:07 +00:00
|
|
|
settings and methods for defining them.
|
2019-02-03 19:24:30 +00:00
|
|
|
|
|
|
|
1. Migrate the database
|
|
|
|
|
2021-02-13 05:29:56 +00:00
|
|
|
gulp migrate
|
2020-01-29 05:28:23 +00:00
|
|
|
|
|
|
|
1. Create cache table
|
|
|
|
|
2021-02-13 05:29:56 +00:00
|
|
|
gulp createcachetable
|
2019-02-03 19:24:30 +00:00
|
|
|
|
|
|
|
1. Build assets and run the server
|
|
|
|
|
2021-02-13 05:29:56 +00:00
|
|
|
gulp
|
2019-02-03 19:24:30 +00:00
|
|
|
|
|
|
|
This command will also watch for file system changes to rebuild assets and
|
|
|
|
restart the server as needed.
|
|
|
|
|
|
|
|
Open [http://127.0.0.1:8000](http://127.0.0.1:8000) and log in with the default
|
2021-10-31 22:11:07 +00:00
|
|
|
username and password (`admin`/`admin`).
|
2019-02-03 19:24:30 +00:00
|
|
|
|
|
|
|
### Gulp commands
|
|
|
|
|
2021-12-21 21:45:50 +00:00
|
|
|
[`gulpfile.js`](/gulpfile.js) defines Baby Buddy's Gulp commands.
|
2021-10-31 22:11:07 +00:00
|
|
|
|
2021-12-21 21:45:50 +00:00
|
|
|
[`babybuddy/management/commands`](/babybuddy/management/commands) defines Baby Buddy's
|
2021-10-31 22:11:07 +00:00
|
|
|
management commands.
|
2019-02-03 19:24:30 +00:00
|
|
|
|
|
|
|
- [`gulp`](#gulp)
|
|
|
|
- [`gulp build`](#build)
|
|
|
|
- [`gulp clean`](#clean)
|
|
|
|
- [`gulp collectstatic`](#collectstatic)
|
2019-04-19 03:24:07 +00:00
|
|
|
- [`gulp compilemessages`](#compilemessages)
|
2019-02-03 19:24:30 +00:00
|
|
|
- [`gulp coverage`](#coverage)
|
2020-01-29 05:28:23 +00:00
|
|
|
- [`gulp createcachetable`](#createcachetable)
|
2021-12-22 16:32:53 +00:00
|
|
|
- [`gulp docs:build`](#docsbuild)
|
|
|
|
- [`gulp docs:deploy`](#docsdeploy)
|
|
|
|
- [`gulp docs:watch`](#docswatch)
|
2019-02-03 19:24:30 +00:00
|
|
|
- [`gulp extras`](#extras)
|
|
|
|
- [`gulp fake`](#fake)
|
2022-01-13 00:11:07 +00:00
|
|
|
- [`gulp generatescheme`](#generatescheme)
|
2019-02-03 19:24:30 +00:00
|
|
|
- [`gulp lint`](#lint)
|
2019-04-19 03:24:07 +00:00
|
|
|
- [`gulp makemessages`](#makemessages)
|
2019-02-03 19:24:30 +00:00
|
|
|
- [`gulp makemigrations`](#makemigrations)
|
|
|
|
- [`gulp migrate`](#migrate)
|
|
|
|
- [`gulp reset`](#reset)
|
|
|
|
- [`gulp runserver`](#runserver)
|
|
|
|
- [`gulp scripts`](#scripts)
|
|
|
|
- [`gulp styles`](#styles)
|
|
|
|
- [`gulp test`](#test)
|
2020-01-28 03:48:28 +00:00
|
|
|
- [`gulp updatestatic`](#updatestatic)
|
2019-02-03 19:24:30 +00:00
|
|
|
|
|
|
|
#### `gulp`
|
|
|
|
|
|
|
|
Executes the `build` and `watch` commands and runs Django's development server.
|
2020-01-27 16:52:42 +00:00
|
|
|
This command also accepts the special parameter `--ip` for setting the
|
2021-10-31 22:11:07 +00:00
|
|
|
server IP address. See [`gulp runserver`](#runserver) for details.
|
2019-02-03 19:24:30 +00:00
|
|
|
|
|
|
|
#### `build`
|
|
|
|
|
|
|
|
Creates all script, style and "extra" assets and places them in the
|
|
|
|
`babybuddy/static` folder.
|
|
|
|
|
2021-12-22 16:32:53 +00:00
|
|
|
#### `docs:build`
|
|
|
|
|
|
|
|
Builds the documentation site in a local directory (`site` by default).
|
|
|
|
|
|
|
|
#### `docs:deploy`
|
|
|
|
|
|
|
|
Deploys the documentation site to GitHub Pages.
|
|
|
|
|
|
|
|
#### `docs:watch`
|
|
|
|
|
|
|
|
Runs a local server for the documentation site reloading whenever documentation
|
|
|
|
sites files (in the `docs` directory) as modified.
|
|
|
|
|
2019-02-03 19:24:30 +00:00
|
|
|
#### `clean`
|
|
|
|
|
|
|
|
Deletes all build folders and the root `static` folder. Generally this should
|
|
|
|
be run before a `gulp build` to remove previous build files and the generated
|
|
|
|
static assets.
|
|
|
|
|
|
|
|
#### `collectstatic`
|
|
|
|
|
|
|
|
Executes Django's `collectstatic` management task. This task relies on files in
|
|
|
|
the `babybuddy/static` folder, so generally `gulp build` should be run before
|
|
|
|
this command for production deployments. Gulp also passes along
|
|
|
|
non-overlapping arguments for this command, e.g. `--no-input`.
|
|
|
|
|
2020-01-28 03:48:28 +00:00
|
|
|
Note: a `SECRET_KEY` value must be set for this command to work.
|
2020-01-19 16:49:45 +00:00
|
|
|
|
2019-04-19 03:24:07 +00:00
|
|
|
#### `compilemessages`
|
|
|
|
|
2020-01-19 16:49:45 +00:00
|
|
|
Executes Django's `compilemessages` management task. See [django-admin compilemessages](https://docs.djangoproject.com/en/3.0/ref/django-admin/#compilemessages)
|
2019-04-19 03:24:07 +00:00
|
|
|
for more details about other options and functionality of this command.
|
|
|
|
|
2019-02-03 19:24:30 +00:00
|
|
|
#### `coverage`
|
|
|
|
|
2021-10-30 21:52:49 +00:00
|
|
|
Create a test coverage report. See [`.coveragerc`](/.coveragerc) for default
|
2019-02-03 19:24:30 +00:00
|
|
|
settings information.
|
|
|
|
|
2020-01-29 05:28:23 +00:00
|
|
|
#### `createcachetable`
|
|
|
|
|
|
|
|
Executes Django's `createcachetable` management task. See [django-admin createcachetable](https://docs.djangoproject.com/en/3.0/ref/django-admin/#createcachetable)
|
|
|
|
for more details about other options and functionality of this command.
|
|
|
|
|
2019-02-03 19:24:30 +00:00
|
|
|
#### `extras`
|
|
|
|
|
|
|
|
Copies "extra" files (fonts, images and server root contents) to the build
|
|
|
|
folder.
|
|
|
|
|
|
|
|
#### `fake`
|
|
|
|
|
|
|
|
Adds some fake data to the database. By default, ``fake`` creates one child and
|
|
|
|
31 days of random data. Use the `--children` and `--days` flags to change the
|
|
|
|
default values, e.g. `gulp fake --children 5 --days 7` to generate five fake
|
|
|
|
children and seven days of data for each.
|
|
|
|
|
2022-01-13 00:11:07 +00:00
|
|
|
#### `generateschema`
|
|
|
|
|
|
|
|
Updates the [`openapi-schema.yml`](/openapi-schema.yml) file in the project root
|
|
|
|
based on current API functionality.
|
|
|
|
|
2019-02-03 19:24:30 +00:00
|
|
|
#### `lint`
|
|
|
|
|
|
|
|
Executes Python and SASS linting for all relevant source files.
|
|
|
|
|
2019-04-19 03:24:07 +00:00
|
|
|
#### `makemessages`
|
|
|
|
|
2020-01-19 16:49:45 +00:00
|
|
|
Executes Django's `makemessages` management task. See [django-admin makemessages](https://docs.djangoproject.com/en/3.0/ref/django-admin/#makemessages)
|
2019-04-19 03:24:07 +00:00
|
|
|
for more details about other options and functionality of this command. When
|
|
|
|
working on a single translation, the `-l` flag is useful to make message for
|
|
|
|
only that language, e.g. `gulp makemessages -l fr` to make only a French
|
|
|
|
language translation file.
|
|
|
|
|
2019-02-03 19:24:30 +00:00
|
|
|
#### `makemigrations`
|
|
|
|
|
|
|
|
Executes Django's `makemigrations` management task. Gulp also passes along
|
|
|
|
non-overlapping arguments for this command.
|
|
|
|
|
|
|
|
#### `migrate`
|
|
|
|
|
|
|
|
Executes Django's `migrate` management task. In addition to migrating the
|
|
|
|
database, this command creates the default `admin` user. Gulp also passes along
|
|
|
|
non-overlapping arguments for this command.
|
|
|
|
|
|
|
|
#### `reset`
|
|
|
|
|
|
|
|
Resets the database to a default state *with* one fake child and 31 days of
|
|
|
|
fake data.
|
|
|
|
|
|
|
|
#### `runserver`
|
|
|
|
|
2020-01-27 16:52:42 +00:00
|
|
|
Executes Django's `runserver` management task. Gulp passes non-overlapping
|
|
|
|
arguments for this command.
|
|
|
|
|
|
|
|
A special parameter, `--ip`, is also available to set the IP for the server.
|
2021-10-31 22:11:07 +00:00
|
|
|
E.g., execute `gulp runserver --ip 0.0.0.0:8000` to make the server available to
|
2020-01-27 16:52:42 +00:00
|
|
|
other devices on your local network.
|
2019-02-03 19:24:30 +00:00
|
|
|
|
|
|
|
#### `scripts`
|
|
|
|
|
|
|
|
Builds and combines relevant application scripts. Generally this command does
|
|
|
|
not need to be executed independently - see the `build` command.
|
|
|
|
|
|
|
|
#### `styles`
|
|
|
|
|
|
|
|
Builds and combines SASS styles in to CSS files. Generally this command does
|
|
|
|
not need to be executed independently - see the `build` command.
|
|
|
|
|
|
|
|
#### `test`
|
|
|
|
|
|
|
|
Executes Baby Buddy's suite of tests.
|
|
|
|
|
|
|
|
Gulp also passes along non-overlapping arguments for this command, however
|
|
|
|
individual tests cannot be run with this command. `python manage.py test` can be
|
|
|
|
used for individual test execution.
|
2020-01-28 03:48:28 +00:00
|
|
|
|
2021-09-04 03:33:25 +00:00
|
|
|
#### `updateglyphs`
|
|
|
|
|
|
|
|
Downloads generated glyph font files data from [Fonttello](https://fontello.com/)
|
2021-10-30 21:52:49 +00:00
|
|
|
based on [`config.json` file](/babybuddy/static_src/fontello/config.json). This
|
2021-09-04 03:33:25 +00:00
|
|
|
only needs to be run after making changes to the config file.
|
|
|
|
|
2020-01-28 03:48:28 +00:00
|
|
|
#### `updatestatic`
|
|
|
|
|
|
|
|
Rebuilds Baby Buddy's `/static` folder by running the following commands in
|
|
|
|
order:
|
|
|
|
|
|
|
|
- [`lint`](#lint)
|
|
|
|
- [`clean`](#clean)
|
|
|
|
- [`build`](#build)
|
|
|
|
- [`collectstatic`](#collectstatic)
|
|
|
|
|
2021-10-31 22:11:07 +00:00
|
|
|
Execute and commit changes made by this command whenever changing Baby Buddy's
|
|
|
|
frontend code (SASS, JS, etc.).
|
2021-08-30 23:08:32 +00:00
|
|
|
|
|
|
|
### Icon Font
|
|
|
|
|
|
|
|
Baby Buddy uses [Fontello](https://fontello.com/) to build a custom icon font
|
2021-10-30 21:52:49 +00:00
|
|
|
for icons used throughout the application. See [`babybuddy/static_src/fontello`](/babybuddy/static_src/fontello)
|
2021-08-30 23:08:32 +00:00
|
|
|
for further documentation about using the config file with Fontello and license
|
|
|
|
information for fonts used by this application.
|