Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 71b234d
Showing
41 changed files
with
1,286 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
[run] | ||
branch = True | ||
omit = *migrations*, | ||
*urls*, | ||
*test*, | ||
*admin*, | ||
./manage.py, | ||
./piedpiper/config/*, | ||
./piedpiper/wsgi.py, | ||
*__init__* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.* | ||
!.coveragerc | ||
!.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
.hypothesis/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
.static_storage/ | ||
.media/ | ||
local_settings.py | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# pyenv | ||
.python-version | ||
|
||
# celery beat schedule file | ||
celerybeat-schedule | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# django staticfiles | ||
/static | ||
|
||
# mypy | ||
.mypy_cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
sudo: required | ||
language: python | ||
services: | ||
- docker | ||
python: | ||
- "3.6" | ||
before_script: | ||
- docker-compose build | ||
script: | ||
- docker-compose run --rm web bash -c "flake8 . && | ||
python wait_for_postgres.py && | ||
./manage.py test" | ||
|
||
notifications: | ||
email: false | ||
|
||
cache: | ||
pip: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
FROM python:3.6 | ||
ENV PYTHONUNBUFFERED 1 | ||
|
||
# Allows docker to cache installed dependencies between builds | ||
COPY ./requirements.txt requirements.txt | ||
RUN pip install -r requirements.txt | ||
|
||
# Adds our application code to the image | ||
COPY . code | ||
WORKDIR code | ||
|
||
EXPOSE 8000 | ||
|
||
# Run the production server | ||
CMD newrelic-admin run-program gunicorn --bind 0.0.0.0:$PORT --access-logfile - piedpiper.wsgi:application |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# piedpiper-web | ||
|
||
[![Build Status](https://travis-ci.org/agconti/piedpiper-web.svg?branch=master)](https://travis-ci.org/agconti/piedpiper-web) | ||
[![Built with](https://img.shields.io/badge/Built_with-Cookiecutter_Django_Rest-F7B633.svg)](https://github.com/agconti/cookiecutter-django-rest) | ||
|
||
Its all about a Weissman score > 5.0. Check out the project's [documentation](http://agconti.github.io/piedpiper-web/). | ||
|
||
# Prerequisites | ||
|
||
- [Docker](https://docs.docker.com/docker-for-mac/install/) | ||
|
||
# Local Development | ||
|
||
Start the dev server for local development: | ||
```bash | ||
docker-compose up | ||
``` | ||
|
||
Run a command inside the docker container: | ||
|
||
```bash | ||
docker-compose run --rm web [command] | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
version: '2' | ||
|
||
services: | ||
postgres: | ||
image: postgres:9.6 | ||
web: | ||
restart: always | ||
environment: | ||
- DJANGO_SECRET_KEY=local | ||
image: web | ||
build: ./ | ||
command: > | ||
bash -c "python wait_for_postgres.py && | ||
./manage.py migrate && | ||
./manage.py runserver 0.0.0.0:8000" | ||
volumes: | ||
- ./:/code | ||
ports: | ||
- "8000:8000" | ||
depends_on: | ||
- postgres | ||
documentation: | ||
restart: always | ||
build: ./ | ||
command: "mkdocs serve" | ||
volumes: | ||
- ./:/code | ||
ports: | ||
- "8001:8001" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# Authentication | ||
For clients to authenticate, the token key should be included in the Authorization HTTP header. The key should be prefixed by the string literal "Token", with whitespace separating the two strings. For example: | ||
|
||
``` | ||
Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b | ||
``` | ||
|
||
Unauthenticated responses that are denied permission will result in an HTTP `401 Unauthorized` response with an appropriate `WWW-Authenticate` header. For example: | ||
|
||
``` | ||
WWW-Authenticate: Token | ||
``` | ||
|
||
The curl command line tool may be useful for testing token authenticated APIs. For example: | ||
|
||
```bash | ||
curl -X GET http://127.0.0.1:8000/api/v1/example/ -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b' | ||
``` | ||
|
||
## Retrieving Tokens | ||
Authorization tokens are issued and returned when a user registers. A registered user can also retrieve their token with the following request: | ||
|
||
**Request**: | ||
|
||
`POST` `api-token-auth/` | ||
|
||
Parameters: | ||
|
||
Name | Type | Description | ||
---|---|--- | ||
username | string | The user's username | ||
password | string | The user's password | ||
|
||
**Response**: | ||
```json | ||
{ | ||
"token" : "9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,106 @@ | ||
# Users | ||
Supports registering, viewing, and updating user accounts. | ||
|
||
## Register a new user account | ||
|
||
**Request**: | ||
|
||
`POST` `/users/` | ||
|
||
Parameters: | ||
|
||
Name | Type | Required | Description | ||
-----------|--------|----------|------------ | ||
username | string | Yes | The username for the new user. | ||
password | string | Yes | The password for the new user account. | ||
first_name | string | No | The user's given name. | ||
last_name | string | No | The user's family name. | ||
email | string | No | The user's email address. | ||
|
||
*Note:* | ||
|
||
- Not Authorization Protected | ||
|
||
**Response**: | ||
|
||
```json | ||
Content-Type application/json | ||
201 Created | ||
|
||
{ | ||
"id": "6d5f9bae-a31b-4b7b-82c4-3853eda2b011", | ||
"username": "richard", | ||
"first_name": "Richard", | ||
"last_name": "Hendriks", | ||
"email": "richard@piedpiper.com", | ||
"auth_token": "132cf952e0165a274bf99e115ab483671b3d9ff6" | ||
} | ||
``` | ||
|
||
The `auth_token` returned with this response should be stored by the client for | ||
authenticating future requests to the API. See [Authentication](authentication.md). | ||
|
||
|
||
## Get a user's profile information | ||
|
||
**Request**: | ||
|
||
`GET` `/users/:id` | ||
|
||
Parameters: | ||
|
||
*Note:* | ||
|
||
- **[Authorization Protected](authentication.md)** | ||
|
||
**Response**: | ||
|
||
```json | ||
Content-Type application/json | ||
200 OK | ||
|
||
{ | ||
"id": "6d5f9bae-a31b-4b7b-82c4-3853eda2b011", | ||
"username": "richard", | ||
"first_name": "Richard", | ||
"last_name": "Hendriks", | ||
"email": "richard@piedpiper.com", | ||
} | ||
``` | ||
|
||
|
||
## Update your profile information | ||
|
||
**Request**: | ||
|
||
`PUT/PATCH` `/users/:id` | ||
|
||
Parameters: | ||
|
||
Name | Type | Description | ||
-----------|--------|--- | ||
first_name | string | The first_name of the user object. | ||
last_name | string | The last_name of the user object. | ||
email | string | The user's email address. | ||
|
||
|
||
|
||
*Note:* | ||
|
||
- All parameters are optional | ||
- **[Authorization Protected](authentication.md)** | ||
|
||
**Response**: | ||
|
||
```json | ||
Content-Type application/json | ||
200 OK | ||
|
||
{ | ||
"id": "6d5f9bae-a31b-4b7b-82c4-3853eda2b011", | ||
"username": "richard", | ||
"first_name": "Richard", | ||
"last_name": "Hendriks", | ||
"email": "richard@piedpiper.com", | ||
} | ||
``` |
Oops, something went wrong.