KACSafety
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/2f259edd-85e2-4a28-9f35-03e648191cef)
About
This is a fictional website for educational purposes for a health and safety training company called KAC Safety. The comapny provides consulation in realtion to health and safety but also provides training courses in which a visitor can view the details on each course and purchase same through a stripe payment process. The company offers both online and classroom based courses in health and in safety. This is a full stack e commerce project. The following languages have been used while building this project: Django, Python, Html, CSS and JavaScript.
UX
When researching the UX principles and thinking about the clients needs, the target audience and what needs to be included so that they would benefit from same I considered the following.
Bearing in mind that this is a start up and more courses will be added over time as the company and website evolves but the target audience for this site are as follows:
- Companies and Private clients in the health and construction industries
- Companies interested in providing health and safety training to their employees to ensure compliance with legal requirements and to create a safe and health work environment.
- Health and Safety courses are essential for promoting workplace safety and prevent accidents and injuries and by undertaking these courses they can benefit both individuals and the company by providing the knowledge and skills necessary to maintain a safe and health work environment.
- Private clients who are looking to upskill in order to gain a promotion or a change of career or maybe to stay up to date with industry standards. .
- Also by offering courses online there is the opportunity to reach a wider audience including people who might not be able to attend in person classes due to time constrains and location
- Also with an online offering thee is the potential of increased revenue.
What the visitors will be looking for:
- Visitors to the site are looking for a an ecommerce site that provides easy access to a range of courses and training materials that are relevant to their individual needs.
- An information source which has a bank of courses in relation to health and safety
- Visitors will require some detail on each course selected.
- Visitors will want to see the cost of each course.
- Visitors will also want to know whether the course is delivered online or in classroom setting.
- Select a training date for a specific course
- And be able to carry this selection through to the checkout process
- Be able to set up an account if they are a frequent visitor to the site so that they can view order history
- Be able to keep up to date with company announcements by way of newsletter and social media link
- Be able to easily naviage around the site to view the specific information that a user want to see.
Agile Development
Github was used to record the project milestone / epics and the kanban board within github was used to record all the user stories for the project.
User Stories
This project has 5 Milestone and they are as follows:
1 Project Planning Design and Setup (Admin)
2 Authentication & Access (Admin and User)
3 Functionality (Admin and User)
4 Management of courses and site (Admin)
5 Testing and Deployment (Admin)
Each one of the above Milestones/Epics are further divided down into their own user stories:
Milestone/Epic : Project Planning Design and Setup (Admin)
- #2 Developer – Document project user requirements, scope and goals – (This was entered twice by mistake under the project milestone above)
- #3 Developer – Create wireframes, mock-ups, layouts and interface, user stories and kanban board.
- #4 Developer – Setup project workspace on hosting platform
Milestone/Epic : Authentication & Access (Admin and User)
- #5 (35) Admin have full access to the site
- #6 Admin – Manage user accounts
- #7 User – Register for a new account
- #8 User – login to account
- #9 User – Manage Account Information
- #10 – User – Reset password
Milestone/Epic : Authentication & Access (Admin and User)
- #11 User – View full list of courses
- #12 User – View the course in more detail
- #13 User – Search courses by category
- #14 User – Search courses by location
- #15 User – Add courses to bag
- #16 (36) User – View courses in bag
- #17 User – Change qty in bag
- #18 User – Enter payment details
- #19 User – See order confirmation
- #20 User – See order history on login
- #21 User – Make purchase without registration
- #22 User – Sign up to company newsletter
- #23 User – Submit a contact form
- #24 User – Access company social media page
- #25 User – See confirmation of actions completed
Milestone/Epic : Management of courses and site (Admin)
- #26 Admin – Add new courses
- #27 Admin – Edit a course
- #28 Admin – Delete a course
- #29 Admin – Update general content
- #30 Admin – Manage in-coming orders
- #31 Admin – Manage all in-coming contact requests
Milestone/Epic : Testing and Deployment (Admin)
- #32 Developer – Test all parts of the Django site
- #33 Developer – Deploy successfully
- #34 Developer – Ensure site is responsive
- Please see screenshots below of Kanban board from Github
- This is a full list of all user stories on github at the start of the project.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/21e0979e-36f8-4d2e-83d8-d74381cfe141)
- Presently this is the status of the kanban board in github.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/e506e76f-1e45-493e-bdca-108298743275)
Product Backlog
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/0d998bfa-8ed6-459d-87bd-c1d57af1a1d4)
Structure
The site is divided into a number of apps so that the user can easily navigate around the site and these are as follows:
- Dashboard - the user can view orders and update shipping information
- Landing – this is the home page for this ecommerce site
- Courses – which contains details about all the courses
- Basket – which will allow user to add their items to the basket and view same
- Purchase – which is basically the checkout app which collects all the information about the payment for the courses.
- Mailchimpnews - marketing Tool
- Contact - should a user want to get in contact with kacsafety
Wireframes
All wireframes were created using Balsamiq.
Home Page
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/35b4be24-fdaa-44a4-8c2a-a6ad707a1df9)
Sign In Page
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/11cb3cb8-7b8f-4867-a010-a8c3d23d78cc)
Sign Up Page
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/1238ac32-4adc-4747-bf16-609988db267a)
Logout
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/9f930e47-7aa6-4376-84b8-41100ebad9f5)
All Courses Page
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/d9256ef2-225d-4bdc-8be8-cff87c88aa14)
Detailed Courses Page - When the superuser is logged in they will be able to
edit and delete courses
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/9804d3d7-ea19-4422-835e-e3e01d612ef2)
Contact Us
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/fdd053c4-fdee-49e2-aacf-b21fd6185070)
Basket
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/e754ae74-b5f7-4a5b-bbe2-d84ef0f24f86)
Purchase Success
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/bb2d6803-a38d-4211-8bda-19fe76f4e311)
Newsletter Signup
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/ed3c56aa-2a83-4a3b-bb3b-0b5dc555b22d)
Add Course Page
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/27e993ad-4125-46bb-b2f7-207d59bdeba2)
Edit Course
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/4a24b634-4e26-42b9-a280-f5eef5691f76)
Dashboard Page
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/1217fa51-504f-4146-a9ba-6588e433be8f)
Database Schema
The design for the database were drawn up in draw sql - In total there are 9 tables for this project which are as follows: Courses, Purchase, Purchase_Order, Location, Group_By, UserDashboard, Basket, Mail_Chimp and contact.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/8bd0c220-9d12-49f6-a545-4e38689e2a86)
Business Model
The business model for this ecommerce projects is a Business to Business and Business to Customer (B2B and B2C). As mentioned above the site is aimed at both companies who are trying to fullfill training and legal requirements and to private clients who want to upskill or career change.
Marketing
Business Model
The Business Model for this ecommerce project is the provision of an online platform where visitors can view courses in relation to health and safety.
Purpose of the Ecommerce site
To provide an online presence for the company and also a platform where people can visit and easily browse a range of courses in relation to health and safety, choose the course that matches their requirements and proceed to purchase same.
B2B and B2C
The ecommerce site focuses on Business to Business and Business to Customer. It might tend to vere more toward business to business because of the fact many businesses in the health and safety sectors will need to fullfill their training requirements but also legal requirements in relation to health and safety. There is also a business to customer focus where a visitor might want to update skills, knowledge and possibility of a career change.
Core Business Focus
- Provide an online site that is easy to navigate for the visitor
- Providing a bank of courses in relation to health and safety
- Easy to navigate checkout process
Marketing Channels
- Each page will provide a link to the companys social media platforms which are Facebook, Twitter, Instagram and Youtube. These links are located in the footer of each page.
- By providing a choice of social media platforms it ensure that the company is reaching a wider audience and keeps customers up to date on all company events and updates and allows the company to engage wit their audience.
- Mail Chimp allows user again to keep up to date with all company updates. Location
- Contact Us Form allows the company to engage with their customers and also gives their customers the opportunity to enquire about different course and get extra information. Location
Below is screenshots of facebook page, contact page and mailchimp signup.
Facebook
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/3b7958e4-b406-47c8-b375-8fed77b3e115)
Contact Page
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/24100feb-2eea-4b84-993e-4548c476c1f4)
Mailchimp example
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/ce607efd-b517-4607-8f7e-1f56daea84b7)
SEO – Search Engine Optimisation
A sitemap.xml has been included in the root directory of this project. This will aid search engine crawlers discover and crawl all of the pages on the ecommerce site including those that may be difficult to find through normal navigation or links. A robots.txt file is also included in the root directory of this project. This will instruct search engine crawlers which pages or sections of the website should not be crawled or indexed. The following keywords were drawn up for DEV-Tees keyword research -
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/a82ab574-4cfc-4d9d-9248-516154a099b8)
These keywords were also put into the meta tag in the base.html page of the project root.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/b02db7dd-dfdd-42dc-abe6-45e70f64f1e6)
Surface
Design Choice
Bootstrap has been used to aid responsiveness of the site
Color Schema
The color scheme used on this site is mainly a shade of grey and red. It allows the content to be shown clearly on the page and in the context of health and safety red is commonly used for warning signs, fire alarms and hazardous material etc to alert people of potential danger and the need for caution.
https://mycolor.space/ was used to research these color types.
Red Ral Color #CC0000
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/a512b104-fe36-4ea1-b312-7baf455aa7cc)
Grey Ral Color # CCCCCC
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/a46852c7-5f00-4da3-ae22-a5a3140f0d29)
Logo
Reseached different websites for logo creation and I took inspiration from https://www.canva.com/ - The main colors used in the logo is red / black and white. The logo sits in the same position on each page in the top left hand corner and will bring the visitor back to the home page when clicked.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/1f847253-21c5-44fc-9d49-249c5eb4b96e)
Typography
Google fonts was used to research font styles for the project. Fonts used in the building of this site were :
Technologies Used
Languages
Frameworks, Libraries & Programs Used
• GitHub – project code is stored on GitHub and this is connected to GitPod and Heroku.
• GitPod – this is the platform where the project is built and then all work that is completed in GitPod is pushed to GitHub in a series of commits which GitPod is also connected to.
• AWS – used to store static files
• Heroku – is a hosting platform and is again connected to GitHub.
• Django – the framework which was used to build the project (python web framework)
• Gunicorn – python web server gateway interface (WSGI) HTTP server
• Allauth – provides authentication and authorisation features for Django
• Bootstrap – used in design, add styling and focus on making the site responsive across a number of devices.
• JQuery – Javascript code
• Google Font – provide the fonts for the website
• Font Awesome – used for icons and toolkits
• Balsamiq – used for the production of wireframe
• Draw Sql – used in the production of database design
• Am I responsive – to check if site is responsive across different screen widths
• W3C Markup Validator – used to validate HTML
• W3C CSS Validator – used to validate css
• Cloudinary – used to store images
• Crispy Forms – used to make it easier to style and manage Django forms.
• ElephantSQL – cloud-based managed PostgreSQL database service
Extensions
• Stripe – payment processing platform
• Pillow – python library that provides support for opening and saving many different image file formats
Testing
Testing has been discussed under the following headings in the Testing.md file
-
Testing User Stories
-
Code Validation
-
Accessibility
-
Manual and Tools Testing
- Lighthouse report – Lighthouse was used to evaluate the ecommerce site performance, accessibility, best practices and SEO which can also be seen in the testing.md file.
Validators
- HTML – code was validated using the W3C HTML Markup Validation
- CSS – code was validated using the W3C CSS Validation
- JavaScript – code was validated using JSHint
- PEP8 - At present the PEP8 Sreenshot has all erros with trailing white
- spaces, insertion of lines before functions and classes and removal of extra
- line removed.
User Stories Testing
Each user story was tested to ensure that it met its intended purpose by ensuring it met its acceptance criteria. Results of same have been documented.
1 As a developer document project user requirements, scope and goals
Requirements, scope and goals are all recoreded in this readme documents and
discused with user.
2 As a Developer create wireframes and mockups on the layouts and interface and compile list of user stories.
Home Page
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/35b4be24-fdaa-44a4-8c2a-a6ad707a1df9)
Sign In Page
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/11cb3cb8-7b8f-4867-a010-a8c3d23d78cc)
Sign Up Page
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/1238ac32-4adc-4747-bf16-609988db267a)
Logout
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/9f930e47-7aa6-4376-84b8-41100ebad9f5)
All Courses Page
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/d9256ef2-225d-4bdc-8be8-cff87c88aa14)
Detailed Courses Page - When the superuser is logged in they will be able to
edit and delete courses
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/9804d3d7-ea19-4422-835e-e3e01d612ef2)
Contact Us
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/fdd053c4-fdee-49e2-aacf-b21fd6185070)
Basket
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/e754ae74-b5f7-4a5b-bbe2-d84ef0f24f86)
Purchase Success
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/bb2d6803-a38d-4211-8bda-19fe76f4e311)
Newsletter Signup
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/ed3c56aa-2a83-4a3b-bb3b-0b5dc555b22d)
Add Course Page
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/27e993ad-4125-46bb-b2f7-207d59bdeba2)
Edit Course
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/4a24b634-4e26-42b9-a280-f5eef5691f76)
Dashboard Page
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/1217fa51-504f-4146-a9ba-6588e433be8f)
3 As a developer I want to be able to setup project workspace on hosting platform using githug and gitpod - installing django, secret key hidden, settings for development and production have been specified in the settings.py
Github
- Login to GitHub and create your new repository
- Go to the Repositories tab click on New
- Then enter the name of the repository you wish to create
- Click on create repository
- New repository is now ready to use
Setting Up Django
This project uses the Django framework
-
First of all the user needs to install Django so in the terminal enter the command – pip3 install django
-
Then to create a new project the user needs to type the following command in the terminal - django-admin startproject ‘insert your project name here’
-
Then the user needs to add a gitignore file in the command line type the following command – touch .gitignore
-
The user will add the following files to the .gitignore file
o *.sqlite3
o *.pyc
o pycache
-
Then the user needs to run the server to see if base project is running by inputting the following in the terminal – python3 manage.py runserver which will open the 8000 port in which the user will be able to view the base project in the browser when they open this port.
-
The user will then need to run the migrate command by inputting the following command in the terminal – python3 manage.py migrate
-
The user will then have to create a superuser in order to access the admin panel so that they can view the information for the site and make the necessary changes. To create a superuser in the terminal the user will input – python3 manage.py createsuperusere.
-
The user will then be prompted to enter a username, email and a password.
-
The secret key needs to be set in the env.py file (this can be generated from a secret key generator for example Djecrety). In the settings file you will just refrence the secret key which is located in the env.py file.
-
Also add your database url secret from ElephantSQL and add same to the env.py file. Again reference same in the settings file.
-
The value for the secret key and key for database url will be also set in heroku under config vars.
-
The user will then make the initial commit to github wit the following commands in the terminal :
o git add .
o git commit -m “initial commit”
o git push
-
This will push all the setup and changes for this project up to GitHub.
4 As an administrator have full access to the site.
The admin user can log by accessing the Dashboard link on the navbar which will then have a dropdown menu where login can be selected.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/9ea29b15-29b7-4a40-9ec8-2207da0297c6)
Once logged in the admin user will have access to Course Administration, My Dashboard and will also be able to logout.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/4d25bd09-7572-435b-bb8a-26950dce1e02)
In the course administration page the admin user will be able to add the details for a new course.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/5c6a3753-4358-42ff-aa5c-119823da7183)
When the user clicks on the add course button the course will be added to the list of courses on the website or the admin user can cancel the page by clicking on the cancel button.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/779b3155-4d39-4188-9837-41b669d4851d)
The admin user can also edit a course by clicking on the edit link in the detailed course making the necessary amendments and updating the details.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/af3cadab-d948-4177-bdba-b1907519b1ba)
The admin user can delete a course by clicking on the delete link on the detailed course above
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/f817bdc4-9fc5-49e3-ae59-75ea79191210)
5 As an administrator manage user accounts - As an admin user they have access to the admin panel where they can see all users been reigtered email addresses and orderes placed.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/9c4a1eaf-cf31-4e24-9d03-184138bf5125)
6 As a user enter my details on a form so that i can register for my own account.
When the user goes to the Dashboard and clicks on Register in the dropdown meanu they will be brought to the Sign Up Page where the user will enter their email, username and password.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/c9ceaedf-73ff-4673-b473-6937e64df75a)
7 As a user I want to be able to login to my account so i can view my details and order history
If the user goes to the Dashboard click on the option to login they will be able to login to their account
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/eff7e7a3-ae52-4538-9625-60935a58c98b)
Once logged in the user can proceed to My Dashboard in the Dashboard menu and they will be brought to the My Dashboard Page where they can enter shpping details and also see their previous purchases.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/0485ef9e-21b3-4d1c-8506-c02c3f1a95ac)
8 As a user I want to be able to manage my account information so that it is up to date.
In point 7 above the user will be able to enter their details and then click on update information so the information is available on their profile. When the user makes a purchase it will be recorded in the Purchase records section of the aobve page.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/9437eed5-8a81-4bf7-bcfc-977145b5cfa6)
9 As a user I want to be able to reset my password in case i forget same.
When the user goes to sign in they have the option to reset password by clicking on "Forgot Password?" and they can then proceed to reset a new password.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/14ee814e-ff5f-4751-9710-e2acad935724)
10 As a user i want to be able to view a full list of courses.
To proceed to all courses the user can click on all courses in the navbar at the top of the page. The learn more button also on the home page will them them to the all courses page.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/04fa3114-6d48-4332-a16c-c1eb57975b74)
the user will then be brought to the all courses page where a list of courses will display.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/4f7f0113-3828-4996-afc4-876ae1357562)
11 As a user i want to be able to view the course in more details so that I can make an informed decision wheather this course is suitable for my needs.
Once the user navigates to the all_courses page they will see a list of course cards and on each course card there is a link to course details which brings the user to the detailed courses page. Example of course details link on the course details card
Example of the detailed course page
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/1e38e621-babc-4fa0-8803-3be21be0a5ac)
12 As a user search courses by category of healthcare or safety so that i can choose which category is of more interest.
This is located in the all_courses page at the left hand side and there is a Group By search and Location serach.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/cc7f2599-8088-4c80-8c42-5d564902fd94)
13 As a user I want to be able to search by location either online or onsite in the classroom. Also i want to be able to group courses in relation to health and safety.
List of online courses
List of classroom courses
list of health courses
list of safety courses
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/f9b495fd-d422-4832-8b21-facc20b1e842)
14 As a user I want to be able to add courses to the basket so that i can clearly see total cose of each course or courses.
When the user navigates to the Basket on the nav bar they can see first of all if they have items in the basket as the amount is displayed under the heading and once they click on the basket link they will be carried to the basket page where they will see items if they have added to the basket.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/989cc3db-1964-42e0-8774-a181bbb55b98)
if there is not items in the basket they will be brought to the following page.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/92bcc968-7298-4ae4-a3d2-6a5759f7ad88)
15 As a user I want to be able to view all courses in the basket so that i can clearly see the total cose of each course or courses.
When the user clicks on the basket on the nav bar they will be brought to the basket page where they will be able to see the items added to the basket.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/079b6471-4dd8-4b99-b5fc-b53e0ecd411c)
16 As a user I want to be able to change the quantity of courses in the bag so that I can accommodate my requirements should they change.
When the user navigates to the basket page they can increase or decrease the amount in the basket with the increment and deincrement option.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/01c7bdf5-24e9-4c62-9dc1-f868ed3346e6)
17 As a user enter my payment details so that I can complete the purchase.
When the user is in the basket page they can proceed to make a purchase and they will be brought to the secure purchase page where they will see their details if they are registered but if they are not registered the user will have to enter their details.
Proceed to payment
Secure Purchase Page ![image](https://github.com/NBJIN/kacsafetya/assets/106515976/888f869d-2842-4a84-97ba-13c32da7770d)
18 See order confriamtion once purchase is complete.
When the user is on the Secure Purchase Page above and they have all their details entered they can then click on Complete Order. Once this is clicked the spinner will appear on a red background and when successfull will navigate to the purchase success page where the user can see their order.
Loading Spinner
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/12cb4196-5105-4436-aa2d-52aa89f7f678)
Thank You For Your Purchase Page
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/6b619a11-f61c-4d81-803a-5f0a6b02d32d)
19 User can see an order history once logged in.
Once the user is logged in they will be able to navigate to My Dashboard where they will be able to see a list of purchase records once an order is place.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/66cee049-990d-437b-b51c-5b8fcd06e467)
20 As a user I want to be able to make a purchase without having to register
When an unregisterd user accesses the all courses page they can choose a course to go to the detailed view and once on this page they can add the cousre to the basket and proceed to purchase and then purchase success page. On the screenshot following one can see that the user is not logged in when making the purchase
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/50d3978b-9f1b-4732-ab7a-34913cd8f64a)
21 As a user i want to be able to sign up to the company newsletter
On the nav bar at the top of each page there is a link to sign up. When the user clicks on this link they will navigate to the newslwetter signup page where they will enter their fullname, company and email.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/433fa2c2-9e4b-4aa8-be10-2c1f9fb09939)
Once these details are entered they can then click on the submit button they will be then brought to Newsletter Signup confirmation page.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/f04eab86-9b4d-43f9-81ca-7eac304766fe)
22 As a user I want to be able to submit a contact form
In the top nav bar there is a link to Contact Us once the user clicks on this link they will be brought to the Contact KACSafety Page where the user can enter their details and their query.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/c0f04159-5ff9-427b-9412-d330165ae6df)
Once the user has entered the details and clicked on submit they will then be brought to the Contact Success Page.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/a8ccb9ed-e6df-4256-a2fe-8e2936cfc371)
23 As a user I want to be able to access company social media page
If the user naviages to the bottom footer they will see a list of links for social meida platforms like facebook, instagram, twitter and youtube. If the user click on the icon of their choice they will be brought to the website page for that social media option.
Youtube
Facebook
Twitter
Instagram
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/6c3ffbe3-fe61-4310-8afb-750e51d3d11c)
24 As a user i want to be able to see confirmation of actions completed.
When a user registers, logins etc a message will appear in the top right hand corner. At present it is only displaying for a second so timing will have to be adjusted.
Successful Signin
Add Couse
Successful Payment
Contact Success
newsletter signup
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/34437f01-2d3c-408a-88d3-0941afe036d5)
25 As an administrator I want to be able to add new courses.
When an administrator logs in they will be able to add courses through the nav link dashboard / course administration.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/1e593bd2-c72b-479b-8db0-5308b7b2d746)
When the form is completed and the user clicks on the Add Course button
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/d1c5cd75-493c-47b3-bfd2-e1374dfe960d)
they will then be brought to the detailed courses page where they will see that course added.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/d1c5cd75-493c-47b3-bfd2-e1374dfe960d)
26 As an administrator I want to be able to edit a course.
An administrator will be able to edit a course when they click on edit on the detailed course page. Once edit is clicked they will be brought to the edit course page.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/2ab297f0-828f-4707-86d2-89be18437b43)
Here once they have updated the details they can choose update course or cancel. They will also be able to access the edit course page when the administrator goes to the all courses page then click on course details and the will be brought to the detailed course page where there is an option to edit and delete course.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/add31aa6-62fb-43d0-a59d-8ad32f7a0740)
A administrator can click on course details and then navigate to the detailed courses page where they have the option to edit or delete.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/806d4247-e003-49aa-a491-44bea33cbcdb)
27 As an administrator I want to be able to delete a course.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/b8f6761c-14b2-497e-9404-60e16537866b)
28 As an administrator I want to be able to update the general content on all pages
As the administrator the user will be able to access all parts of the site and the admin panel where they will be able to manage users.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/98f298de-04b5-4475-b921-7a045474c62a)
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/0beb5494-f7e2-4297-affb-1471cfd6d630)
29 As an administrator I want to be able to manage all incomming orders.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/06b2fd64-9325-49e4-85ad-e17cf89e2e29)
30 As an administrator I want to be able to manage all incomming contact requests.
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/06b2fd64-9325-49e4-85ad-e17cf89e2e29)
31 As a developer I want to be able to test all parts of the django ecommerce website
Testing of user stories, features, code validation, lighthouse reports have all being carried out and detailed report is contained in this readme file.
32 As a developer I want to be able to deploy successfully. This project has been deployed to Heroku
![image](https://github.com/NBJIN/kacsafetya/assets/106515976/9b499754-f851-4d26-8327-eb39fdff409e)
34 As a developer I want to be able to ensure that the site is responsive.
Known Bugs
The Favicon file sometime throws a 404 error in the terminal but not always. The favicon icon is in the file and displays but on some rare occasions i have seen it to throw and error.
Got an error as i was about to submit project in under the Network tab in relation "GET https://res.cloudinary.com/dc4lcot1r/raw/upload/v1/static/contact/css/contact.d41d8cd98f00.css net::ERR_ABORTED 404" tried to do some work on it was in contact with tutor support but ran out of time.
- Robots.txt file has been installed and set up.
Features Testing
Each feature in the ecommerce site was tested to ensure that it functioned correctly there are some features that still need to be implemented.
Responsiveness
The site is reponsive across all devices and screen sizes.
Milestone/Epic : Project Planning Design and Setup (Admin)
-
2 Developer – Document project user requirements, scope and goals – (This was entered twice by mistake under the project milestone above)
-
3 Developer – Create wireframes, mock-ups, layouts and interface, user stories and kanban board.
-
4 Developer – Setup project workspace on hosting platform
Milestone/Epic : Authentication & Access (Admin and User)
-
5 (35) Admin have full access to the site
-
6 Admin – Manage user accounts
-
7 User – Register for a new account
-
8 User – login to account
-
9 User – Manage Account Information
-
10 – User – Reset password
Milestone/Epic : Authentication & Access (Admin and User)
-
11 User – View full list of courses
-
12 User – View the course in more detail
-
13 User – Search courses by category
-
14 User – Search courses by location
-
15 User – Add courses to bag
-
16 (36) User – View courses in bag
-
17 User – Change qty in bag
-
18 User – Enter payment details
-
19 User – See order confirmation
-
20 User – See order history on login
-
21 User – Make purchase without registration
-
22 User – Sign up to company newsletter
-
23 User – Submit a contact form
-
24 User – Access company social media page
-
25 User – See confirmation of actions completed
-
Milestone/Epic : Management of courses and site (Admin)
-
26 Admin – Add new courses
-
27 Admin – Edit a course
-
28 Admin – Delete a course
-
29 Admin – Update general content
-
30 Admin – Manage in-coming orders
-
31 Admin – Manage all in-coming contact requests
Milestone/Epic : Testing and Deployment (Admin)
-
32 Developer – Test all parts of the Django site
-
33 Developer – Deploy successfully
-
34 Developer – Ensure site is responsive
Deployment
With a fully working django ecommerce project the final steps to hosting the project are as follows:
• First the database is created and this will be completed by using ElephantSQL
- Set up an account with ElephantSQL if you don’t have one already else login to your account.
- Access the dashboard on ElephantSQL and click on the button ‘Create New Instance’.
- Then set up your plan by giving your plan a ‘Name’ this is usually the name of the project, then select ‘Tiny Turtle (Free) plan’ and then leave the ‘Tags’ field blank.
- Next Select “Select Region”
- Select a data center near you in this case ‘EU-West-1----’
- Then click on ‘Review’
- Review your detail again and ensure they are correct then click on ‘Create Instance’
- Go to the ElephantSQL dashboard and click on the ‘database instance name’ for the project
- Under Details in the section of this page click on copy icon at the right of the url
- Leaving this for a moment we need to create a new database instance
• Next we will create the Heroku app
- Again if a new user set up and account with Heroku or if you have an account already log in with credentials.
- Then click on ‘New’ to create a new app.
- Give your app a name and select the region closest to you
- Then click ‘Create app’
- Open the ‘settings’ tab in Heroku
- Click on ‘reveal config vars’
- Then add the config var ‘DATABASE_URL’ and then paste in the url which would have been copied from ElephantSQL.
• With the database created in ElephantSQL and app created on Heroku revert back to code specifically to the settings.py file in the project folder in Gitpod (code anywhere if using this IDE) and we need to carry out the steps to connect the db to the local development web server.
- In the terminal of the projects Gitpod workspace install dj_database_url and psycopg2 by inserting the following command in the terminal: pip3 install dj_database_url==0.5.0 psycopg2
- Update the requirements.txt file with the newly install packages by typing the following command in the terminal – pip freeze > requirements.txt
- In settings.py of the project folder import dj_database_url underneath the import os at the top of the page – import dj_database_url
- Proceed to the Database section in settings.py – need to comment out the code that is in this section and then enter code that will allow the connection to the new ElephantSQL database. Under the DATABASES commented out code add the following code –
DATABASES = {
‘default’: dj_database_url.parse(‘insert the datatbase url here from ElephantSQL’)
}
VERY IMPORTANT – Do not commit this file with your database string in the code this is just a temporary so that a connection can be made to the new database and make migrations.
- Back in the terminal run the showmigrations command – this will confirm if connection has been made to the external database. Type the following command in the terminal – python3 manage.py showmigrations
- This will return a list of all migrations – none of these migrations will be checked off
- Migrate the database models to the new database with the following command – python3 manage.py migrate.
- Create a superuser for the new database by tying the following command in the terminal – python3 manage.py createsuperuser – it will prompt to enter a username, email and password.
- To prevent exposing the database when a push is done to Github remove the code in the database section in settings.py and set up the original code for sqlite database. So in setting.py under the database section it should contain the following code:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
• Now we need to confirm the database is set up
- In ElephantSQL page for your database in the left hand side of the page select ‘BROWSER’.
- Click the ‘Table queries’ button select ‘auth_user’
- Click ‘Execute’ and you will then see the newly created superuser details displayed which is confirmation that the tables have been created and data can be added.
• Referring back to the code in the Databases section of settings.py and in particular to counteract the exposing of variable we will add an if statement so that when the app is running on Heroku whet the database URL environment variable will be defined we connect to Postgres and otherwise we connect to SQLite.
- In settings.py and above DATABASES we will add the following code –
if ‘DATABASE_URL’ in os.environ:
DATABASES = {
‘default’: dj_database_url.parse(os.environ.get(‘DATABASE_URL’))
}
else:
DATABASES = {
‘default’: {
‘ENGINE’: ‘django.db.backends.sqlite3’,
‘NAME’: os.path.join(BASE_DIR, ‘db.sqlite3’),
}
}
- Next we need to install gunicorn so in the terminal in gitpod type the following code – pip3 install gunicorn
- Then freeze the above into requirements file by typing the following in the terminal : pip3 freeze > requirements.txt
- Next create the Procfile in the root directory of the project which will tell Heroku to create a web dyno which will run gunicorn and server the django app. In the Profile file type the following – web: gunicorn ‘name of app’.wsgi:application
- Next disable collect static so that Heroku wont start collecting static file when the project is deployed. In the terminal of the project in gitpod type the following command – Heroku config:set DISABLE_COLLECTSTATIC=1 –app ‘app name’.
- Add the hostname of the Heroku app to ALLOWED_HOSTS in settings.py in section ALLOWED_HOSTS with the following code – ALLOWED_HOSTS = [‘name’.herokuapp.com’, ‘localhost’]
- Next deploy app by typing the following in the terminal - ‘git add .’ then on the next line ‘git commit -m “name of commit”’ next line ‘git push’ and then finally on the next line ‘git push Heroku main’
- Next type the following line in the termainal – Heroku git:remote -a ‘name of app’
- Return and type ‘git push Heroku main’ once you click on return this will print out a log with a link to the deployed app – when you open this link it will contain the deployed app
- Next set up automatic deploy in Heroku by clicking on ‘Deploy’ at the top of the screen then click ‘connect to GitHub’
- Click on ‘search’ to search for the repository once same has been selected click on ‘connect’.
- Now scroll down the page and click on ‘enable automatic deploys’ – this ensures that evey times we push to github our code will be deployed to Heroku also.
- Generate a secret key for Heroku. There are many online sources but the source that I have used is ‘https://djecrety.ir/’
- Once you have generated the secret key add same to the config vars in Heroku –
SECRET_KEY = ‘paste in generated key from djecrety above’.
- Next go back to settings.py and replace the secret key with –
SECRET_KEY = os.environ.get(‘SECRET_KEY’, ‘’)
- Next set DEBUG = True only if there is a a development in the environment with the following line of code – DEBUG = ‘DEVELOPMENT’ in os.environ
- Then push changes to GitHub.
- You can go to Heroku and see the build log of the project and you can view same under ‘more view logs’.
- Once this process if finished you will see the link for the app and note saying it was successfully deployed to Heroku.
• Creating a AWS account – the site needs a place to store the static files and images for the site so we will use a cloud-based storage called Amazon Web Services s3 AWS for short.
-
Create a AWS account if you have not an account already else you can login by going to the following page https://aws.amazon.com/console/ and click on my account on the nav menu at the top of the page click on the dropdown and click on ‘AWS Management Console’.
-
Once logged in you need to search of s3 under the services menu
-
When you navigate to the S3 page click on ‘create bucket’ and give it the same name as your Heroku app New we will create a bucket.
-
Then you need to select a region and select the one that is closest to you.
-
Then you need to uncheck ‘Block all public access’
-
Click on the tick box to acknowledge that the bucket will be public
-
Then click on ‘Create Bucket’ and this will bring you to the bucket list page
-
Locate the bucket that you have just created click on it and and you will be brought to the settings section
-
Click on the properties tab and then click on ‘Static website hosting’ (which will give a new endpoint which can be used to access it from the internet) this will open a new dialog box called Static website hosting. In the input box under Index document type ‘index.html’ and in the input box under Error document type ‘error.html’. Then click on save.
-
Navigate to the permissions tab and then click on ‘CORS configuration’ (this will set up the required access between the Heroku app and this s3 bucket’)
-
Then click on Save
-
Now navigate to the Bucket Policy tab and click on the ‘policy generator’ at the bottom of the screen so that we can create a security policy for this bucket.
-
This will bring you to the AWS Policy Generator Page where you will need to input some data.
-
For step 1 Select Policy Type on this page select ‘S3 Bucket Policy’
-
Under Step 2 Add Statements we want to allow all principles by adding a ‘*’ to the Principal input box. For the Actions in this section select ‘Get Object’ from the dropdown menu. Next you need to revert back to Permissions tab and then to Bucket Policy and copy the Bucket policy editor ARN: and paste it it to ‘Amazon Resource Name (ARN)’ input box in Setp 2 of the AWS Policy Generator page. Next click on ‘Add Statement’ .
-
Unser Step 3 Generate Policy click on the ‘Generate Policy’ button. A dialog box will open with the Policy JSON document copy the code in this dislog box and then go back to Permissions / Bucket Policy Tab and in the space provided under the heading Bucket policy editor ARN: paste in the Policy JSON document code. Add a ‘/*’ onto the end of the resouce key in your code. Finally click on ‘save’ on this page.
-
With the configuration for the Bucket Policy and CORS complete it will now allow full access to all resouces in the bucket.
-
Then navigate to the ‘Acces Control List’ tab and under Public Access select the radio button for ‘Everyone’. This will then open a diaglog box and click on the checkbox for ‘List object’ and then click on ‘Save’.
-
Next we need to create a user to acces the bucket
-
In AWS got to the services menu open IAM
-
Naviage to ‘groups’ in the Dasboard at the left hand side of the screen
-
Then click on ‘Create New Group’ and give it a name Group Name : ‘Enter Name Here’
-
Then click ‘Next’ and ‘Next’ again and then click on ‘Create Group’
-
Next we need to create the policy to acess bucket. Naviage to Polices on the left of the screen under Dashboard.
-
Click on ‘create policy’ and naviage to the ‘JSON’ tab
-
Click on ‘import managed policy’ at the top of the dialog box
-
Then in the search box input ‘s3’ to search for same and then choose ‘AmazonS3FullAccess’ and click on ‘Import’
-
We just want to allow access to the bucket so Navigate to ‘Services’ on the Nav bar at the top of the AWS page and on the left hand menu choose ‘s3’. Here you will get the bucket ARN from the bucket policy page in s3
-
Choose the ‘name of your bucket’ and navigate to ‘Permission’ and ‘Bucket Policy’ and copy the Bucket policy editor ARN: a the top of the large input box.
-
Then navigate back to ‘IAM Management Console’ to the ‘JSON’ file and paste the ‘ARN’ after Resoure in square brakets. Its inputted twice in double quotes and the second line has an extra ‘/*’ at the end which adds another rule for all files/folders in the bucket.
-
Then click on ‘Review Policy’ on this page
-
Give it a ‘Name’ and ‘Description’
-
Then click on ‘Create Policy’
-
This will then take the user back to the policy page and you will see a message at the top of the screen that ‘your policy name’ has been created.
-
Next attach the policy to the group that was created so navigate to ‘Groups’ under the ‘Dashboard’ then find your group ‘mange-yourgroupname’ and click on ‘attach policy’ then search for the policy that was just created and select it. Click on the tick box next to your policy and then click on ‘Attach Policy’.
-
Now create a user to put in the group – navigate to ‘users’ on the dashboard and click on ‘add user’.
-
Then create a ‘user name’ and give the user ‘programmatic access’ and then click on ‘next’.
-
Under Add user to group click on the ‘policy for the project’ to attach to the user and then click on ‘next tags’ then ‘next review’ and then click ‘create user’.
-
This will bring you to the page where there is a success message to say you have successfully created the users shown on this page.
-
We need to download the csv file on that page as it contain the users access key and secret access key which will be used to authenticate the user from the django app. V.I This file can only be downloaded once and should be completed at this stage.
• Connect Django to s3
- To connect Django to s3 we need to install two packages boto3 and django-storages
- Back in our project in Gitpod type the following command in the termianl to install boto3 – pip3 install boto3
- And to install django-storages type the following command in the terminal – pip3 install django-storages
- Now we need to freeze these requirements so in the teminal type the following command – pip3 freeze > requirements.txt
- Then add storages to installed apps in settings.py of your project
- We need to add settings to settings.py to connect django to s3 to tell it which bucket it should be communicating with.
- Under the media root code we will add an if statement –
If ‘USE_AWS’ in os.environ:
AWS_STORAGE_BUCKET_NAME = ‘insert bucket name here’
AWS_s3_REGION_NAME = ‘enter region name’
AWS_ACCESS_KEY_ID = os.environ.get(‘AWS_ACCESS_KEY_ID’)
AWS_SECRET_ACCESS_KEY = os.environ.get(‘AWS_SECRET_ACCESS_KEY’)
- Now we need to go to Heroku and add aws keys to config variables in the deploy section
Github
- Login to GitHub and create your new repository
- Go to the Repositories tab click on New
- Then enter the name of the repository you wish to create
- Click on create repository
- New repository is now ready to use
Setting Up Django
This project uses the Django framework
-
First of all the user needs to install Django so in the terminal enter the command – pip3 install django
-
Then to create a new project the user needs to type the following command in the terminal - django-admin startproject ‘insert your project name here’
-
Then the user needs to add a gitignore file in the command line type the following command – touch .gitignore
-
The user will add the following files to the .gitignore file
o *.sqlite3
o *.pyc
o pycache
-
Then the user needs to run the server to see if base project is running by inputting the following in the terminal – python3 manage.py runserver which will open the 8000 port in which the user will be able to view the base project in the browser when they open this port.
-
The user will then need to run the migrate command by inputting the following command in the terminal – python3 manage.py migrate
-
The user will then have to create a superuser in order to access the admin panel so that they can view the information for the site and make the necessary changes. To create a superuser in the terminal the user will input – python3 manage.py createsuperusere.
-
The user will then be prompted to enter a username, email and a password.
-
The user will then make the initial commit to github wit the following commands in the terminal :
o git add .
o git commit -m “initial commit”
o git push
-
This will push all the setup and changes for this project up to GitHub.
All Auth
To cover user account for example registration and login the user will use Allauth which automatically handles the user account process. The steps to installing django allauth are in the attached link:
https://django-allauth.readthedocs.io/en/latest/installation.html
Heroku
The user will do the final deployment to Heroku
Login to your account click on the new button and crate new app
Choose a name for the app, select the region which is closest to you and click create new app
On the resources tab navigate to the Add-ons section and search for Heroku Postgres
Select Heroku Postgres then under plan name choose Hoobey Dev free and click submit order form
To use Postgres you will need to install dj_database_url and psycopg2. This should be done in whatever IDE you are using.
1 In your IDE type the command:
pip3 install dj_database_url
2 Then once that is installed type the command:
pip3 install psycopg2-binary
3 Then, to make sure Heroku install all your apps requirements when you deploy it, run the command:
pip3 freeze > requirements.txt
4 Next, navigate to your setting.py file in your main project folder. At the top of the file add the line: import dj_database_url
5 Then scroll down the file till you find your database settings. Comment out the default configuration and underneath insert the code:
6 DATABASES = {
'default': dj_database_url.parse(Enter Database URL here)
}
7 The database URL can be found in the settings tab of your app in heroku, under Config Vars. Make sure to have the link in quotation marks
8 If you want to migrate any data from your current database to the Postgres database in Heroku, make sure you run this line before connecting to Postgres:
./manage.py dumpdata --exclude auth.permission --exclude contenttypes > db.json
9 Once that's saved, you will now need to run migrations because you have connected to a new database. This is done by running the command: python3 manage.py migrate If you had previously saved your data to import into the postgres database, you can now run the command:
./manage.py loaddata db.json
10 Now that's setup you will now need to create a superuser for the new database. The command is: python3 manage.py createsuperuser Note, once the superuser is created, it's a good idea to sign into the admin panel, locate the user, and check the option that says their email is verified. This is needed otherwise Allauth won't allow the user to sign into the store.
11 Before you commit these changes, you will need to remove the Databases section in the settings.py and uncomment the original database. This is to stop your Postgres database URL from ending up in version control.
12 Now we can create an if statement in our settings.py to run the postgres database when using the app on heroku or sqlite if not. Scroll back to the database section and refactor the code to look like this:
if 'DATABASE_URL' in os.environ:
DATABASES = {
'default': dj_database_url.parse(os.environ.get('DATABASE_URL'))
}
else:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': BASE_DIR / 'db.sqlite3',
}
}
Credits
Content
Content for courses were taken from Helath and Safety Authority website.
Media
Most pictures were taken form pexels.com
Acknowledgements
Thanks to our Cohort Facilitator Iris, Class Lead Ivette, to my amazing class mates for their time and knowlege, to the all the patient people in Tutor Assitance and to Student Care.
Also want to say a big thank you to Mentor Sammy, Marcel and Luke for all their help and support along this journey.