new-dawn / new_dawn_server

Backend Repo for 布咕
0 stars 0 forks source link

New Dawn Server Repo

Build Status

Setup

  1. Clone the repo to your local machine by running git clone https://github.com/tangziyi001/new_dawn_server.git
  2. Download virtualenv
  3. Run virtualenv new_dawn to create a virtual env
  4. Activate your virtual env by running source new_dawn/bin/activate
  5. Run pip3 install -r requirements.txt to install dependencies

Run Server & Test API

  1. Run local server ./runserver. This will go through some environment setup.
  2. Get the testing username and apikey from the output. This should be used in your iOS code to test backend requests.
  3. In another terminal session, use curl to GET/POST your request.

Example

{"birthday": "1800-01-01", "date_joined": "2018-12-02T22:33:22.203670", "email": "", "first_name": "ziyi", "gender": "M", "id": 7, "is_active": true, "is_staff": false, "is_superuser": false, "last_login": null, "last_name": "tang", "password": "pbkdf2_sha256$120000$EZGzO2YmhkK6$jgsvSXMXV41gyEVDsWQAgxkn/sT0W+xnZvMYUkNY8DA=", "phone_number": "+11111111111", "username": "goodman"}

Feel free to play with different invalid input to see how the server returns error message.
Except for required fields, there are some optional fields that you can lookup from `users/api/resources.py`

## Dev Basic
* Make sure to re-do the step 4 above before coding. After dev, run `deactivate` to exit the virtual env.
* Please create your own branch by running `git branch <yourname>` and run `git checkout <yourname>` before development. Run `git pull origin master` frequently to make sure that you are in sync with the master branch.
* Commit and push your work by running `git push origin <yourname>` instead of master.
* Send pull request for code review before merging.

## Dev Data Model
* Data models are stored in directories such as `users/models.py`. Make changes you want in `models.py`.
* Run `python3 manage.py makemigrations` and `python3 manage.py migrate`. If everything works fine, you should be able to see the following messages:

(new_dawn) TZY-Mac:new_dawn_server Tang$ python3 manage.py makemigrations Migrations for 'users': new_dawn_server/users/migrations/0002_remove_account_nationality.py

Tests

  1. Unit Test: Run python3 manage.py test.
  2. Integration Test: ./runserver locally. Go to browser to query the endpoint you touched. See if correct data is returned.