- Install Python 3.5+ and create the dependencies file:
pip freeze > requirements.txt
- Install requirements using:
pip install -r requirements.txt
- Enter the folder where
manage.py
is located. - Create database and apply migrations:
python manage.py makemigrations
andpython manage.py migrate
- Run development server:
python manage.py runserver
All the users must have one and only one blog.
All the endpoints require authentication, except the GET requests to /api/1.0/blogs and to /api/1.0/posts.
A POST request must be done.
http://localhost:8000/api/1.0/users
{
"username": jose
"email": jose@jose.com
"first_name": José Ramón
"last_name": Alonso
"password": supersegura
}
The user must be registered in the application and do a POST request
http://localhost:8000/api/1.0/users/get-token
{
"username": jose
"password": supersegura
}
The user needs not to be registered and must do a GET request
http://localhost:8000/api/1.0/blogs
If the user is not registered or is the superuser all the posts will be shown.
If the user is registered only the posts from his blog should be shown.
GET http://localhost:8000/api/1.0/posts
TODO
The query parameter order_by is used. Possible values are:
- title, -title
- publication_date, -publication_date
Example: http://localhost:8000/api/1.0/posts/?order_by=title
A POST request must be done to the url http://localhost:8000/api/1.0/posts/ with these two headers:
- Content-Type: set to application/json
- Authorization: set to token value
and these parameters in the body:
{
"title": "Título del artículo",
"image": "http://images/my_image.com",
"summary": "Resumen",
"body": "Contenido",
"publication_date": "2017-12-02",
"category":[1, 2]
}
Non-authenticated users can see only published posts. Only the superuser and the author of that post can see a non-published post.
GET http://localhost:8000/api/1.0/posts/<id>
Only the superuser and the author of that post can perform this operation.
PUT http://localhost:8000/api/1.0/posts/<id>
Only the superuser and the author of that post can perform this operation.