Developer: Aleksandra Haniok
This repository contains the API set up using Django REST Framework for the SnapFood 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 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
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 Follower model owner and followed fields
- ForeignKey relation with the Post model owner field
- ForeignKey relation with the Comment model owner field
- ForeignKey relation with the Like model owner field
- The Profile model contains the following fields: owner, name, description, created_on, updated_on and image
- One-to-one relation between the owner field and the User model id field
- The Post model contains the following fields: owner, created_on, updated_on, title, description, category and image
- ForeignKey relation with the Comment model post field
- ForeignKey relation with the Like model post field
- The Follower model contains the following fields: owner, followed and created_on
- ForeignKey relation between the owner field and the User model id field
- ForeignKey relation between the followed field and the User model post field
- The Comment model contains the following fields: owner, post, created_on, updated_on and content
- ForeignKey relation between the owner field and the User model id field
- ForeignKey relation between the post field and the User model post field
- The Like model contains the following fields: owner, post and created_on
- ForeignKey relation between to the User model id field
- ForeignKey relation between the owner field and the User model id field
- ForeignKey relation between the post field and the Post model post field
Back to top
- Python
- Django
- APITestCase - Django Rest Framework APITestCase was used for automated testing
- Cloudinary to store static files
- Coverage used to produce automated testing report
- Dbdiagram.io used for the database schema diagram
- Git was used for version control via Gitpod terminal to push the code to GitHub
- GitHub was used as a remote repository to store project code
- Gitpod) - a virtual IDE workspace used to build this site
- Render Platform was used to deploy the project into live environment
- Django REST Framework was used to build the back-end API
- Django AllAuth was used for user authentication
- Pillow was used for image processing and validation
- Psycopg2 was used as a PostgreSQL database adapter for Python
- PostgreSQL – deployed project on Render uses a PostgreSQL database
Back to top
PEP8 Validation Service was used to check the code for PEP8 requirements. All the code passes with no errors or 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 |
Post | Create, update & delete | A post can be created, edited or deleted | Works as expected |
Comment | Create, update & delete | A comment can be created, edited or deleted | Works as expected |
Like | Create & delete | A like can be created or deleted (like / unlike post) | Works as expected |
Follower | Create & delete | Follow or unfollow user | Works as expected |
In addition, posts, comments, likes and following 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 (a very similar to Django's TestCase). The report of overall testing was produced using the coverage tool ($ coverage report
& $ coverage html
commands)
- Tests summary
Back to top
- User avatar default image taken from here and colors changed using Paint
- Default post image found here and tweaked with Paint
This project was created based on the Code Institute's Django REST API walkthrough project 'Moments' which was a great learning experience.