artcuddy / project4-cocktail-nerd

1 stars 1 forks source link


Your expert cocktail guide, featuring hand-selected cocktail recipes.
Find great new drinks to try plus helpful tips and advice.

Contents

Introduction

Project Milestone 4 for Code Institute Full-stack development program. Cocktail Nerd - is a full stack Django project that runs on Heroku.

The site allows staff users to edit posts, categories and comments from the frontend once logged in & registered users can login to comment,like & rate cocktail recipes.

Live Site

A live version of the site can be found HERE



User Experience - UX

Back to the top.

User Stories

  1. Navigate around the site and easily view the desired content.
  2. View a list of cocktail recipes and choose accordingly.
  3. Search cocktail recipes to find specific recipes.
  4. Click on post to read the cocktail recipe details.
  5. Register for an account to like, rate or comment on a cocktail recipe.
  6. View the number of likes on a cocktail recipe.
  7. View comments on cocktail recipes so that I can read other users opinions.
  1. Like/unlike cocktail recipes and view my liked cocktail recipes on a single liked cocktails page.
  2. Comment on cocktail recipes and give my opinion about the posts.
  3. Delete or edit my previous comments.
  4. Manage my profile by updating my details and avatar.
  1. Create and publish a new cocktail recipe.
  2. Create draft recipe posts that can be reviewed and finalised later.
  3. Create new cocktail recipes and cocktail categories.
  4. Edit cocktail recipes, cocktail categories and comments.
  5. Delete cocktail recipes, cocktail categories and comments.
  1. Create and publish a new cocktail recipe.
  2. Create draft recipe posts that can be reviewed and finalised later.
  3. Create a new user, cocktail recipes and cocktail categories.
  4. Edit cocktail recipes, cocktail categories and comments.
  5. Delete a user, cocktail recipes, cocktail categories and comments.
  6. Approve user's comments.
  7. Change the website permissions for a user.

Agile Methodology

The Agile Methodology was used to plan this project. This was implemented through Github and the Project Board which can be seen here - Cocktail Nerd User Stories

Through the use of the Kanban board in the projects view in Github, the project was divived into a few different sections:

Kanban board github

Github issues were used to create User Stories and any other fixes or updates for the project. This was where the project user was assigned, labels were added to provide clarity, and the story was added to the appropriate sprint and the project. Each User Story, Fix or Update had a clear title.

Milestones were used to create sprints. There were 3 sprints each dated appropriately. User Stories were completed based on the current sprint in progress. Each sprint was completed on time.

3 enhancement features were not completed and left as Future Features for further development.

The Github issues were not just used to record User Stories but also used to record any bug fixes or updates to the codebase as well.

The Scope

Design

Back to the top.

Colours

Bootstrap 5 Colours

Typography

Media

Database Diagram

Database Diagram

Wireframes

Initial Wireframes

Home Page

All Cocktails

All Cocktails Admin

Post Detail

Features

Back to the top.

Homepage

Back to the top.

Back to the top.

Cocktail Recipe Details

Back to the top.

Cocktail Recipe Sidebar

Back to the top.

Liked Cocktails

Back to the top.

All Cocktails

Back to the top.

All Spirit Categories

Back to the top.

Filter Cocktails by Spirit Category

Back to the top.

Search Results

Back to the top.

Admin on the Frontend

Back to the top.

Possible Future Features

Back to the top.

Technologies

Back to the top.

Throughout the planning, design, testing and deployment of the Cocktail Nerd Website , I have used a number of technologies listed below:

Languages Used

Django Packages Used

Frameworks - Libraries - Programs Used

Development & Testing

Back to the top.

Automated Testing Results

Functional Automated Testing Results

Manual Testing Results

Deployment

Back to the top.

This project was created on GitHub and Edited in GitPod by carrying out the following:

  1. A new repository was created using 'Code-Instutute-Org/python-essentials-template'
  2. A meaningful name was given to my new repository and I selected 'Create Repository'
  3. I then opened the repository on GitHub and clicked the 'Gitpod' button to build the GitPod workspace which would allow me to build and edit the code used to make the Cocktail Nerd website.
  4. Version control was used throughout the project using the following commands in the terminal using Bash
    • git add . OR git add "file name" - to stage the changes and get them ready for being committed to the local repo.
    • git commit -m "Description of the update" - to save the change and commit the change to the local repo
    • git push - to push all committed changes to the GitHub
    • commit --amend - for changing the wording or spelling of the most recent commit
    • git reset "commit hash"
    • git push -f - This was used to force changes through to the GitHub repo if either "commit --amend" or "git reset" were used
  5. ## Heroku The project was deployed via Heroku, and the live link can be found here: Cocktail Nerd This project was developed utilising the Code Institute Template. Some of the deployment steps below are specifically required for the new CI template and may not be applicable to older versions, or different projects. Before deploying to Heroku pip3 freeze > requirements.txt was used to add all dependencies for deployment and created the Procfile with web: gunicorn cocktailnerd.wsgi. Created .slugignore with /documentation, README.md & TESTING.md as paths to ignore in Heroku as I don't want the documentation to upload to Heroku. This project was deployed to Heroku using the Heroku CLI details below * Login To use the CLI you must log in to your Heroku account. To do this you will need to enter the command heroku login -i in the terminal. It requires the email and password you used to sign up. If you have enabled multi-factor authentication (a recommended security practice) then instead of your password you need an API key. To get the API key go to your account settings and scroll down to the section ‘API Key’. Click reveal and copy that, then paste it into the password prompt.

    * Creating A Heroku App Now that you are logged in, the first thing is to create a new app. Heroku creates a URL based on your app name, so it must be unique not only on your account, but across the whole site. You may need to try a few different names. To create an app use the following command, where myapp is the name of your app.

    * Here the app heroku-cli-example has been created with an output of the website URL. It also displays and sets the git remote repository which will be used to deploy. By default the region will be set to the US. If you would prefer a server based in the EU then you can specify the region with the flag EU * When you push code to Heroku it will look at the repository contents to decide how to build the project. One of the factors taken into consideration is the package file. With a Python project the standard file is a requirements.txt file, which will have the list of packages needed to run the project. If this file is present it will build the project using the Python buildpack. * It is also possible to specify the buildpack manually. More information about buildpacks can be found in the documentation. To check the buildpack for the project you can enter heroku buildpacks in the terminal. ## Deployment Steps On Heroku. * Run this command pip3 install pip3 install 'django<4' to install django. * Added these libraries:pip3 install dj_database_url psycopg2,pip3 install dj3-cloudinary-storage * Created requirements.txt file where I can save all the libraries I've installed:pip3 freeze --local > requirements.txt * To create my project typed this command:django-admin startproject cocktailnerd * To create my app:python3 manage.py startapp cocktailapp * To make this app work, Into the setting.py file inside INSTALLED_APPS added cocktailapp * To migrate changes typed this command:python3 manage.py migrate * To run the test if the project is working python3 manage.py runserver * When deploying for the first time on Heroku, you must first register with Heroku. * Create your project name and location. * To add Database into the app, Locate in the Resources Tab, Add-ons, search and add 'Heroku Postgres' * Copy DATABASE_URL value, by going into the Settings Tab, click reveal Config Vars, Copy Text * In your workspace Create new env.py file. * Import os library:import os * Set environment variables:os.environ["DATABASE_URL"] = "Heroku DATABASE_URL" * Add in secret key:os.environ["SECRET_KEY"] = "mysecretkey" * Add Secret Key to Config Vars in Heroku settings:SECRET_KEY, "mysecretkey" * Add env.py file to the settings.py file:import osimport dj_database_urlif os.path.isfile("env.py"):import env * Remove the insecure secret key and replace - links to the SECRET_KEY variable on Heroku:SECRET_KEY = os.environ.get('SECRET_KEY') * Comment out the old DATABASES variable in setting.py file and add this instead:DATABASES = { 'default': dj_database_url.parse(os.environ.get("DATABASE_URL"))} * Save all files and Make Migrations:python3 manage.py migrate * Make account with Cloudinary To get static and media files. * From Cloudinary Dashboard, Copy your CLOUDINARY_URL: * Add Cloudinary URL to env.py file:os.environ["CLOUDINARY_URL"] = "cloudinary://************************" * Add Cloudinary URL to Heroku Config Vars:"cloudinary://************************" * Temporalliy add DISABLE_COLLECTSTATIC inside the heroku config Vars:DISABLE_COLLECTSTATIC, 1 * Add Cloudinary Libraries to settings.py installed apps:INSTALLED_APPS = ['cloudinary_storage', 'django.contrib.staticfiles', 'cloudinary'] * In the settings.py file under the STATIC_URL = 'static/' add: ```python STATICFILES_STORAGE = 'cloudinary_storage.storage.StaticHashedCloudinaryStorage' STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'), ] STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') ``` * Place under the BASE_DIR line in settings.py:TEMPLATES_DIR = os.path.join(BASE_DIR, 'templates') * Change the templates directory to TEMPLATES_DIR Place within the TEMPLATES array:TEMPLATES = [{'DIRS': [TEMPLATES_DIR],],},},] * Add Heroku Hostname to ALLOWED_HOSTS:ALLOWED_HOSTS = ["project4-cocktail-nerd.herokuapp.com", "localhost"] * Create 3 new folders on the root directory: media, static, templates * Create Procfile needed for Heroku on the root directory and inside the file add this:web: gunicorn dentist.wsgi * Before deploying on heroku make sure: DEBUG = False Remove DISABLE_COLLECTSTATIC from the config vars. * Created .slugignore with /documentation, README.md & TESTING.md as I don't want the documentation to upload to Heroku. * Click **Enable Automatic Deploys** for automatic deployment when you push updates to Github. * Select the correct branch for deployment from the drop-down menu and click **Deploy Branch** for manual deployment. ### Github Local Deployment There are many ways to deploy the project locally on your own device. Forking, Cloning, GitHub Desktop and Zip Exctraction, the steps in these processes are outlined below: ### Forking the GitHub repo If you want to make changes to the repo without affecting it, you can make a copy of it by 'Forking' it. This will make sure that the original repo remains unchanged.
    1. Log in to your GitHub account
    2. Navigate to the repository HERE
    3. Select the 'Fork' button in the top right corner of the page (under your account image)
    4. The repo has now been copied into your own repos and you can work on it in your chosen IDE
    5. If you have any suggestions to make regards to the code to make the site better, you can put in a pull request
    ### Cloning the repo with GitPod
    1. Log in to your GitHub account
    2. Navigate to the Repository HERE
    3. Select the 'Code' button above the file list on the right had side
    4. Ensure HTTPS is selected and click the clipboard on the right of the URL to copy it
    5. Open a new workspace in GitPod
    6. In the bash terminal type 'git clone [copy url here from step 4]'
    7. Press enter - the IDE will clone and download the repo
    ### Github Desktop
    1. Log in to your GitHub account
    2. Navigate to the Repository HERE
    3. Select the 'Code' button above the file list on the right had side
    4. Select 'Open with GitHub Desktop'
    5. If you haven't already installed GitHub desktop application - you will need to follow the relevant steps to do this
    6. The repo will then be copied locally onto your machine
    ### Download and extract the zip directly from GitHub
    1. Log in to your GitHub account
    2. Navigate to the Repository HERE
    3. Select the 'Code' button above the file list on the right had side
    4. Select 'Download Zip'
    5. Once you have the Zip downloaded, open it with your prefered file decompression software
    6. You can then drag and drop the files from the folder into your chosen IDE or view/edit them on your local machine
    7. If you want to create a web-app from the repo please follow the instructions in "Project Deployment"

    Credits

    Back to the top. ### I have listed some of the resources I used for inspiration and in researching how to create the Cocktail Nerd Website * Building a blog application with Django HERE * Code Institute "I think therefore I blog" helped me setup the initial code for Cocktail Nerd. * All the cocktail receipes are from Liquor.com * All the header images are from Unsplash * Adding star rating to cocktails is from Django Star Ratings ### These are some of the resources that helped me solve some of the issues encountered when developing the site * [W3Schools - Python](https://www.w3schools.com/python/) * [Stack Overflow](https://stackoverflow.com/) for various code snippets and solutions * [Django Documentation](https://docs.djangoproject.com/en/4.1/) * [Django Testing](https://www.youtube.com/watch?v=0MrgsYswT1c&list=PLbpAWbHbi5rMF2j5n6imm0enrSD9eQUaM&index=3) * [Django Testing Cheatsheet](https://www.valentinog.com/blog/testing-django/) * [Django User Profile](https://dev.to/earthcomfy/django-user-profile-3hik) * [Django Allauth](https://django-allauth.readthedocs.io/en/latest/) * [Django Real Python Manage Users](https://realpython.com/manage-users-in-django-admin/) * [Summernote](https://summernote.org/deep-dive/) * [Awesome Django](https://awesomedjango.org/) * [Codemycom](https://www.youtube.com/c/Codemycom)

    Acknowledgements

    Back to the top. This project was made possible due to the help & advice from my Code Institute mentor Rohit, Code Institute Slack community, Stack Overflow community and a lot of extensive Googling and hair pulling if I had any.