Final Report
Final Report
Final Report
My Awesome Cart
Towards partial fulfilment of Requirement for
the award of degree of
Bachelor of Computer Application
University of Lucknow
2019-2020
1
CERTIFICATE OF ORIGINALITY
Under my guidance. The Matter embodies in this project is genuine work done by the student
and has not been submitted whether to the University or to and University/Institute for the
fulfilment of any course of study………………………………….
2
ACKNOWLEDGEMENT
This is to certify that I Sumit Kumar Yadav student of B.C.A. (Vth Sem.) has completed my
Minor project File based on College website. The satisfaction and euphoria that accompany the
development of any task would be incomplete without the mention of the people who make it
possible, whose constant guidance and encouragement crowned our efforts with success.
We, the developers feel indebted to a lot of people who during the course of our
project not only held us in good stead but also provided us with invaluable services both
personal and professional. At this juncture, when we, at the successful completion of our
project are presenting our report it would be unfair not to acknowledge the various acts of
kindness done to us by our teachers. They were always present on our every back and call to
help us out of every hurdle and obstacle that we faced.
Our first vote of thanks goes to our Parents, with every gesture, every word, every
pat on the back, they have always tried to inspire us for better things and attain them. More so
with this project, they were with us every instant, sharing our joys-when the code used to work
and wiping our tears when machine used to hang.
We wish to place on record our whole hearted gratitude to our project guide for
making available every facility that we required during the course of our project. Also, we are
extremely thankful to you sir for extending your kind guidance and words of wisdom from your
treasure trove of experience. With friendly advice and guidance at every step, his presence was
a welcome sight throughout the project. Thank you sir.
Basically, this Minor project report is just an excuse to convey our feelings about
how much we appreciate the amount of concern and caring that our teachers exhibit in all our
pursuits ranging from anything as simple as the routine lab program to something as taxing as
a project. Their patient listening to our problem is itself a major source of strength to us.
Thanks to all of you. Finally I would like to bind up by paying our heartfelt thanks
and prayers to the Almighty.
3
CONTENT
4
TITLE OF THE PROJECT
MY AWESOME CART
The title of the project is “My Awesome Cart” , this title has been chosen as this software is
mainly been made for customers who want to shop online products from home or anywhere
without going in markets and without wasting time.
5
SYNOPSIS OF
MY
AWESOME CART
6
ACKNOWLEDGEMENT
I have taken efforts in this project. However, it would not have been possible without the
kind support and help of my teachers and my college.
I am highly indebted to my Sir for his guidance and constant supervision as well as for
providing necessary information regarding the project.
I would like to express my gratitude towards my parents and teachers for their kind support
and co-operation which helped me in completing this project.
My thanks also go to my friends who shared their suggestions with me and people who have
willingly helped me out with their abilities.
INTRODUCTION
My Awesome Cart is a web based application that works within a centralized network. This
project presents a review on the software program “My Awesome Cart” as should be used in a
E-commerce system, a facility which is used for book orders, cancellation of orders and
different types of enquiries regarding products.
It maintains all customers details, orders details, shopping details. In order to achieve designs,
from google chrome was chosen.
Python language and HTML was used for the front-end of the software while the back-end was
design using Django Framework.
Online Booking
Database work.
Supports customer’s online product booking.
Supports customer’s feedback.
It facilitates customer to quantity of products.
It maintains all customer details.
An online payment using credit cards/debit cards should be implemented into the
system.
Ability to store all database in a secure file.
7
THIS PROJECT DIVIDED INTO THREE MODULES:
ADMIN LOGIN MODULE: This module is for admin. In this module the
following links will be provided :-
Order-id: This module is for user. In this module the following links will be
provided:-
8
Order-id snapshot
Contact us snapshot
9
OBJECTIVE OF THE PROJECT
iii) Easing payment by obtaining a bank pin after payments is made to the various designated
banks.
iv) Ability of customers to cancel their orders.
Project Category
The basic aim in the new proposed system was to provide all improved functionality and
flavor system minus the entire drawbacks or shortcoming analysed. With front end like
HTML & Python and backend Django Framework most of the major irritants due the
conventional file system, were removed without many efforts. Django Framework has
evolved into a full featured open source relational database management system(RDBMS).
Django is a Python-based free and open-source web framework, which follows the model-
template-view architectural pattern. It is maintained by the Django Software Foundation,
an independent organization established as a 501 non-profit. Django's primary goal is to
ease the creation of complex, database-driven websites.
10
TOOLS AND PLATEFORM
Python
Django
Features of Python
Python is easy to learn and use. It is developer-friendly and high level programming
language.
Python language is more expressive means that it is more understandable and readable.
Python is an interpreted language i.e. interpreter executes the code line by line at a time. This
makes debugging easy and thus suitable for beginners.
Python supports object oriented language and concepts of classes and objects come into existence.
It can be easily integrated with languages like C, C++, JAVA etc.
Graphical user interfaces can be developed using Python.
Features of Django
Django was designed with the intention to make a framework which takes less time to build
web application. The project implementation phase is a very time taken but Django creates it
rapidly.
Django takes security seriously and helps developers to avoid many common security
mistakes, such as SQL injection, cross-site scripting, cross-site request forgery etc. Its user
authentication system provides a secure way to manage user accounts and passwords.
Django includes various helping task modules and libraries which can be used to handle
common Web development tasks. Django takes care of user authentication, content
administration, site maps, RSS feeds etc.
11
HARDWARE AND SOFTWARE
REQUIREMENTS
Hardware Requirements:
Software Requirements:-
12
MODULE DESCRIPTION
ORDER-id: This module is for user. In this module the following links
will be provided:-
CONTACT-US MODULE:
This module is for the user. In this module, the users can give their
feedback.
13
DATABASE DESCRIPTION
ADMIN
FIELD DATA TYPE LENGTH CONSTRAINT
Name varchar 45 Primary key
adminid varchar 45 Not null
password varchar 45 Not null
Mail varchar 45 Not null
mobile varchar 45 Not null
City varchar 45 Not null
AVAIBILITY
FIELD DATA TYPE LENGTH CONSTRAINT
productid varchar 45 Primary key
price varchar 45 Not null
quantity varchar 45 Not null
rating varchar 45 Not null
views varchar 45 Not null
status varchar 45 Not null
PRODUCT INFO
FIELD DATA TYPE LENGTH CONSTRAINT
idproductinfo varchar 45 Primary key
productname varchar 45 Not null
address varchar 45 Not null
dispatch varchar 45 Not null
dtime varchar 45 Not null
atime varchar 45 Not null
types varchar 45 Not null
price varchar 45 Not null
Discount varchar 45 Not null
14
CONTACTUS
SECURITY MEASURE
The security system is needed for recognizing and protecting against unauthorized and
inappropriate access to the database by the people and the software programs that process against
the database. Providing software security involves hardware, software and users are often
achieved through the use of verification techniques. These verification techniques are used to
authenticate users and terminals to detect unauthorized access attempt to prohibit unauthorized
data manipulation and to support multilevel security that trust the system to segregate the users
and data.
Authentication
There are two ways of restricting access to documents: either by the hostname of the browser
being used, or by asking for a username and password. The former can be used to, for example,
restrict documents to use within a company. However if the people who are allowed to access the
documents are widely dispersed, or the server administrator needs to be able to control access on
an individual basis, it is possible to require a username and password before being allowed access
to a document. This is called user authentication.
Authorization
15
formally, "to authorize" is to define access policy. Access control in computer systems and
networks relies on access policies. The access control process can be divided into two phases:
Authorization is the function of the policy definition phase which precedes the policy enforcement
phase where access requests are granted or rejected based on the previously defined
authorizations.
16
INTRODUCTION
17
My awesome cart is a web based application that works within a centralized network. This
project presents a review on the software program “My Awesome Cart” as should be for
purchasing products online, a facility which is used to place orders, cancellation of order and
different types of route enquiries regarding products
It maintains all customers details, product details, orders details. In order to achieve designs,
from google crome was chosen.
Python language was used for the front-end of the software while the back-end was design
using Django.
The software achieved is capable of improving the customer hand and relationship management
in operation. It is recommended that dispite the present functionality of the design software, an
additional functionality such as the use of email to track orders and notification to the customer
and an online payment using credit cards/debit cards should be implemented into the system.
Every organisation, whether big or small, has challenges to overcome And managing the
information of products, customer, suppliers. Every order booking system has different needs,
therefore we design exclusive employ management systems that are adapted to your managerial
requirements. This is designed to assist in strategic planning, and will help you ensure that your
organisation is equipped with the right level of information and details for future goals. Also,
for those busy executive who are always on the go, our systems come with remote access
features, which will allow you to manage your work force anytime, at all times. These systems
will ultimately allow you to better manage resources.
18
OBJECTIVE
19
E-commerce is the route for purchasing goods and services online. The money transactions are done through
online thus leads to the digital economy.
One research data to know is that 80% of online users buy their products in an online store than a physical
store. As per statistics, $4.5 trillion in sales are expected by 2021.
Need Of E-commerce
More than reach, it also important for increasing digital transactions of the country.
Customer satisfaction will be improved more.
More offers and discounts will be provided for buyers.
Easy to spread business across countries
Helps to increase our national income
20
SURVEY OF TECHNOLOGY
21
Open Source Scripts
Django with Softaculous connects you to a world of popular and free open-source languages
and application like Pyhton, mysql, mongodb, angular. Simply select your favourite application
or language, and it handles the downloading and installation of new module for project.
Configuring Django
Django provides you to create and delete local or network domains. You can manage
Apache and MySQL very easily with Django. Django offers high security and also provide
rapid developement
Database
Django can set up to communicate with SQLite, Mysql, SAP, IMM DB2. Django officially
supports three other popular relational databases that include: PostgreSQL, MySQL and
Oracle and unofficially Firebird, ODBC and many others.
22
FUNCTIONAL AND NON-
FUNCTIONAL REQUIREMENT
23
Functional requirements: -
Functional requirement are those requirement which affect the system. These requirements make
the system working. Functional requirements describe what the system should do. In this system
Students can give their feedback and ask their queries also.
Roll number of the student depends upon the information filled by the admin.
Students can login after entering the correct user name and password.
Non-Functional Requirement
Non-functional requirement are those requirement which do not make any impact on the
The objective of software project planning is to provide a framework that enables the
manager to make reasonable estimates of resources, cost, and schedule. These estimates are
made within a limited time frame at the beginning of a software project and should be
updated regularly as the project progresses. In addition, estimates should attempt to define
best case and worst case scenarios so that project outcomes can be bounded.
Charting Techniques:-
Gantt chart:-
A Gantt chart, commonly used in project management, is one of the most popular and
useful ways of showing activities (tasks or events) displayed against time. On the left of the
24
chart is a list of the activities and along the top is a suitable time scale. Each
activity is represented by a bar; the position and length of the bar reflects the
start date, duration and end date of the activity. This allows you to see at a
glance:
Hardware Requirements:-
39
25
schedule, organize, and coordinate tasks within a project. PERT stands
for Program Evaluation Review Technique; a methodology developed
by the U.S. Navy in the 1950s to manage the Polaris submarine missile
program. A similar methodology, the Critical Path Method (CPM)
was developed for project management in the private sector at about the
same time.
26
Hardware and software
requirement
27
Hardware Requirements:
Processor : Dual
core or above RAM : 1 GB
Disk space : 500 GB
Monitor : 15 inch color
Printer : Depend on user
Keyboard : 108 Key Normal
Mouse : 3 Button Normal Mouse
Software Requirements:-
Logical Design
Logical design of an information system shows the major features and also
how they are related to one another. The first step of the system design is to
design logical design elements. This is the most creative and challenging phase
and is also important. Design of proposed system produces the details of the
state how the system will meet the requirements identified during the system
analysis, i.e., in the design phase we have to find how to solve the difficulties
faced by the existing system. The logical design of the proposed system should
include the details that contain how the solutions can be implemented. It also
28
specifies how the database is to be built for storing and retrieving data? What
kind of reports are to be created? And what are the inputs to be given to the
system? and so on. The logical design includes input design, output design,
database design and physical design.
Input Design
The input design is the link between the information system and the user (s).
It comprises the developing specification and procedures for data preparation
and those steps are necessary to put transaction data into a usable form for
processing data entry. The activity of putting data into the computer for
processing can be achieved by inspecting the computer to read data from a
written or printed document or it can occur by having people keying the data
directly into the system.
The system needs the data regarding the asset items, depreciation rates, asset
transfer, and physical verification for various validation, checking,
calculation and report generation. The error raising method is also included
in the software, which helps to raise error message while wrong entry of input
is done. So, in input design the following things are considered: -
- Methods for preparing input validations and steps to follow when error occurs.
29
Output Design
Computer output is the most important and direct information source to the
users. Output design is a process that involves designing necessary outputs in
the form of reports that should be given to the users according to the
requirements. Efficient, intelligible output design should improve the
system's relationship with the users and help in decision making. Since the
reports are directing referred by the management for taking decisions and to
draw conclusions, they must be designed with almost care and the details in
the reports must be simple, descriptive and clear to the users.
30
Modular Design
MODULES: -
Login module
Contact-us module.
Sign up module.
31
CODING
32
index.html
{% extends 'shop/basic.html' %}
{% block title%} MyAwesomeCart - Best Ecommerce Website{% endblock %}
{% block css %}
.col-md-3
{
display: inline-block;
margin-left:-4px;
}
.carousel-indicators .active {
background-color: blue;
}
.col-md-3 img{
width: 170px;
height: 200px;
}
body .carousel-indicator li{
background-color: blue;
}
body .carousel-indicators{
bottom: -40px;
}
.carousel-indicators li {
background-color: #7270fc;
}
body .carousel-control-prev-icon,
body .carousel-control-next-icon{
background-color: blue;
}
33
.carousel-control-prev,
.carousel-control-next{
top: auto;
bottom: auto;
padding-top: 222px;
}
body .no-padding{
padding-left: 0,
padding-right: 0;
}
{% endblock %}
{% block body %}
{% load static %}
<div class="container">
<!--Slideshow starts here -->
{% for product, range, nSlides in allProds %}
<h5 class="my-4">Flash Sale On {{product.0.category}} - Recommended Items</h5>
<div class="row">
<div id="demo{{forloop.counter}}" class="col carousel slide my-3" data-ride="carousel">
<ul class="carousel-indicators">
<li data-target="#demo{{forloop.counter}}" data-slide-to="0" class="active"></li>
{% for i in range %}
<li data-target="#demo{{forloop.parentloop.counter}}" data-slide-to="{{i}}"></li>
{% endfor %}
</ul>
<div class="container carousel-inner no-padding">
<div class="carousel-item active">
{% for i in product %}
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card align-items-center" style="width: 18rem;">
<img src='/media/{{i.image}}' class="card-img-top" alt="...">
<div class="card-body">
34
<h5 class="card-title" id="namepr{{i.id}}">{{i.product_name}}</h5>
<p class="card-text">{{i.desc|slice:"0:53"}}...</p>
<h6 class="card-title" >Price: <span
id="pricepr{{i.id}}">{{i.price}}</span></h6>
<span id="divpr{{i.id}}" class="divpr">
<button id="pr{{i.id}}" class="btn btn-primary cart">Add To Cart</button>
</span>
<a href="/shop/products/{{i.id}}"><button id="qv{{i.id}}" class="btn btn-
primary cart">QuickView</button></a>
</div>
</div>
</div>
{% if forloop.counter|divisibleby:4 and forloop.counter > 0 and not forloop.last %}
</div>
<div class="carousel-item">
{% endif %}
{% endfor %}
</div>
</div>
</div>
<!-- left and right controls for the slide -->
<a class="carousel-control-prev" href="#demo{{forloop.counter}}" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#demo{{forloop.counter}}" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
{% endfor %}
</div>
{% endblock %}
{% block js %}
<script>
35
// Find out the cart items from localStorage
if (localStorage.getItem('cart') == null) {
var cart = {};
} else {
cart = JSON.parse(localStorage.getItem('cart'));
updateCart(cart);
}
// If the add to cart button is clicked, add/increment the item
//$('.cart').click(function() {
$('.divpr').on('click', 'button.cart', function(){
var idstr = this.id.toString();
if (cart[idstr] != undefined) {
qty = cart[idstr][0] + 1;
} else {
qty = 1;
name = document.getElementById('name'+idstr).innerHTML;
price = document.getElementById('price'+idstr).innerHTML;
cart[idstr] = [qty, name, parseInt(price)];
}
updateCart(cart);
});
//Add Popover to cart
$('#popcart').popover();
updatePopover(cart);
function updatePopover(cart) {
console.log('We are inside updatePopover');
var popStr = "";
popStr = popStr + "<h5> Cart for your items in my shopping cart </h5><div class='mx-2 my-2'>";
var i = 1;
for (var item in cart) {
popStr = popStr + "<b>" + i + "</b>. ";
popStr = popStr + document.getElementById('name' + item).innerHTML.slice(0, 19) + "... Qty:
" + cart[item][0] + '<br>';
36
i = i + 1;
}
popStr = popStr + "</div> <a href='/shop/checkout'><button class='btn btn-primary' id
='checkout'>Checkout</button></a> <button class='btn btn-primary' onclick='clearCart()' id
='clearCart'>Clear Cart</button> "
console.log(popStr);
document.getElementById('popcart').setAttribute('data-content', popStr);
$('#popcart').popover('show');
}
function clearCart() {
cart = JSON.parse(localStorage.getItem('cart'));
for (var item in cart) {
document.getElementById('div' + item).innerHTML = '<button id="' + item + '" class="btn btn-
primary cart">Add To Cart</button>'
}
localStorage.clear();
cart = {};
updateCart(cart);
}
function updateCart(cart) {
var sum = 0;
for (var item in cart) {
sum = sum + cart[item][0];
document.getElementById('div' + item).innerHTML = "<button id='minus" + item + "' class='btn
btn-primary minus'>-</button> <span id='val" + item + "''>" + cart[item][0] + "</span> <button
id='plus" + item + "' class='btn btn-primary plus'> + </button>";
}
localStorage.setItem('cart', JSON.stringify(cart));
document.getElementById('cart').innerHTML = sum;
console.log(cart);
updatePopover(cart);
}
// If plus or minus button is clicked, change the cart as well as the display value
$('.divpr').on("click", "button.minus", function() {
37
a = this.id.slice(7, );
cart['pr' + a][0] = cart['pr' + a][0] - 1;
cart['pr' + a][0] = Math.max(0, cart['pr' + a][0]);
if (cart['pr' + a][0] == 0){
document.getElementById('divpr' + a).innerHTML = '<button id="pr'+a+'" class="btn btn-
primary cart">Add to Cart</button>';
delete cart['pr'+a];
}
else{
document.getElementById('valpr' + a).innerHTML = cart['pr' + a][0];
}
updateCart(cart);
});
$('.divpr').on("click", "button.plus", function() {
a = this.id.slice(6, );
cart['pr' + a][0] = cart['pr' + a][0] + 1;
document.getElementById('valpr' + a).innerHTML = cart['pr' + a][0];
updateCart(cart);
});
</script>
{% endblock %}
38
Basic.html
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
39
<li class="nav-item">
<a class="nav-link" href="/shop/about">About Us</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/shop/tracker">Tracker</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/shop/contact">Contact Us</a>
</li>
</ul>
<form class="form-inline my-2 my-lg-0">
<input class="form-control mr-sm-2" type="search" placeholder="Search" aria-label="Search">
<button class="btn btn-outline-success my-2 my-sm-0" type="submit">Search</button>
</form>
<button type="button" class="btn btn-secondary mx-2" id="popcart" data-container="body" data-
toggle="popover" data-placement="bottom" data-html="true" data-content="Vivamus
sagittis lacus vel augue laoreet rutrum faucibus.">
Cart(<span id="cart">0</span>)
</button>
</div>
</nav>
{% block body %} {% endblock %}
40
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.6/umd/popper.min.js"
integrity="sha384-
wHAiFfRlMFy6i5SRaxvfOCifBUQy1xHdJ/yoi7FRNXMRBu5WHdZYu1hA6ZOblgut"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/js/bootstrap.min.js"
integrity="sha384-
B0UglyR+jN6CkvvICOB2joaf5I4l3gm9GU6Hc1og6Ls7i6U/mkkaduKaBhlAXv9k"
crossorigin="anonymous"></script>
{% block js %} {% endblock %}
</body>
</html>
41
productview.html
{% extends 'shop/basic.html' %}
</div>
<div class="col-md-8">
<h5>{{product.product_name}}</h5>
<p><b>Rs.{{product.price}} </b></p>
<p>{{product.desc}}</p>
</div>
</div>
</div>
{% endblock %}
42
{% block js %}
<script>
console.log('working');
if(localStorage.getItem('cart') == null){
var cart = {};
}
else
{
cart = JSON.parse(localStorage.getItem('cart'));
document.getElementById('cart').innerHTML = Object.keys(cart).length;
}
$('.cart').click(function(){
console.log('clicked');
var idstr = this.id.toString();
console.log(idstr);
if (cart[idstr] !=undefined){
cart[idstr] = cart[idstr] + 1;
}
else
{
cart[idstr] = 1;
}
console.log(cart);
localStorage.setItem('cart', JSON.stringify(cart));
document.getElementById('cart').innerHTML = Object.keys(cart).length;
});
$('#popcart').popover();
document.getElementById("popcart").setAttribute('data-content', '<h5>Cart for your items in my
shopping cart</h5>');
</script>
{% endblock %}
43
Search.html
{% extends 'shop/basic.html' %}
{% block css %}
.col-md-3
{
display: inline-block;
margin-left:-4px;
}
.carousel-indicators .active {
background-color: blue;
}
.col-md-3 img{
width: 170px;
height: 200px;
}
body .carousel-indicator li{
background-color: blue;
}
body .carousel-indicators{
bottom: -40px;
}
.carousel-indicators li {
background-color: #7270fc;
}
body .carousel-control-prev-icon,
body .carousel-control-next-icon{
44
background-color: blue;
}
.carousel-control-prev,
.carousel-control-next{
top: auto;
bottom: auto;
padding-top: 222px;
}
body .no-padding{
padding-left: 0,
padding-right: 0;
}
{% endblock %}
{% block body %}
{% load static %}
<div class="container">
<!--Slideshow starts here -->
{% for product, range, nSlides in allProds %}
<h5 class="my-4">Flash Sale On {{product.0.category}} - Recommended Items</h5>
<div class="row">
<div id="demo{{forloop.counter}}" class="col carousel slide my-3" data-ride="carousel">
<ul class="carousel-indicators">
<li data-target="#demo{{forloop.counter}}" data-slide-to="0" class="active"></li>
{% for i in range %}
<li data-target="#demo{{forloop.parentloop.counter}}" data-slide-to="{{i}}"></li>
{% endfor %}
</ul>
<div class="container carousel-inner no-padding">
<div class="carousel-item active">
{% for i in product %}
<div class="col-xs-3 col-sm-3 col-md-3">
<div class="card align-items-center" style="width: 18rem;">
45
<img src='/media/{{i.image}}' class="card-img-top" alt="...">
<div class="card-body">
<h5 class="card-title" id="namepr{{i.id}}">{{i.product_name}}</h5>
<p class="card-text">{{i.desc|slice:"0:53"}}...</p>
<h6 class="card-title" >Price: <span
id="pricepr{{i.id}}">{{i.price}}</span></h6>
<span id="divpr{{i.id}}" class="divpr">
<button id="pr{{i.id}}" class="btn btn-primary cart">Add To Cart</button>
</span>
<a href="/shop/products/{{i.id}}"><button id="qv{{i.id}}" class="btn btn-
primary cart">QuickView</button></a>
</div>
</div>
</div>
{% if forloop.counter|divisibleby:4 and forloop.counter > 0 and not forloop.last %}
</div>
<div class="carousel-item">
{% endif %}
{% endfor %}
</div>
</div>
</div>
<!-- left and right controls for the slide -->
<a class="carousel-control-prev" href="#demo{{forloop.counter}}" data-slide="prev">
<span class="carousel-control-prev-icon"></span>
</a>
<a class="carousel-control-next" href="#demo{{forloop.counter}}" data-slide="next">
<span class="carousel-control-next-icon"></span>
</a>
</div>
{% endfor %}
</div>
{% endblock %}
46
{% block js %}
<script>
{% if msg|length != 0 %}
alert('{{msg}}');
window.location.href = "/"
{% endif %}
// Find out the cart items from localStorage
if (localStorage.getItem('cart') == null) {
var cart = {};
} else {
cart = JSON.parse(localStorage.getItem('cart'));
updateCart(cart);
}
// If the add to cart button is clicked, add/increment the item
//$('.cart').click(function() {
$('.divpr').on('click', 'button.cart', function(){
var idstr = this.id.toString();
if (cart[idstr] != undefined) {
qty = cart[idstr][0] + 1;
} else {
qty = 1;
name = document.getElementById('name'+idstr).innerHTML;
price = document.getElementById('price'+idstr).innerHTML;
cart[idstr] = [qty, name, parseInt(price)];
}
updateCart(cart);
});
//Add Popover to cart
$('#popcart').popover();
updatePopover(cart);
function updatePopover(cart) {
console.log('We are inside updatePopover');
47
var popStr = "";
popStr = popStr + "<h5> Cart for your items in my shopping cart </h5><div class='mx-2 my-2'>";
var i = 1;
for (var item in cart) {
popStr = popStr + "<b>" + i + "</b>. ";
popStr = popStr + document.getElementById('name' + item).innerHTML.slice(0, 19) + "... Qty:
" + cart[item][0] + '<br>';
i = i + 1;
}
popStr = popStr + "</div> <a href='/shop/checkout'><button class='btn btn-primary' id
='checkout'>Checkout</button></a> <button class='btn btn-primary' onclick='clearCart()' id
='clearCart'>Clear Cart</button> "
console.log(popStr);
document.getElementById('popcart').setAttribute('data-content', popStr);
$('#popcart').popover('show');
}
function clearCart() {
cart = JSON.parse(localStorage.getItem('cart'));
for (var item in cart) {
document.getElementById('div' + item).innerHTML = '<button id="' + item + '" class="btn btn-
primary cart">Add To Cart</button>'
}
localStorage.clear();
cart = {};
updateCart(cart);
}
function updateCart(cart) {
var sum = 0;
for (var item in cart) {
sum = sum + cart[item][0];
document.getElementById('div' + item).innerHTML = "<button id='minus" + item + "' class='btn
btn-primary minus'>-</button> <span id='val" + item + "''>" + cart[item][0] + "</span> <button
id='plus" + item + "' class='btn btn-primary plus'> + </button>";
}
48
localStorage.setItem('cart', JSON.stringify(cart));
document.getElementById('cart').innerHTML = sum;
console.log(cart);
updatePopover(cart);
}
// If plus or minus button is clicked, change the cart as well as the display value
$('.divpr').on("click", "button.minus", function() {
a = this.id.slice(7, );
cart['pr' + a][0] = cart['pr' + a][0] - 1;
cart['pr' + a][0] = Math.max(0, cart['pr' + a][0]);
if (cart['pr' + a][0] == 0){
document.getElementById('divpr' + a).innerHTML = '<button id="pr'+a+'" class="btn btn-
primary cart">Add to Cart</button>';
delete cart['pr'+a];
}
else{
document.getElementById('valpr' + a).innerHTML = cart['pr' + a][0];
}
updateCart(cart);
});
$('.divpr').on("click", "button.plus", function() {
a = this.id.slice(6, );
cart['pr' + a][0] = cart['pr' + a][0] + 1;
document.getElementById('valpr' + a).innerHTML = cart['pr' + a][0];
updateCart(cart);
});
</script>
{% endblock %}
49
Checkout.html
{% extends 'shop/basic.html' %}
{% block title%} Checkout - My Awesome Cart{% endblock %}
{% block body %}
<div class="container">
<div class="col my-4">
<h2>Step 1 - My Awesome Cart Express Checkout - Review Your Cart Items</h2>
<div class="my-4">
<ul class="list-group" id="items">
</ul>
<nav aria-label="breadcrumb">
<ol class="breadcrumb mt-3">
<li class="breadcrumb-item active" aria-current="page">Your Cart Total Is <b>Rs. <span
id="totalPrice"></span></b>. Enter your details below & place your order. Thanks for using My
Awesome Cart!</li>
</ol>
</nav>
</div>
</div>
<div class="col my-4">
<h2>Step 2 - Enter Address & Other Details:</h2>
<form method="post" action="/shop/checkout/">{% csrf_token %}
<input type="hidden" name="itemsJson" id="itemsJson">
<input type="hidden" name="amount" id="amount">
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputname">Name</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Name">
</div>
<div class="form-group col-md-6">
<label for="inputEmail4">Email</label>
50
<input type="email" class="form-control" id="email" name="email"
placeholder="Email">
</div>
</div>
<div class="form-group">
<label for="inputAddress">Address</label>
<input type="text" class="form-control" id="address1" name="address1"
placeholder="1234 Main St">
</div>
<div class="form-group">
<label for="inputAddress2">Address line 2</label>
<input type="text" class="form-control" id="address2" name="address2"
placeholder="Apartment, studio, or floor">
</div>
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputCity">City</label>
<input type="text" class="form-control" id="city" name="city">
</div>
<div class="form-group col-md-4">
<label for="inputState">State</label>
<input type="text" class="form-control" id="state" name="state" placeholder="Enter
State">
</div>
<div class="form-group col-md-2">
<label for="inputZip">Zip</label>
<input type="text" class="form-control" id="zip_code" name="zip_code">
</div>
</div>
<div class="form-group">
<label for="inputZip">Phone Number</label>
<input type="tel" class="form-control" id="phone" name="phone">
</div>
<button type="submit" class="btn btn-primary">Place Order</button>
51
</form>
</div>
</div>
{% endblock %}
{% block js %}
<script>
if (localStorage.getItem('cart') == null) {
var cart = {};
} else {
cart = JSON.parse(localStorage.getItem('cart'));
}
console.log(cart);
var sum = 0;
var totalPrice = 0;
if ($.isEmptyObject(cart)) {
//if object is empty
mystr = `<p>Your cart is empty, please add some items to your cart before checking out!</p>`
$('#items').append(mystr);
} else {
for (item in cart) {
let name = cart[item][1];
let qty = cart[item][0];
let itemPrice = cart[item][2];
sum = sum + qty;
totalPrice = totalPrice + qty* itemPrice;
mystr = `<li class="list-group-item d-flex justify-content-between align-items-center">
${name}
<span class="badge badge-primary badge-pill">${qty}</span>
</li>`
$('#items').append(mystr);
}
}
52
document.getElementById('cart').innerHTML = sum;
document.getElementById('totalPrice').innerHTML = totalPrice;
$('#itemsJson').val(JSON.stringify(cart));
{% if thank %}
alert('Thanks for ordering with us. Your order is is {{id}}. Use it to track your order using our order
tracker');
localStorage.clear();
document.location = "/shop";
{% endif %}
$('#amount').val($('#totalPrice').html())
</script>
{% endblock %}
53
paytm.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Paytm merchant payment page</title>
</head>
<body>
<h1>Redirecting you to the merchant ... </h1>
<h1>Please do not refresh your page ... </h1>
<form action="https://securegw-stage.paytm.in/theia/processTransaction" method="post"
name="paytm">
{% for key, value in param_dict.items %}
<input type="hidden" name="{{key}}" value="{{value}}">
{% endfor %}
</form>
</body>
<script>
document.paytm.submit()
</script>
</html>
54
Paymentstatus.html
{% extends 'shop/basic.html' %}
{% block title%} My Awesome Cart Tracker{% endblock %}
{% block body %}
<div class="container">
{{response}}
<div class="col my-4">
</div>
</div>
{% endblock %}
{% block js %}
<script>
</script>
{% endblock %}
55
tracker.html
{% extends 'shop/basic.html' %}
{% block title%} My Awesome Cart Tracker{% endblock %}
{% block body %}
<div class="container">
<div class="col my-4">
<h2>Enter your Order Id and Email address to track your order</h2>
<form method="post" action="#" id="trackerForm">{% csrf_token %}
<div class="form-row">
<div class="form-group col-md-6">
<label for="inputname">Order Id</label>
<input type="text" class="form-control" id="orderId" name="orderId"
placeholder="Order Id">
</div>
<div class="form-group col-md-6">
<label for="inputEmail4">Email</label>
<input type="email" class="form-control" id="email" name="email"
placeholder="Email">
</div>
<button type="submit" class="btn btn-primary">Track Order</button>
</div>
</div>
<div class="col my-4">
<h2>Your Order Status</h2>
<div class="my-4">
<ul class="list-group" id="items">
Enter your order Id and Email and click Track Order to find details about your order!
</ul>
</div>
<h2>Your Order Details</h2>
<div class="my-4">
<ul class="list-group" id="citems">
</ul>
56
</div>
</div>
</div>
{% endblock %}
{% block js %}
<script>
$('#trackerForm').submit(function(event) {
$('#items').empty();
var formData = {
'orderId': $('input[name=orderId]').val(),
'email': $('input[name=email]').val(),
'csrfmiddlewaretoken': $('input[name=csrfmiddlewaretoken]').val()
};
$.ajax({
type: 'POST',
url: '/shop/tracker/',
data: formData,
encode: true
})
.done(function(data) {
console.log(data)
data = JSON.parse(data);
updates = data[0];
if (updates.length > 0 & updates != {}) {
for (i = 0; i < updates.length; i++) {
let text = updates[i]['text'];
let time = updates[i]['time'];
mystr = `<li class="list-group-item d-flex justify-content-between align-items-center">
${text}
<span class="badge badge-primary badge-pill">${time}</span>
</li>`
$('#items').append(mystr);
57
}
} else {
mystr = `<li class="list-group-item d-flex justify-content-between align-items-center">
Sorry, We are not able to fetch this order id and email. Make sure to type correct order Id
and email</li>`
$('#items').append(mystr);
}
// Fill in the order details
cart = JSON.parse(data[1]);
console.log(cart);
for (item in cart) {
let name = cart[item][1];
let qty = cart[item][0];
mystr = `<li class="list-group-item d-flex justify-content-between align-items-center">
${name}
<span class="badge badge-primary badge-pill">${qty}</span>
</li>`
$('#citems').append(mystr);
}
});
event.preventDefault();
});
</script>
{% endblock %}
58
contact.html
{% extends 'shop/basic.html' %}
<div class="form-group">
<label for="name">Phone</label>
<input type="tel" class="form-control" id="phone" name='phone' placeholder="Enter Your Phone
Number">
</div>
<div class="form-group">
<label for="desc">How May We Help You?</label>
<textarea class="form-control" id="desc" name='desc' rows="3"></textarea>
</div>
<button type="submit" class="btn btn-success">Submit</button>
</form>
59
</div>
{% endblock %}
{% block js %}
<script>
{% if thank %}
alert('Thanks for contacting us. We will get back to you soon!');
document.location = "/shop/contact";
{% endif %}
</script>
{% endblock %}
60
about.html
{% extends 'shop/basic.html' %}
<main role="main">
<!-- Main jumbotron for a primary marketing message or call to action -->
<div class="jumbotron">
<div class="container">
<h1 class="display-3">My Awesome Cart!</h1>
<p>My Awesome Cart Pvt Ltd. is an Indian electronic commerce company based in Bengaluru,
India. Founded by Sachin Bansal and Binny Bansal in 2007, the company initially focused on book
sales, before expanding into other product categories such as consumer electronics, fashion, and
lifestyle products.
The service competes primarily with Amazon' s Indian subsidiary, and the domestic rival
Snapdeal.[5][6] as of March 2017, Flipkart held a 39.5% market share of India's e-commerce
industry.[7] Flipkart is significantly dominant in the sale of apparel (a position that was bolstered by
its acquisitions of Myntra and Jabong.com), and was described as being "neck and neck" with
Amazon in the sale of electronics and mobile phones.[8] Flipkart also owns PhonePe, a mobile
payments service based on the Unified Payments Interface (UPI).
In August 2018, U.S.-based retail chain Walmart acquired a 77% controlling stake in Flipkart for
US$16 billion, valuing it at $22 billion.</p>
<p><a class="btn btn-primary btn-lg" href="#" role="button">Learn more »</a></p>
</div>
</div>
<div class="container">
<!-- Example row of columns -->
61
<div class="row">
<div class="col-md-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo,
tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada
magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-secondary" href="#" role="button">View details »</a></p>
</div>
<div class="col-md-4">
<h2>Heading</h2>
<p>Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo,
tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus. Etiam porta sem malesuada
magna mollis euismod. Donec sed odio dui. </p>
<p><a class="btn btn-secondary" href="#" role="button">View details »</a></p>
</div>
<div class="col-md-4">
<h2>Heading</h2>
<p>Donec sed odio dui. Cras justo odio, dapibus ac facilisis in, egestas eget quam. Vestibulum
id ligula porta felis euismod semper. Fusce dapibus, tellus ac cursus commodo, tortor mauris
condimentum nibh, ut fermentum massa justo sit amet risus.</p>
<p><a class="btn btn-secondary" href="#" role="button">View details »</a></p>
</div>
</div>
<hr>
</main>
{% endblock %}
62
views.py
from django.shortcuts import render
from .models import Product, Contact, Orders, OrderUpdate
from math import ceil
import json
from django.views.decorators.csrf import csrf_exempt
from PayTm import Checksum
# Create your views here.
from django.http import HttpResponse
MERCHANT_KEY = 'Your-Merchant-Key-Here'
def index(request):
allProds = []
catprods = Product.objects.values('category', 'id')
cats = {item['category'] for item in catprods}
for cat in cats:
prod = Product.objects.filter(category=cat)
n = len(prod)
nSlides = n // 4 + ceil((n / 4) - (n // 4))
allProds.append([prod, range(1, nSlides), nSlides])
params = {'allProds':allProds}
return render(request, 'shop/index.html', params)
def about(request):
return render(request, 'shop/about.html')
def contact(request):
thank = False
if request.method=="POST":
name = request.POST.get('name', '')
63
email = request.POST.get('email', '')
phone = request.POST.get('phone', '')
desc = request.POST.get('desc', '')
contact = Contact(name=name, email=email, phone=phone, desc=desc)
contact.save()
thank = True
return render(request, 'shop/contact.html', {'thank': thank})
def tracker(request):
if request.method=="POST":
orderId = request.POST.get('orderId', '')
email = request.POST.get('email', '')
try:
order = Orders.objects.filter(order_id=orderId, email=email)
if len(order)>0:
update = OrderUpdate.objects.filter(order_id=orderId)
updates = []
for item in update:
updates.append({'text': item.update_desc, 'time': item.timestamp})
response = json.dumps([updates, order[0].items_json], default=str)
return HttpResponse(response)
else:
return HttpResponse('{}')
except Exception as e:
return HttpResponse('{}')
def search(request):
return render(request, 'shop/search.html')
64
def productView(request, myid):
def checkout(request):
if request.method=="POST":
items_json = request.POST.get('itemsJson', '')
name = request.POST.get('name', '')
amount = request.POST.get('amount', '')
email = request.POST.get('email', '')
address = request.POST.get('address1', '') + " " + request.POST.get('address2', '')
city = request.POST.get('city', '')
state = request.POST.get('state', '')
zip_code = request.POST.get('zip_code', '')
phone = request.POST.get('phone', '')
order = Orders(items_json=items_json, name=name, email=email, address=address, city=city,
state=state, zip_code=zip_code, phone=phone, amount=amount)
order.save()
update = OrderUpdate(order_id=order.order_id, update_desc="The order has been placed")
update.save()
thank = True
id = order.order_id
# return render(request, 'shop/checkout.html', {'thank':thank, 'id': id})
# Request paytm to transfer the amount to your account after payment by user
param_dict = {
'MID': 'Your-Merchant-Id-Here',
65
'ORDER_ID': str(order.order_id),
'TXN_AMOUNT': str(amount),
'CUST_ID': email,
'INDUSTRY_TYPE_ID': 'Retail',
'WEBSITE': 'WEBSTAGING',
'CHANNEL_ID': 'WEB',
'CALLBACK_URL':'http://127.0.0.1:8000/shop/handlerequest/',
}
param_dict['CHECKSUMHASH'] = Checksum.generate_checksum(param_dict,
MERCHANT_KEY)
return render(request, 'shop/paytm.html', {'param_dict': param_dict})
@csrf_exempt
def handlerequest(request):
# paytm will send you post request here
form = request.POST
response_dict = {}
for i in form.keys():
response_dict[i] = form[i]
if i == 'CHECKSUMHASH':
checksum = form[i]
66
models.py
from django.db import models
class Contact(models.Model):
msg_id = models.AutoField(primary_key=True)
name = models.CharField(max_length=50)
email = models.CharField(max_length=70, default="")
phone = models.CharField(max_length=70, default="")
desc = models.CharField(max_length=500, default="")
class Orders(models.Model):
order_id = models.AutoField(primary_key=True)
items_json = models.CharField(max_length=5000)
67
amount = models.IntegerField( default=0)
name = models.CharField(max_length=90)
email = models.CharField(max_length=111)
address = models.CharField(max_length=111)
city = models.CharField(max_length=111)
state = models.CharField(max_length=111)
zip_code = models.CharField(max_length=111)
phone = models.CharField(max_length=111, default="")
class OrderUpdate(models.Model):
update_id = models.AutoField(primary_key=True)
order_id = models.IntegerField(default="")
update_desc = models.CharField(max_length=5000)
timestamp = models.DateField(auto_now_add=True)
68
urls.py
from django.urls import path
from . import views
urlpatterns = [
path("", views.index, name="ShopHome"),
path("about/", views.about, name="AboutUs"),
path("contact/", views.contact, name="ContactUs"),
path("tracker/", views.tracker, name="TrackingStatus"),
path("search/", views.search, name="Search"),
path("products/<int:myid>", views.productView, name="ProductView"),
path("checkout/", views.checkout, name="Checkout"),
path("handlerequest/", views.handlerequest, name="HandleRequest"),
manage.py
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mac.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if name == ' main ':
69
0001_initial.py
# Generated by Django 2.2.5 on 2019-10-10 01:36
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Product',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,
verbose_name='ID')),
('product_name', models.CharField(max_length=50)),
('desc', models.CharField(max_length=300)),
('pub_date', models.DateField()),
],
),
]
70
0003_contact.py
# Generated by Django 2.2.5 on 2019-10-28 13:01
class Migration(migrations.Migration):
dependencies = [
('shop', '0002_auto_20191010_0801'),
]
operations = [
migrations.CreateModel(
name='Contact',
fields=[
('msg_id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=50)),
('email', models.CharField(default='', max_length=70)),
('phone', models.CharField(default='', max_length=70)),
('desc', models.CharField(default='', max_length=900)),
],
),
]
71
delete_orders.py
class Migration(migrations.Migration):
dependencies = [
('shop', '0004_auto_20191028_1920'),
]
operations = [
migrations.DeleteModel(
name='Orders',
),
]
72
orders.py
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('shop', '0005_delete_orders'),
]
operations = [
migrations.CreateModel(
name='Orders',
fields=[
('order_id', models.AutoField(primary_key=True, serialize=False)),
('items_json', models.CharField(max_length=5000)),
('name', models.CharField(max_length=90)),
('email', models.CharField(max_length=111)),
('address', models.CharField(max_length=111)),
('city', models.CharField(max_length=111)),
('state', models.CharField(max_length=111)),
('zip_code', models.CharField(max_length=111)),
('phone', models.CharField(default='', max_length=111)),
],
),
]
73
Order_update.py
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('shop', '0006_orders'),
]
operations = [
migrations.CreateModel(
name='OrderUpdate',
fields=[
('update_id', models.AutoField(primary_key=True, serialize=False)),
('order_id', models.IntegerField(default='')),
('update_desc', models.CharField(max_length=5000)),
('timestamp', models.DateField(auto_now_add=True)),
],
),
]
74
order_amount.py
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('shop', '0007_orderupdate'),
]
operations = [
migrations.AddField(
model_name='orders',
name='amount',
field=models.IntegerField(default=0),
),
]
75
contact.py
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('shop', '0002_auto_20191010_0801'),
]
operations = [
migrations.CreateModel(
name='Contact',
fields=[
('msg_id', models.AutoField(primary_key=True, serialize=False)),
('name', models.CharField(max_length=50)),
('email', models.CharField(default='', max_length=70)),
('phone', models.CharField(default='', max_length=70)),
('desc', models.CharField(default='', max_length=900)),
],
),
]
76
TEST CASE DESIGN
77
Test Case I
Let us take a case when the when admin is login dajngo server is started and
working succesfully.
Test Case II
If Admin want to view details of any user, then all details of user is available
and can be viewed by admin correctly in this web application we found it
correct.
78
SECURITY MEASURE
79
The security system is needed for recognizing and protecting against
unauthorized and inappropriate access to the database by the people and the
software programs that process against the database. Providing software security
involves hardware, software and users are often achieved through the use of
verification techniques. These verification techniques are used to authenticate
users and terminals to detect unauthorized access attempt to prohibit
unauthorized data manipulation and to support multilevel security that trust the
system to segregate the users and data.
Authentication
There are two ways of restricting access to documents: either by the hostname of
the browser being used, or by asking for a username and password. The former
can be used to, for example, restrict documents to use within a company.
However if the people who are allowed to access the documents are widely
dispersed, or the server administrator needs to be able to control access on an
individual basis, it is possible to require a username and password before being
allowed access to a document. This is called user authentication.
Authorization
Authorization is the function of the policy definition phase which precedes the
policy enforcement phase where access requests are granted or rejected based on
the previously defined authorizations.
80
BIBLOGRAPHY
81
Web site
1. www.google.com
2. www.w3schools.com
3. www.wikipedia.com
82