The Video Games Reviews is a community site for game lovers. Users can post their reviews to the community, follow other users, like posts, favorite posts, comment on posts, and contact the admin.
This repository holds the Django Rest Framework (DRF) API database for the ReactJS frontend part of the project.
- The following models were created to represent the database model structure of the application:
All python files passed through the PEP8 validator with no issues
Contacts:
-
PP8 Contacts - Models
-
PP8 Contacts - Serializer
-
PP8 Contacts - Views
Likes:
Profiles:
-
PP8 Profiles - Models
-
PP8 Profiles - Serializer
-
PP8 Profiles - Views
Favourites:
-
PP8 Favourites - Models
-
PP8 Favourites - Serializer
-
PP8 Favourites - Views
Contact:
-
PP8 Contact - Models
-
PP8 Contact - Serializer
-
PP8 Contact - Views
Posts:
Backend Manual Testing
Area | Test | Result |
---|---|---|
Deployed site | Home shows message and no errors | PASS |
/profiles/ shows all profiles | PASS | |
/profiles/:id shows single profile | PASS | |
/posts/ shows all posts | PASS | |
/posts/:id shows single post | PASS | |
/comments/shows all comments | PASS | |
/comments/:id shows single comment | PASS | |
/favourites/shows all favourites | PASS | |
/likes/shows all likes | PASS | |
/admin/ allows superuser to login | PASS | |
/admin/ basic admin view and functions | PASS | |
Dev site | /posts/ show pagination | PASS |
/posts/ show text search by user__username | PASS | |
/admin/ shows login for Superuser and then loads admin panel | PASS |
- 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 |
None identified
- Python
- Django
- Django-REST-framework - Toolkit for building web API's with Django.
- Built-in Packages/Modules
- os - This module provides a portable way of using operating system dependent functionality.
- External Python Packages
- cloudinary - Cloudinary intergration.
- django-cloudinary-storage - Cloudinary intergration.
- dj-database-url - Allows the use of 'DATABASE_URL' environmental variable in the Django project settings file to connect to a PostgreSQL database.
- django-allauth - Set of Django application used for account registration, management and authentication.
- dj-rest-auth - API endpoints for handling authentication in Django Rest Framework.
- django-filter - Application that allows dynamic QuerySet filtering from URL parameters.
- djangorestframework-simplejwt - JSON Web Token authentication backend for the Django REST Framework.
- django-cors-headers - Django App that adds CORS headers to responses.
- gunicorn - Python WSGI HTTP Server.
- Pillow - Fork of PIL, the Python Imaging Library which provides image processing capabilities.
- psycopg2 - Python PostgreSQL database adapter.
By forking the GitHub Repository we make a copy of the original repository on our GitHub account to view and/or make changes without affecting the original repository by using the following steps...
- Log in to GitHub and locate the GitHub Repository
- At the top of the Repository (not top of page) just above the "Settings" Button on the menu, locate the "Fork" Button.
- Click the button (not the number to the right) and you should now have a copy of the original repository in your GitHub account.
NOTE: It is a requirement of the project that you have Python version 3.8 or higher installed locally.
-
Log in to GitHub and locate the GitHub Repository.
-
Under the repository name, click "Code".
-
To clone the repository using HTTPS, under "HTTPS", copy the link.
-
Open your local terminal with git installed
-
Change the current working directory to the location where you want the cloned directory to be created.
-
Type
git clone
, and then paste the URL you copied in Step 3.~$ git clone https://github.com/JoaoHigino/video-games-reviews-api
-
Press Enter. Your local clone will be created.
$ git clone https://github.com/JoaoHigino/video-games-reviews-api > Cloning into `test-dir`... > remote: Counting objects: 10, done. > remote: Compressing objects: 100% (8/8), done. > remove: Total 10 (delta 1), reused 10 (delta 1) > Unpacking objects: 100% (10/10), done.
Click here for a more detailed explanation of the process above with pictures.
-
Change the current working directory to the cloned project folder (this will be a child directory in the location you cloned the project).
-
It is recommended to use a virtual environment during development (learn more about virtual environments). If you would prefer not to use one please skip the following steps:
- Create a virtual environment in the projects working directory by entering the following command in the same terminal window used for the steps above
python3 -m venv .venv
. - Before use, the virtual environment will need to be activated using the command
source .venv/bin/activate
in the same terminal window used previously.
- Create a virtual environment in the projects working directory by entering the following command in the same terminal window used for the steps above
-
Packages required by the project can now using the command
pip install -r requirements.txt
-
In the cloned directory, rename the file
.env-example
to.env
and populate it with the information required. -
Make Django migrations using the command
./manage.py migrate
.
NOTE: It is a prerequisite of deployment to Heroku that you already have access to the following:
- A Cloudinary account, create one for free at https://cloudinary.com.
NOTE: It is assumed you have followed all deployment instructions listed in this readme starting with the section titled 'Forking the GitHub Repository'.
- Log in to Heroku and if not taken there automatically, navigate to your personal app dashboard.
- At the top of the page locate the 'New' drop down, click it and then select 'Create new app'.
- Give your application a unique name, select a region appropriate to your location and click the 'Create app' button.
- Your app should now be created, so from the menu towards the top of the page select the 'Resources' section.
- Search for 'Heroku Postgres' under the Add-ons section and add it.
- From the menu towards the top of the page select the 'Settings' section and lick 'Reveal Config Vars' in the Config vars section. Enter the following key / value pairings:
- Key as
ALLOWED_HOSTS
and the value as the name of you project with '.herokuapp.com' appended to the end e.g.example-app.herokuapp.com
. Click the Add button. - Key as
CLOUDINARY_URL
and the value as your cloudinary API Environment variable e.g.cloudinary://**************:**************@*********
. Click the Add button. - Key as
SECRET_KEY
and the value as a complex string which will be used to provide cryptographic signing. Click the Add button. - Ensure the key
DATABASE_URL
is already populated. This should have been created automatically by Heroku. - The
DATABASE_URL
should be copied into your local.env
, created during the cloning process.(Add the address to your ElephantSQL respository) - To make authenticated requests to this API (e.g. from a fontend application) you are required to add the key
CLIENT_ORIGIN
with the value set as the URL you will be sending the authentication request from. - Additionally, a
CLIENT_ORIGIN_DEV
key can be set with the value of a development server (IP or URL) for use during local development.
- Key as
- Open the
.env
file in the project directory and delete the key / value pairDEV_ENVIRONMENT_DATABASE = True
before saving the file. This can be added back after the next step to ensure local development changes will not alter the remote database. - Navigate to the 'Deploy' page using the menu towards the top of the page.
- Select 'GitHub' from the 'Deployment method' section and you will be prompted to 'Connect to GitHub'.
- Once connected to your GitHub account you will be able to search for your repository which contains the forked 'property-direct-backend' repository.
- Once the repository is found click 'Connect'.
- At the bottom of the page find the section named 'Manual deploy', select the 'main' branch in the drop down and click the 'Deploy' button.
- Once deployment is complete, click the 'View' button to load the URL of the deployed application.
-
Code Institute's Moments project was used to lay the foundations of this project and was adapted on to create a unique project.
-
To my amazing wife Sandra, my best friend, my mentor, and my safe haven, without her, all my dreams will be impossible to achieve. She is everything.
-
To my two kids, Maria and Thomas, with them life is easy and light. They make me laugh and think that our future is bright.
-
To my family and friends - for being a great support and providing a lot of the user testing for me, especially my friends from "Liga 7 BP" with their craziness helped me to clean my head.
-
To my mentor Lauren-Nicole aka CluelessBiker for all her help, feedback, and patience. It's a main difference when your mentor cares about you.
-
The Code Institute community on slack and my classmates its was a pleasure.