A backend app to help keep track of your favorite things!
This project has been built by using our custom cookie-cutter project that was built overtime in our careers. This is still a work in progress and having used this might mean there are a few extra libraries and functionality that are present but unused in this project. I chose to use this cookie cutter for rapid development and deployment purposes.
Also would prefer to use django-dirty-fields
to track my model field changes, since my applied ModelDiffMixin
might
not cover most cases of state changes.
- A user can have many different favorite things
- One category can have multiple favorite things
- One favorite thing can have one category
- Only showing the PK and FK labels
- Used built in admin log entry models to save audit log changes. I took this approach because I thought it better to use something django already provides. This will also allow us to query for changes on a specific date. The change message stores the favorite field value model object changes.
(P.S: I think it might have been better to create another model based off of the LogEntry model for logging our model changes and not having conflicts since changes made by the admin panel are also being save in our currently used log entry model.)
- Deployed using dokku on a remote AWS instance (nano)
- Added ssl using dokku built in methods since our front end that was deployed using netlify and it enabled ssl over there. As a result we had to add a certificate in order to consume our backend resources
- Deployed link: http://13.235.4.179/
- Login credentials:
- username: admin
- password: admin12345
POST http://13.235.4.179/api/v1/favorites/
request data
{
"category": "food",
"title": "burger",
"ranking": 1,
"metadata": null,
"description": ""
}
response
{
"id": 1,
"logs": [],
"category": "food",
"created_date": "2019-06-26",
"modified_date": "2019-06-26",
"title": "burger",
"ranking": 1,
"metadata": null,
"description": ""
}
PUT http://13.235.4.179/api/v1/favorites/1/
request data
{
"category": "food",
"title": "pizza",
"ranking": 1,
"metadata": null,
"description": ""
}
response
{
"id": 1,
"logs": [
"{'title': ('burger', 'pizza')}"
],
"category": "food",
"created_date": "2019-06-26",
"modified_date": "2019-06-26",
"title": "burger",
"ranking": 1,
"metadata": null,
"description": ""
}
GET http://13.235.4.179/api/v1/favorites/
response
[
{
"id": 1,
"title": "person",
"favorite_things": []
},
{
"id": 2,
"title": "place",
"favorite_things": [
{
"id": 2,
"logs": [
"{'title': ('bangkok', 'tokyo')}"
],
"category": "place",
"created_date": "2019-06-26",
"modified_date": "2019-06-26",
"title": "tokyo",
"ranking": 1,
"metadata": null,
"description": ""
}
]
}
]
GET http://13.235.4.179/api/v1/favorites/1/
response
{
"id": 1,
"logs": [
"{'title': ('burger', 'pizza')}"
],
"category": "food",
"created_date": "2019-06-26",
"modified_date": "2019-06-26",
"title": "pizza",
"ranking": 1,
"metadata": null,
"description": ""
}
DOCUMENTATION: http://13.235.4.179/docs/
Make sure you have docker and docker compose installed
docker-compose up --build
Pytest:
- Log into docker compose shell via exec:
docker-compose exec web bash
- Run this command in shell:
pytest