2021-01-15 23:01:58 +03:00
# How to Contribute
2021-02-19 00:33:35 +03:00
We welcome pull requests from everyone. We do expect everyone to adhere to the [Mozilla Community Participation Guidelines ](https://www.mozilla.org/en-US/about/governance/policies/participation/ ).
2021-01-15 23:01:58 +03:00
## Setup
This application is composed of two parts: a Django backend (`mentoring/`) and a React frontend (`frontend/`).
### Frontend
To set up the frontend for development, you will need the latest LTS Node installed.
With that, ensure you have [yarn installed ](https://classic.yarnpkg.com/en/docs/install/ ).
Then, in the `frontend` directory, run
```shell
yarn install
```
to install the dependencies.
2021-02-26 21:48:26 +03:00
If you are working on a component (something in `frontend/src/components` ), then you can use the storybook view to focus on only that component:
2021-02-05 20:31:08 +03:00
```shell
2021-02-26 21:48:26 +03:00
yarn storybook
2021-02-05 20:31:08 +03:00
```
To build the full frontend and prepare it for use in a browser (if you're working on views, or on the backend), run
2021-01-15 23:01:58 +03:00
```shell
yarn dev
```
If you are planning to change the backend, this is all you need to do in the `frontend/` directory.
2021-01-20 00:01:06 +03:00
You may need to repeat the last step (`yarn dev`) if you update your working copy to include changes made by others to the frontend.
2021-01-15 23:01:58 +03:00
If you are making changes on the frontend, you can automatically rebuild every time a file changes with
```shell
yarn dev --watch
```
2021-01-20 00:01:06 +03:00
To run the tests,
```shell
yarn test
```
2021-01-15 23:01:58 +03:00
To actually load the frontend in the browser, you'll need to run the backend server, as described in the next section.
### Backend
2021-01-20 00:01:06 +03:00
The backend is a normal Django app, so those familiar with Django should have no difficulty setting it up.
2021-01-15 23:01:58 +03:00
Those unfamiliar can find some background information [here ](https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/development_environment ).
You will need Python installed, at least version 3.6.
Set up a virtualenv, and install the required packages:
```shell
python3 -mvenv sandbox
sandbox/bin/pip install -r requirements.txt
```
2021-01-20 00:01:06 +03:00
The backend defaults to a development configuration, with a local database and local users.
You'll need to set up that database and create a user.
2021-01-15 23:01:58 +03:00
2021-01-20 00:01:06 +03:00
```shell
2021-01-22 18:54:53 +03:00
sandbox/bin/python3 manage.py migrate
2021-01-15 23:01:58 +03:00
```
2021-01-20 00:01:06 +03:00
```shell
2021-01-22 18:54:53 +03:00
sandbox/bin/python3 manage.py createsuperuser
2021-01-20 00:01:06 +03:00
Username: yourname
Email address: (any email address)
Password:
Password (again):
Superuser created successfully.
2021-01-15 23:01:58 +03:00
```
2021-01-20 00:01:06 +03:00
Finally, run the server:
2021-01-15 23:01:58 +03:00
```shell
2021-01-22 18:54:53 +03:00
sandbox/bin/python3 manage.py runserver
2021-01-15 23:01:58 +03:00
```
The result will show a message like
```
Starting development server at http://127.0.0.1:8000/
```
and you can access the server at that URL.
2021-01-20 00:01:06 +03:00
Sign in as the new superuser you have created.
2021-03-10 21:26:56 +03:00
From there, you can create a new non-superuser via the Django admin page, if you would like.
The admin page is available at `/admin` , which must be entered manually.
2021-01-15 23:01:58 +03:00
2021-01-20 00:01:06 +03:00
To run the backend tests,
```shell
2021-01-22 18:54:53 +03:00
sandbox/bin/python3 manage.py test
2021-01-20 00:01:06 +03:00
```
2021-01-15 23:01:58 +03:00
2021-01-20 00:01:06 +03:00
When you return to the project on another day, you need only invoke the `runserver` command.
As you update your working copy to include database changes made by others, you may need to run the `migrate` command again as well.