Skip to content

Commit 71b234d

Browse files
committed
feat: init commit
0 parents  commit 71b234d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+1286
-0
lines changed

.coveragerc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
[run]
2+
branch = True
3+
omit = *migrations*,
4+
*urls*,
5+
*test*,
6+
*admin*,
7+
./manage.py,
8+
./piedpiper/config/*,
9+
./piedpiper/wsgi.py,
10+
*__init__*

.dockerignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.*
2+
!.coveragerc
3+
!.env

.gitignore

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
# Byte-compiled / optimized / DLL files
2+
__pycache__/
3+
*.py[cod]
4+
*$py.class
5+
6+
# C extensions
7+
*.so
8+
9+
# Distribution / packaging
10+
.Python
11+
build/
12+
develop-eggs/
13+
dist/
14+
downloads/
15+
eggs/
16+
.eggs/
17+
lib/
18+
lib64/
19+
parts/
20+
sdist/
21+
var/
22+
wheels/
23+
*.egg-info/
24+
.installed.cfg
25+
*.egg
26+
MANIFEST
27+
28+
# PyInstaller
29+
# Usually these files are written by a python script from a template
30+
# before PyInstaller builds the exe, so as to inject date/other infos into it.
31+
*.manifest
32+
*.spec
33+
34+
# Installer logs
35+
pip-log.txt
36+
pip-delete-this-directory.txt
37+
38+
# Unit test / coverage reports
39+
htmlcov/
40+
.tox/
41+
.coverage
42+
.coverage.*
43+
.cache
44+
nosetests.xml
45+
coverage.xml
46+
*.cover
47+
.hypothesis/
48+
49+
# Translations
50+
*.mo
51+
*.pot
52+
53+
# Django stuff:
54+
*.log
55+
.static_storage/
56+
.media/
57+
local_settings.py
58+
59+
# Flask stuff:
60+
instance/
61+
.webassets-cache
62+
63+
# Scrapy stuff:
64+
.scrapy
65+
66+
# Sphinx documentation
67+
docs/_build/
68+
69+
# PyBuilder
70+
target/
71+
72+
# Jupyter Notebook
73+
.ipynb_checkpoints
74+
75+
# pyenv
76+
.python-version
77+
78+
# celery beat schedule file
79+
celerybeat-schedule
80+
81+
# SageMath parsed files
82+
*.sage.py
83+
84+
# Environments
85+
.env
86+
.venv
87+
env/
88+
venv/
89+
ENV/
90+
env.bak/
91+
venv.bak/
92+
93+
# Spyder project settings
94+
.spyderproject
95+
.spyproject
96+
97+
# Rope project settings
98+
.ropeproject
99+
100+
# mkdocs documentation
101+
/site
102+
103+
# django staticfiles
104+
/static
105+
106+
# mypy
107+
.mypy_cache/

.travis.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
sudo: required
2+
language: python
3+
services:
4+
- docker
5+
python:
6+
- "3.6"
7+
before_script:
8+
- docker-compose build
9+
script:
10+
- docker-compose run --rm web bash -c "flake8 . &&
11+
python wait_for_postgres.py &&
12+
./manage.py test"
13+
14+
notifications:
15+
email: false
16+
17+
cache:
18+
pip: true

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
FROM python:3.6
2+
ENV PYTHONUNBUFFERED 1
3+
4+
# Allows docker to cache installed dependencies between builds
5+
COPY ./requirements.txt requirements.txt
6+
RUN pip install -r requirements.txt
7+
8+
# Adds our application code to the image
9+
COPY . code
10+
WORKDIR code
11+
12+
EXPOSE 8000
13+
14+
# Run the production server
15+
CMD newrelic-admin run-program gunicorn --bind 0.0.0.0:$PORT --access-logfile - piedpiper.wsgi:application

README.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# piedpiper-web
2+
3+
[![Build Status](https://travis-ci.org/agconti/piedpiper-web.svg?branch=master)](https://travis-ci.org/agconti/piedpiper-web)
4+
[![Built with](https://img.shields.io/badge/Built_with-Cookiecutter_Django_Rest-F7B633.svg)](https://github.com/agconti/cookiecutter-django-rest)
5+
6+
Its all about a Weissman score > 5.0. Check out the project's [documentation](http://agconti.github.io/piedpiper-web/).
7+
8+
# Prerequisites
9+
10+
- [Docker](https://docs.docker.com/docker-for-mac/install/)
11+
12+
# Local Development
13+
14+
Start the dev server for local development:
15+
```bash
16+
docker-compose up
17+
```
18+
19+
Run a command inside the docker container:
20+
21+
```bash
22+
docker-compose run --rm web [command]
23+
```

docker-compose.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
version: '2'
2+
3+
services:
4+
postgres:
5+
image: postgres:9.6
6+
web:
7+
restart: always
8+
environment:
9+
- DJANGO_SECRET_KEY=local
10+
image: web
11+
build: ./
12+
command: >
13+
bash -c "python wait_for_postgres.py &&
14+
./manage.py migrate &&
15+
./manage.py runserver 0.0.0.0:8000"
16+
volumes:
17+
- ./:/code
18+
ports:
19+
- "8000:8000"
20+
depends_on:
21+
- postgres
22+
documentation:
23+
restart: always
24+
build: ./
25+
command: "mkdocs serve"
26+
volumes:
27+
- ./:/code
28+
ports:
29+
- "8001:8001"

docs/api/authentication.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Authentication
2+
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:
3+
4+
```
5+
Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b
6+
```
7+
8+
Unauthenticated responses that are denied permission will result in an HTTP `401 Unauthorized` response with an appropriate `WWW-Authenticate` header. For example:
9+
10+
```
11+
WWW-Authenticate: Token
12+
```
13+
14+
The curl command line tool may be useful for testing token authenticated APIs. For example:
15+
16+
```bash
17+
curl -X GET http://127.0.0.1:8000/api/v1/example/ -H 'Authorization: Token 9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b'
18+
```
19+
20+
## Retrieving Tokens
21+
Authorization tokens are issued and returned when a user registers. A registered user can also retrieve their token with the following request:
22+
23+
**Request**:
24+
25+
`POST` `api-token-auth/`
26+
27+
Parameters:
28+
29+
Name | Type | Description
30+
---|---|---
31+
username | string | The user's username
32+
password | string | The user's password
33+
34+
**Response**:
35+
```json
36+
{
37+
"token" : "9944b09199c62bcf9418ad846dd0e4bbdfc6ee4b"
38+
}
39+
```

docs/api/users.md

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
# Users
2+
Supports registering, viewing, and updating user accounts.
3+
4+
## Register a new user account
5+
6+
**Request**:
7+
8+
`POST` `/users/`
9+
10+
Parameters:
11+
12+
Name | Type | Required | Description
13+
-----------|--------|----------|------------
14+
username | string | Yes | The username for the new user.
15+
password | string | Yes | The password for the new user account.
16+
first_name | string | No | The user's given name.
17+
last_name | string | No | The user's family name.
18+
email | string | No | The user's email address.
19+
20+
*Note:*
21+
22+
- Not Authorization Protected
23+
24+
**Response**:
25+
26+
```json
27+
Content-Type application/json
28+
201 Created
29+
30+
{
31+
"id": "6d5f9bae-a31b-4b7b-82c4-3853eda2b011",
32+
"username": "richard",
33+
"first_name": "Richard",
34+
"last_name": "Hendriks",
35+
"email": "[email protected]",
36+
"auth_token": "132cf952e0165a274bf99e115ab483671b3d9ff6"
37+
}
38+
```
39+
40+
The `auth_token` returned with this response should be stored by the client for
41+
authenticating future requests to the API. See [Authentication](authentication.md).
42+
43+
44+
## Get a user's profile information
45+
46+
**Request**:
47+
48+
`GET` `/users/:id`
49+
50+
Parameters:
51+
52+
*Note:*
53+
54+
- **[Authorization Protected](authentication.md)**
55+
56+
**Response**:
57+
58+
```json
59+
Content-Type application/json
60+
200 OK
61+
62+
{
63+
"id": "6d5f9bae-a31b-4b7b-82c4-3853eda2b011",
64+
"username": "richard",
65+
"first_name": "Richard",
66+
"last_name": "Hendriks",
67+
"email": "[email protected]",
68+
}
69+
```
70+
71+
72+
## Update your profile information
73+
74+
**Request**:
75+
76+
`PUT/PATCH` `/users/:id`
77+
78+
Parameters:
79+
80+
Name | Type | Description
81+
-----------|--------|---
82+
first_name | string | The first_name of the user object.
83+
last_name | string | The last_name of the user object.
84+
email | string | The user's email address.
85+
86+
87+
88+
*Note:*
89+
90+
- All parameters are optional
91+
- **[Authorization Protected](authentication.md)**
92+
93+
**Response**:
94+
95+
```json
96+
Content-Type application/json
97+
200 OK
98+
99+
{
100+
"id": "6d5f9bae-a31b-4b7b-82c4-3853eda2b011",
101+
"username": "richard",
102+
"first_name": "Richard",
103+
"last_name": "Hendriks",
104+
"email": "[email protected]",
105+
}
106+
```

0 commit comments

Comments
 (0)