Developer: Jamie King
This repository contains the API set up using Django REST Framework for the Tick It front-end application (repository here and live website here)
The back-end section of the project focuses on its administration side and covers one user story:
- As an admin, I want to be able to create, edit and delete users, tasks, packs, comments and watches, so that I can have control over the content of the application and also remove any potential inappropriate content.
The following models were created to represent the database model structure of the application:
- The User model contains information about the user. It is part of the Django allauth library.
- One-to-one relation with the Profile model owner field
- ForeignKey relation with the Task model owner
- ForeignKey relation with the Pack model owner
- ForeignKey relation with the Comment model owner
- ForeignKey relation with the Watch model owner
- The Profile model contains the following fields: owner, name, job_role, created_on, updated_on and an image
- One-to-one relation between the owner field and User id field
- The Task model contains the following fields: owner, created_on, title, task_body, updated_on, priority, due_date, assigned_to, completed and pack.
- ForeignKey relation with the owner field
- ForeignKey relation with the assigned_to field
- ForeignKey relation with the pack field
- The Watch model contains the following fields: owner, task and created_on
- ForeignKey relation between the owner field and the User id field
- ForeignKey relation between the task field and the Task id field
- The Comment model contains the following fields: owner, task, created_on, updated_on and comment_body
- ForeignKey relation between the ownner and User id field
- ForeignKey relation between the task and Task id field
- The Pack model contains the following fields: owner, created_on, title, pack_description, updated_on and tasks
- ForeignKey relation between to owner and User id field
- ManyToMany relation between the tasks and Task id field
- The Contact model contains the following fields: reason, name, email, message and message date
Back to top
- Python
- Django
- Cloudinary - File storage. Justification: I used this to store static files
- Graphviz - Image generator. Justification: I used this used for the database model diagram
- Git - Version control system. Justification: I used this for version control and to push the code to GitHub
- GitHub - Cloud based hosting service. Justification: I used this as a remote repository to store project code
- Gitpod - Cloud development environment. Justification: I used this to host a virtual workspace
- Heroku - Cloud platform. Justification: I used this was used to deploy the project into live environment
- Django REST Framework - API toolkit. Justification: I used this to build the back-end API
- Django AllAuth - API Module. Justification: I used this for user authentication
- Psycopg2 - PostgreSQL database adaptor. Justification: This was used as a PostgreSQL database adapter for Python
- ElephantSQL - Database hosting service – Justification: This was used as the deployed project on Heroku uses an ElephantSQL database
Back to top
PEP8 was unavailable at the time of creating this project so Pycodestyle was used instead to continually check all Python code for errors and warnings.
The following tests were carried out on the app:
- Manual testing of user stories
- Automated testing
- As an admin, I want to be able to create, edit and delete the users, posts, comments and likes, so that I can have a control over the content of the application and remove any potential inappropriate content
Test | Action | Expected Result | Actual Result |
---|---|---|---|
User | Create, update & delete user | A user can be created, edited or deleted | Works as expected |
User | Change permissions | User permissions can be updated | Works as expected |
Profile | Create, update & delete | User profile can be created, edited or deleted | Works as expected |
Task | Create, update & delete | A Task can be created, edited or deleted | Works as expected |
Comment | Create, update & delete | A comment can be created, edited or deleted | Works as expected |
Watch | Create & delete | A Watch relationship between a Task and a User can be created or deleted | Works as expected |
Pack | Create & delete | A Pack can be created, edited or deleted | Works as expected |
Contact | Create & delete | A Contact message can be created or deleted | Works as expected |
In addition, tasks, comments, packs and watches can be created by logged-in users only. Users can only update or delete the content which was created by themselves.
Automated testing was done using the Django Rest Framework APITestCase.
- Tests summary
Back to top
This project was created based on the Code Institute's Django REST API walkthrough project 'Moments'.