0% found this document useful (0 votes)
65 views

Nischitha

The document describes an online grocery shop management system project submitted by two students. The project aims to develop a web application that allows customers to order grocery products online and view their orders. It contains customer-facing and admin-facing interfaces. The application is intended to make buying groceries easy and convenient without needing to visit a physical store.

Uploaded by

Sanjana S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
65 views

Nischitha

The document describes an online grocery shop management system project submitted by two students. The project aims to develop a web application that allows customers to order grocery products online and view their orders. It contains customer-facing and admin-facing interfaces. The application is intended to make buying groceries easy and convenient without needing to visit a physical store.

Uploaded by

Sanjana S
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 93

VISVESVARAYA TECHNOLOGICAL UNIVERSITY

JNANASANGAMA, BELGAVI-590018

DATABASE MANAGEMENT SYSTEM MINI PROJECT


(18CSL58)
ON
“ONLINE GROCERY SHOP MANAGEMENT SYSTEM”
Submitted in partial fulfillment of the requirements for the 5th Semester

INFORMATION SCIENCE AND ENGINEERING

Submitted by
MEGHANA SREENIVASA RAO (1BI19IS031)
NISCHITHA NAGARURU (1BI19IS037)

Under the guidance of

Mrs. Prameela R Dr. Hema Jagadish


Assistant Professor Associate Professor
Dept of ISE Dept of ISE
BIT, Bangalore-04 BIT, Bangalore-04

2021-2022
DEPARTMENT OF INFORMATION SCIENCE AND ENGINEERING
BANGALORE INSTITUTE OF TECHNOLOGY

K. R. Road, V. V. Pura, Bengaluru-560004


BANGALORE INSTITUTE OF TECHNOLOGY
K.R. Road, V.V. Puram, Bengaluru -560004
DEPARTMENT OF INFORMATION SCIENCE AND ENGINEERING

CERTIFICATE

This is to certify that the implementation of DBMS MINI PROJECT (18CSL58) entitled
“ONLINE GROCERY SHOP MANAGEMENT SYSTEM” has been successfully completed
by NISCHITHA NAGARURU (1BI19IS037) of V semester B.E. for the partial fulfilment of
the requirements for the Bachelor's degree in Information Science & Engineering of the
Visvesvaraya Technological University during the academic year 2021-2022.

Lab In charge: Head of Department:

Mrs. Prameela R Dr. Roopa H


Assistant Professor Associate Professor and Head
Dept of ISE, BIT Dept of ISE, BIT

Name of Examiners: Signature with date

1.

2.
DECLARATION

I, NISCHITHA NAGARURU bearing USN 1BI19IS037 student of Fifth Semester


Bachelor of Engineering in Information Science Engineering, Department of
Information Science Engineering, Bangalore Institute of Technology, Bangalore
declare that the project work has been carried out by me and submitted in partial
fulfillment of the requirements for the award of the degree of Bachelor of
Engineering in Information Science Engineering of Visvesvaraya Technological
University, Belagavi during the year 2021-2022. The matter embodied at this report
has not been submitted to any university or institute for the award of any other degree.

Place: Bangalore Name: Nischitha Nagaruru


Date: USN: 1BI19IS037

i
ACKNOWLEDGEMENT

The satisfaction and euphoria that accompany the successful completion of any
task would be incomplete without the mention of the people who made it
possible. So, with gratitude, I acknowledge all those whose guidance and
encouragement crowned my effort with success.

It’s immense pleasure in thanking principal Dr. Ashwath M.U, BIT, Bangalore,
for providing an opportunity to present this project as a part of my curriculum in
the partial fulfilment of the degree.

I express sincere gratitude for Dr. Roopa H, Head of the Department,


Information Science and Engineering for her co-operation and encouragement at
all moments of my approach.

It is pleasant duty to place on record my deepest sense of gratitude to my guide


Mrs. Prameela R, Asst. Professor, for the constant encouragement, and

Dr Hema Jagadish, Associate Professor for valuable help and assistance in


every possible way.

I would like to thank all teaching and non-teaching staff of ISE Department
for providing their valuable guidance and for being there at all the stages of my
world.

NISCHITHA NAGARURU (1BI19IS037)

ii
ABSTRACT

This project aims at developing an online grocery shop management system for customers
with the goal of making buying groceries in an easy and simple manner without having
to step out of house. The project contains the customer side and the admin side. The
customer can order products online and see his orders. Thus, it’s a digital way of
management of the product order and also payment system. An online Grocery Store
permits a customer to submit online orders for items and/or services from a store that
serves both walk-in customers and online customers. The online Store system presents an
online display of all the items they want to sell. This web-based application helps
customers to choose their daily needs and add products to their shopping cart. Customers
provides their complete detail of address and contact and they get their chosen products
in their home.

This Web application saves lots of time of customers. The appeal of e-grocery services is
also influenced by many consumers finding grocery shopping a stressful activity. In
addition to time-starved and stressed consumers, individuals with disabilities related to
age and health are another prominent market for e-grocery service.

iii
TABLE OF CONTENTS

DECLARATION I

ACKNOWLEDGMENT II

ABSTRACT III

TABLE OF CONTENTS IV

LIST OF FIGURES VI

LIST OF TABLES VII

SL NO. CHAPTERS PAGE NO.

1 INTRODUCTION 1-4

1.1 What is the need of DBMS? 1

1.2 Design and Modeling 2

1.3 Problem Statement 3

1.4 Objectives 4

2 SOFTWARE AND HARDWARE REQUIREMENTS 5

2.1 Software Requirements 5

2.2 Hardware Requirements 5

3 DESIGN 6-17

3.1 ER Analysis 6

3.1.1 Entity Sets 6

3.1.2 Relationship Sets 10

3.2 Entity Relationship Diagram 11

3.2.1 ER Diagram with relationships and cardinality ratio 11

3.3 Schema Diagram 13

iv
3.4 Tables and Functional Dependencies 14

3.5 Normalization 16

3.5.1 First Normal form 16

3.5.2 Second Normal form 16

3.5.3 Third Normal form 17

3.5.4 Other Normalization forms 17

4 IMPLEMENTATION 18-72

4.1 Basic Steps 18

4.2 Technologies and Framework 18

4.3 Front-End Code 19

4.4 Back-End Code 43

4.4.1 Table Creation 66

4.4.2 Triggers 71

4.4.3 Insert into Statements 72

5 SOFTWARE TESTING 73-75

5.1 Testing Objectives 73

5.2 Testing Principles 73

5.3 Validation Testing 73

5.4 Unit Testing 74

5.4 Regression Testing 75

6 SNAPSHOTS 76-82

7 CONCLUSION AND FUTURE ENHANCEMENTS 83

v
LIST OF FIGURES

FIGURE NO. TITLE PAGE NO.


1.1 Simplified database environment 2
3.1 ER Diagram Notations 11
3.2 ER Diagram of Grocery 12
Management System
3.3 Schema Diagram of Grocery 13
Management System
5.7.1 Login page with error 75
5.7.2 Username already exists 75
6.1 Home Page 76
6.2 Items Page 76
6.3 Login Page 76
6.4 Signup Form for a new user 77
6.5 Item Description after Selecting 77
an item
6.6 Cart Items 78
6.7 Users’ orders 78
6.8 Admin Login Page 79
6.9 Admin Page 79
6.10 Cart items view for admin 79
6.11 Admin can add items to cart 80
6.12 Admin page which shows items 80
available on catalog
6.13 Admin adding item to Catalog 81
6.14 Admin viewing logged in users 81
6.15 Admin has option to add users 81
6.16 Admin can view reviews left by 82
customers

vi
LIST OF TABLES

TABLE NO. TABLE NAME PAGE NO.


3.1 auth_group attribues 7
3.2 auth_group permission attributes 7
3.3 auth_permission attributes 7
3.4 auth_user attributes 7
3.5 auth_user_permissions attributes 8
3.6 admin_log attributes 8
3.7 content_type attributes 8
3.8 migrations attributes 8
3.9 session attributes 8
3.10 main_cart_items attributes 9
3.11 main_items 9
5.1 Test Cases 74

vii
GROCERY MANAGEMENT SYSTEM 1BI19IS037

CHAPTER 1
INTRODUCTION
Database is a collection of data and Management System is a set of programs to store and
retrieve those data. Based on this one can define DBMS as a collection of inter-related data
and set of programs to store & access those data in an easy and effective manner.

1.1 What is the need of DBMS?


Database systems are basically developed for large amount of data. When dealing with huge
amount of data, there are two things that require optimization: Storage of data and retrieval
of data.

Storage: According to the principles of database systems, the data is stored in such a way
that it acquires lot less space as the redundant data (duplicate data) has been removed before
storage. Let’s take a layman example to understand this. In a banking system, suppose a
customer is having two accounts, one is saving account and another is salary account. Let’s
say bank stores saving account data at one place and salary account data at another place, in
that case if the customer information such as customer name, address etc. are stored at both
places then this is just a wastage of storage (redundancy/ duplication of data), to organize
the data in a better way the information should be stored at one place and both the accounts
should be linked to that information somehow. The same thing we achieve in DBMS.

Fast Retrieval of data: Along with storing the data in an optimized and systematic manner,
it is also important to retrieve the data quickly when needed. Database systems ensure that
the data is retrieved as quickly as possible.

The choice of a database product is often influenced by factors such as:


➢ the computing platform (i.e., hardware, operating system)
➢ the volume of data to be managed.
➢ the number of transactions required per second.
➢ existing applications or interfaces that an organization may have support for
heterogeneous and/or distributed computing.
➢ Cost
➢ vendor support

Dept of ISE, BIT 2021-2022 Page |1


GROCERY MANAGEMENT SYSTEM 1BI19IS037

1.2 Design and Modeling


The first task of a database designer is to produce a conceptual data model that reflects the
structure of the information to be held in the database. A common approach to this is to
develop an entity-relationship model, often with the aid of drawing tools. Another popular
approach is the Unified Modeling Language. A successful data model will accurately
reflect the possible state of the external world being modeled: for example, if people can
have more than one phone number, it will allow this information to be captured.

Figure 1.1: Simplified database environment

Dept of ISE, BIT 2021-2022 Page |2


GROCERY MANAGEMENT SYSTEM 1BI19IS037

1.3 Problem Statement


This project aims at developing an online grocery shop management system for customers
with the goal of making buying groceries in an easy and simple manner without having to
step out of house. The project contains only the customer side. The customer can order
products online and see his orders. Thus, it’s a digital way of management of the product
order and also payment system.
A grocery store is a retail store that primarily sells food. Grocery stores offer non-
perishable food that is packaged in cans, bottles and boxes with some also having fresh
produce, butchers, delis andbakeries.
But there are few problems faced by in person grocery stores-
• As pollution is increasing and Covid-19 virus is spreading, buying food on the
roadside isnot advisable.
• Due to the busy working schedule, people are unable to find time for household
works likebuying grocery.
• In a supermarket once we buy groceries and if incase, we want to cancel an item,
the moneyfor that respective item is not returned.

In grocery shop management system, we can overcome all these drawbacks by creating a
contactless shopping experience, help people order groceries despite their busy schedule
from any part of the city or any place with the help of electronic gadgets like laptops and
phones.
There is also an admin side to the grocery shop included, where the admin will be able to
login with the specified credentials and change contents and manage the web page which
handle the grocery management system.

Dept of ISE, BIT 2021-2022 Page |3


GROCERY MANAGEMENT SYSTEM 1BI19IS037

1.4 Objectives
The aim of this project is to create a simple, efficient grocery management system which
makesonline grocery shopping easy for the consumers and includes all the functionality that is
required by them. Online grocery shopping is a dream come true for today’s generation.
Specially, for all those women/men who always wanted to do grocery shopping on a budget.
The landscape of grocery fulfilment has changed greatly, and there are certain advantages and
disadvantages to online grocery shopping.
Shopping online alleviates the need to walk up and down store aisles. And you can log in any
time even at 2 am and still have the advantage of a fully stocked store. Plus, going the
delivery route saves you a trip to the store, which not only saves time, but gas money as well.
In fact, studies show grocery delivery services slash carbon dioxide emissions in half
compared to individual household trips. Search engines on websites make it much easier to
find items quickly; typing in the name or brand of a product will show you all relevant
products making itmuch easier to find exactly what you need.

The main purpose of online grocery is to create and develop new models, and to optimize the
relationships between a grocery company and its customers. Changing from shopping at the
supermarket to online grocery shopping can improve an online grocery retailer’s productivity
by shortening supply chains, reducing overhead costs, and enabling “just in time” service.

Dept of ISE, BIT 2021-2022 Page |4


GROCERY MANAGEMENT SYSTEM 1BI19IS037

CHAPTER 2

SOFTWARE AND HARDWARE REQUIREMENT


The program works on Desktop PC and is executed using a Python Django which interacts
with a SQLite database running on localhost.

2.1 Software Requirements


• Operating System: Windows 7/8/10
• Back End: Python Django
• Front End: HTML, CSS
• Application required: Visual Studio and the database used is SQLite.

2.2 Hardware Requirements

• Hard disk – 15 GB or Above


• RAM – Minimum 1 GB or Above
• Processor- Intel core i4/i5/i7

Dept of ISE, BIT 2021-2022 Page |5


GROCERY MANAGEMENT SYSTEM 1BI19IS037

CHAPTER 3
DESIGN
In the below section, a brief overview of how the project is designed is given, including the Entity

Relation diagram and Schema diagram which describes the various attributes used in the design

and their types.

3.1 ER Analysis: Identifying Entity Sets and Relationship Sets

Entity Relationship Model (ER Modelling) is a graphical approach to database design. It is a


high-level data model that defines data elements and their relationship for a specified software
system. An ER model is used to represent real-world objects.

3.1.1 Entities and Attributes

An Entity is a thing or object in real world that is distinguishable from surrounding


environment. An Entity is an object of Entity Type and set of all entities is called as Entity
set. Attributes are the properties which define the entity type.
The section of the document explains the entities used in the project, their attributes and how
they will work together. Basically, this is intended to make the design easier and understand-
able foreveryone.

ENTITIES
1. auth_group
2. auth_group_permissions
3. auth_permission
4. auth_user
5. auth_user_permissions
6. admin_log
7. content_type
8. migrations
9. session
10. main_cart_items
11. main_type

Dept of ISE, BIT 2021-2022 Page |6


GROCERY MANAGEMENT SYSTEM 1BI19IS037

1. auth_group: Attributes of this entity are id and name

Table 3.1
ATTRIBUTE DATATYPE DESCRIPTION
Id INTEGER Primary key
Name VARCHAR(150)

2. auth_group_permissions: Attributes of this entity are id, group_id and permission_id

Table 3.2
ATTRIBUTE DATATYPE DESCRIPTION
Id INTEGER Primary key
group_id INTEGER Primary key
permission_id INTEGER Primary key

3. auth_permission: Attributes of this entity ae id, content_type_id, codename and name.

Table 3.3
ATTRIBUTE DATATYPE DESCRIPTION
Id INTEGER Foreign key
content_type_id INTEGER Non key attribute
Codename VARCHAR(100) Primary key
Name VARCHAR(255) Non key attribute

4. auth_user: Attributes of this entity are id, password, last_login, is_superuser, username, first_name, email,
is_staff, is_active, date_joined, last_name
Table 3.4

ATTRIBUTE DATATYPE DESCRIPTION


Id INTEGER Foreign key
Password VARCHAR(128) Foreign key
last_login DATETIME Non key attribute
Is_superuser BOOL Non key attribute
Username VARCHAR(150) Non key attribute
first_name VARCHAR(30) Non key attribute
Email VARCHAR(254) Primary key
is_staff BOOL Non key attribute
is_active BOOL Non key attribute
date_joined DATETIME Non key attribute
last_name VARCHAR(150) Non key attribute

Dept of ISE, BIT 2021-2022 Page |7


GROCERY MANAGEMENT SYSTEM 1BI19IS037

4. auth_user_permissions: Attributes of this entity are id, user_id and permission_id

Table 3.5

ATTRIBUTE DATATYPE DESCRIPTION


Id INTEGER Foreign key
user_id INTEGER Non key attribute
permission_id INTEGER Non key attribute

5. admin_log: Attributes of this entity are id, action_time, object_repr, change_message, content_type_id,
user_id, action_flag
Table 3.6

ATTRIBUTE DATATYPE DESCRIPTION


Id INTEGER Primary key
action_time DATETIME Non key attribute
object_id TEXT Non key attribute
object_repr VARCHAR(200) Non key attribute
change_message TEXT Non key attribute

6. content_type: Attributes of this entity are id, app_label and model.

Table 3.7

ATTRIBUTE DATATYPE DESCRIPTION


Id INTEGER Foreign key
app_label VARCHAR(100) Non key attribute
Model VARCHAR(100) Non key attribute

7. migrations: Attributes of this entity are id, app, name, applied.

Table 3.8

ATTRIBUTE DATATYPE DESCRIPTION


Id INTEGER Foreign key
App VARCHAR(255) Non key attribute
Name VARCHAR(255) Non key attribute
Applied DATETIME Non key attribute

8. session: Attributes of this entity are session_key, session_data and expire_data.


Table 3.9

ATTRIBUTE DATATYPE DESCRIPTION


session_key VARCHAR(40) Primary key
session_data TEXT Non key attribute
expire_date DATETIME Non key attribute

Dept of ISE, BIT 2021-2022 Page |8


GROCERY MANAGEMENT SYSTEM 1BI19IS037

9. main_cart_items: Attributes of this entity are id, ordered, quantity, item_id, user_id, ordered_date, status,
delivery_date
Table 3.10
ATTRIBUTE DATATYPE DESCRIPTION
Id INTEGER Foreign key
Ordered BOOL Non key attribute
Quantity INTEGER Non key attribute
item_id INTEGER Non key attribute
user_id INTEGER Foreign key
ordered_date DATE Non key attribute
Status VARCHAR(20) Non key attribute
delivery_date DATE Non key attribute

10. main_items: Attributes of this entity are id, title, description, price, piece, pieces, instructions, image,
labels,label_color, slug, created_by_id
Table 3.11
ATTRIBUTE DATATYPE DESCRIPTION
Id INTEGER Foreign key
Title VARCHAR(150) Non key attribute
Description VARCHAR(250) Non key attribute
Price REAL Non key attribute
Pieces INTEGER Non key attribute
Instructions VARCHAR(250) Non key attribute
Images VARCHAR(100) Non key attribute
Labels VARCHAR(25) Non key attribute
label_color VARCHAR(10) Non key attribute
Slug VARCHAR(50) Non key attribute
created_by_id INTEGER Non key attribute

Dept of ISE, BIT 2021-2022 Page |9


GROCERY MANAGEMENT SYSTEM 1BI19IS037

3.1.2 Relationship Sets

A relationship type represents the association between entity types. A set of relationships
of same type is known as relationship set.
The following are the relationships between the various entities used in the project.

• Has permissions: to check the permissions various groups have in the management
system
• Authenticates: for one group, usually the admin, to grant permission to another group
• Verifies: for one group, usually the admin, to verify the credentials and to give access to
something
• Accesses: usually, the admin has access to the main cart items, to add, delete, update
information on various items
• Gets added: the admin gets to add items to be displayed in the home page of the
management system
• Adds: here, the authenticated user, usually a supplier, add details and items to be
displayed and accessed on the home page

Dept of ISE, BIT 2021-2022 P a g e | 10


GROCERY MANAGEMENT SYSTEM 1BI19IS037

3.2 Entity Relationship Diagram


An entity relationship model, also called an entity-relationship (ER) diagram, is a graphical
representation of entities and their relationships to each other, typically used in computing in
regard to the organization of data within databases or information systems

3.2.1 ER Diagram with relationships and cardinality ratio

The cardinality or fundamental principle of one data aspect with respect to another is a critical
feature. The relationship of one to the other must be precise and exact between each other in
order to explain how each aspect links together. In simple words Cardinality is a way to define
the relationship between two entities.
The following are the notations of the ER diagram:

Fig 3.1 ER Diagram Notations

Dept of ISE, BIT 2021-2022 P a g e | 11


GROCERY MANAGEMENT SYSTEM 1BI19IS037

The ER diagram below shows the relationship between the many tables that exist in the
database for the functioning of Grocery Shop Management System.

Fig 3.2: ER Diagram of Grocery Shop Management System

Dept of ISE, BIT 2021-2022 P a g e | 12


GROCERY MANAGEMENT SYSTEM 1BI19IS037

3.3 Schema Diagram

In any data model it is important to distinguish between the description of the database and the
database itself. The description of a database is called the database schema, which is specified
during database design and is not expected to change frequently. A displayed schema is called
a schema diagram. A schema diagram displays only some aspects of a schema, such as the
names of record types and data items, and some types of constraints.

Fig 3.3: Schema Diagram for Grocery Shop Management System

Dept of ISE, BIT 2021-2022 P a g e | 13


GROCERY MANAGEMENT SYSTEM 1BI19IS037

3.4 Tables and Functional Dependencies

Functional Dependency (FD) is a constraint that determines the relation of one attribute to
another attribute in a Database Management System (DBMS). Functional Dependency helps
to maintain the quality of data in the database. It plays a vital role to find the difference between
good and bad database design.

A functional dependency is denoted by an arrow "→". The functional dependency of X on Y


is represented by X → Y.

1. auth_group_permissions ( id, group_id, permission_id)


FD={ id → group_id }

2. auth_group ( id, name )


FD= { id → name }
id is a foreign key constraint

3. auth_permission ( id, content_type_id, codename, name )


FD= { id → content_type_id }
id is a foreign key constraint

4. auth_user ( id, password, last_login, is_superuser, username, first_name, email, is_staff,


is_active, date_joined, last_name)
FD= { is_staff → date_joined, email, last_name
id → username, password, last_login }

5. auth_user_permissions ( id, user_id, permission_id )


FD= { id → user_id }
id is a foreign key constraint

Dept of ISE, BIT 2021-2022 P a g e | 14


GROCERY MANAGEMENT SYSTEM 1BI19IS037

6. admin_log ( id, action_time, object_repr, change_message, content_type_id, user_id,


action_flag )
FD= { id → user_id, content_type_id }
content_type_id is a foreign key constraint

7. content_type ( id, app_label, model )FD


= { id → model }

8. migrations ( id, app, name, applied)


FD= { id → name, applied }
id is a foreign key constraint

9. session ( session_key, session_data, expire_data ) FD =


{ session_key → session_data, expire_data }

10. main_item ( id, title, description, price, piece, pieces, instructions, image, labels, label_color,
slug, created_by_id)
FD = { id → title, labels, color, description }
created_by_id is a foreign key constraint

11. main_cartitems ( id, ordered, quantity, item_id, user_id, ordered_date, status, delivery_date)
FD= { id → item_id, quantity, ordered }
id is a foreign key constraint

Dept of ISE, BIT 2021-2022 P a g e | 15


GROCERY MANAGEMENT SYSTEM 1BI19IS037

3.5 Normalization

Normalization is a process of organizing the data in database to avoid data redundancy,


insertion anomaly, update anomaly & deletion anomaly.
Database Normalization is a technique of organizing the data in the database. Normalization is
a systematic approach of decomposing tables to eliminate data redundancy(repetition) and
undesirable characteristics like Insertion, Update and Deletion Anomalies. It is a multi-step
process that puts data into tabular form, removing duplicated data from the relation tables.
Normalization is used for mainly two purposes,
a. Eliminating redundant(useless) data.
b. Ensuring data dependencies make sense i.e data is logically stored.

3.4.1 First Normal form

For a table to be in the First Normal Form, it should follow the following 4 rules:
1. It should only have single(atomic) valued attributes/columns.
2. Values stored in a column should be of the same domain
3. All the columns in a table should have unique names.
4. And the order in which data is stored, does not matter.

All the tables have achieved 1NF by converting multi-valued attribute Permissions into
separate entities like user_permissions or user group permissions.

3.4.2 Second Normal form

For a table to be in the Second Normal Form,


1. It should be in the First Normal form.
2. And, it should not have Partial Dependency.

Dept of ISE, BIT 2021-2022 P a g e | 16


GROCERY MANAGEMENT SYSTEM 1BI19IS037

All the tables which are part of this project are in 2NF as they have at most one
primarykey, so no partial dependency.

3.5.3 Third Normal form

A table is said to be in the Third Normal Form when,


1. It is in the Second Normal form.
2. And, it doesn't have Transitive Dependency.
All the used tables satisfy both these conditions and hence are in 3NF.

3.5.4 Other Normalization Forms

BCNF (Boyce Codd Normal Form) is the advanced version of 3NF. A table is in
BCNFif every functional dependency X->Y, X is the super key of the table. For
BCNF, the table should be in 3NF, and for every FD. LHS is super key.
Fourth normal form (4NF) is a level of database normalization where there are no non-
trivial multivalued dependencies other than a candidate key. It builds on the first three
normal forms (1NF, 2NF and 3NF) and the Boyce-Codd Normal Form (BCNF).
A relation is in 5NF if it is in 4NF and not contains any join dependency and
joiningshould be lossless.

All the tables we have used, do not contain any multivalued dependencies or
joindependencies. Thus, no case of generating additional invalid tuples arise.

Dept of ISE, BIT 2021-2022 P a g e | 17


GROCERY MANAGEMENT SYSTEM 1BI19IS037

CHAPTER 4
IMPLEMENTATION
This section focuses on the implementation of the online grocery shopping management system.
The steps and the technologies used are listed below.

4.1 Basic Steps in Implementation:

• Every user will login using existing credentials, or sign up to create an account by
entering a valid phone number and email and set a password.
• The admin will be able to add items or delete items on the main catalog and also by able
tocheck the reviews on the admin page.
• Be able to view the list of all orders and reviews on the admin page.
• Customers will be able to add items to the cart, be able to checkout and view the invoice.

4.2 Technologies and Frameworks


HTML

Hypertext Markup Language is the standard markup language for documents designed to
be displayed in a web browser. It can be assisted by technologies such as Cascading Style
Sheets and scripting languages such as JavaScript.

CSS

Cascading Style Sheets is a style sheet language used for describing the presentation of
a document written in a markup language like HTML. CSS is a cornerstone technology
of the World Wide Web, alongside HTML and JavaScript. Functional Modules.

Django
Django is a high-level Python Web framework that encourages rapid development and clean
pragmatic design. A Web framework is a set of components that provide a standard way to
develop websites fast and easily. Django’s primary goal is to ease the creation of complex
database-driven websites. Some well-known sites that use Django include PBS, Instagram,
Disqus, Washington Times, Bitbucket and Mozilla.

Dept of ISE, BIT 2021-2022 P a g e | 18


GROCERY MANAGEMENT SYSTEM 1BI19IS037

4.3 Frontend Code


Admin_dashboard
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<title>Admin Dashboard</title>
<link
href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,70
0,700i,800,800i,900,900i" rel="stylesheet">
<link href="css/sb-admin-2.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="{% static 'main/sb-admin-2.min.css' %}">
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
integrity="sha384-
Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
<script
src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.9.3/Chart.bundle.min.js"></script>
</head>
<body id="page-top">
<div id="wrapper">
<ul class="navbar-nav bg-gradient-primary sidebar sidebar-dark accordion"
id="accordionSidebar">
<a class="sidebar-brand d-flex align-items-center justify-content-center" href="{% url
'main:admin_dashboard' %}">
<div class="sidebar-brand-text mx-3">Welcome</div>

Dept of ISE, BIT 2021-2022 P a g e | 19


GROCERY MANAGEMENT SYSTEM 1BI19IS037

<hr class="sidebar-divider">
<li class="nav-item">
<a class="nav-link">
<li class="nav-item">
<a class="nav-link" href="{% url 'main:home' %}">
<i class="fa fa-home"></i>
<span>Home</span></a>
</li>
<li class="nav-item ml-3 mb-3">
<form class="logout-link" action="{% url 'accounts:logout' %}" method="post">
{% csrf_token %}
<button type="submit" class="mr-2">Logout</button>
</form>
</li>
<hr class="sidebar-divider d-none d-md-block">
</ul>
<div id="content-wrapper" class="d-flex flex-column">
<div id="content">
<nav class="navbar navbar-expand navbar-light bg-white topbar mb-4 static-top shadow">
<h2 class="text-center">AdminPage</h3>
</nav>
<div class="container-fluid">
<div class="row">
<div class="col-xl-4 col-md-4 mb-4">
<div class="card border-left-success shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-success text-uppercase mb-1">Total
Earnings</div>
<div class="h5 mb-0 font-weight-bold text-gray-800">₹ {{ income }}</div>
</div>
<div class="col-auto">

Dept of ISE, BIT 2021-2022 P a g e | 20


GROCERY MANAGEMENT SYSTEM 1BI19IS037

<i class="fas fa-dollar-sign fa-2x text-gray-300"></i>


</div>
</div>
</div>

</div>
<div class="col-xl-4 col-md-4 mb-4">
<div class="card border-left-primary shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-primary text-uppercase mb-1">Total Delivered</div>
<div class="h5 mb-0 font-weight-bold text-gray-800">{{ completed_total }}</div>
</div>
<div class="col-auto">
<i class="fas fa-comments fa-2x text-gray-300"></i>
</div>
</div>
</div>
</div>
</div>
<div class="col-xl-4 col-md-4 mb-4">
<div class="card border-left-danger shadow h-100 py-2">
<div class="card-body">
<div class="row no-gutters align-items-center">
<div class="col mr-2">
<div class="text-xs font-weight-bold text-danger text-uppercase mb-1">Pending Orders</div>
<div class="h5 mb-0 font-weight-bold text-gray-800">{{ pending_total }}</div>
</div>
<div class="col-auto">
<i class="fas fa-comments fa-2x text-gray-300"></i>
</div>
</div>

Dept of ISE, BIT 2021-2022 P a g e | 21


GROCERY MANAGEMENT SYSTEM 1BI19IS037

<div class="row">
<div class="col-xl-6 col-lg-6">
<div class="card shadow mb-4">
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">Categories Bar Chart</h6>
</div>
<div class="card-body">
<div class="chart-pie pt-4 pb-2">
<canvas id="myChart"></canvas>
</div>
</div>
</div>
</div>
<div class="col-xl-6 col-lg-6">
<div class="card shadow mb-4">
<div class="card-header py-3 d-flex flex-row align-items-center justify-content-between">
<h6 class="m-0 font-weight-bold text-primary">Categories Doughnut Chart</h6>
</div>
<div class="card-body">
<canvas id="myAreaChart"></canvas>
</div>
</div>
</div>
</div>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-
KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"

Dept of ISE, BIT 2021-2022 P a g e | 22


GROCERY MANAGEMENT SYSTEM 1BI19IS037

integrity="sha384-
ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-
JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>

<script>
let myChart = document.getElementById('myChart').getContext('2d');
let myAreaChart = document.getElementById('myAreaChart').getContext('2d');
let count1 = {{ count1 }};
let count2 = {{ count2 }};
let count3 = {{ count3 }};
let orderChart1 = new Chart(myChart, {
type:'bar',
data:{
labels:['Spicy Avocado', 'Tempura', 'Maki'],
datasets:[{
label:'Items',
data:[
count1,
count2,
count3,
],
backgroundColor:[
'#007BFF',
'#28A745',
'#FFC107',
],
}]
},
options:{

Dept of ISE, BIT 2021-2022 P a g e | 23


GROCERY MANAGEMENT SYSTEM 1BI19IS037

layout:{
padding:{
left:0,
right:0,
bottom:40,
top:0
}
},

});
let orderChart2 = new Chart(myAreaChart, {
type:'doughnut',
data:{
labels:['Spicy Avocado', 'Tempura', 'Maki'],
datasets:[{
label:'Items',
data:[
count1,
count2,
count3,
],
backgroundColor:[
'#007BFF',
'#28A745',
'#FFC107',
],
borderWidth:1,
borderColor:'#777',
hoverBorderWidth:1,
hoverBorderColor:'#000'
}]
},
options:{

Dept of ISE, BIT 2021-2022 P a g e | 24


GROCERY MANAGEMENT SYSTEM 1BI19IS037

layout:{
padding:{
left:0,
right:0,
bottom:40,
top:0
}
},
});
</script>
</body>
</html>
Admin_view
{% extends "main/layout2.html" %}
{% block content %}
<div class="cart">
<div class="container">
<div class="row">
<div class="col-sm-12">
<h3 class="text-center">Completed Orders</h3>
{% if cart_items %}
<div class="table-responsive">
<table class="table table-dark">
<thead>
<tr>
<td scope="col">Order No.</td>
<th scope="col">User</th>
<th scope="col">User Email</th>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">Specification</th>
<th scope="col">Price</th>
<th scope="col">Total Pieces</th>

Dept of ISE, BIT 2021-2022 P a g e | 25


GROCERY MANAGEMENT SYSTEM 1BI19IS037

<th scope="col">Status</th>
<th scope="col">Delivery Date</th>
</tr>
</thead>
<tbody>
{% for cart in cart_items %}
<tr>
<td>{{ cart.id }}</td>
<td>{{ cart.user.username }}</td>
<td>{{ cart.user.email}}</td>
<td>{{ cart.item.title }} <span class="badge badge-{{ cart.item.label_colour }}">{{
cart.item.labels }}</span></td>
<td>{{ cart.item.description }}</td>
<td>{{ cart.item.instructions }}</td>
<td>{{ cart.item.price }}</td>

<td>{{ cart.item.pieces }} pieces</td>


<td>{{ cart.status }}</td>
<td>{{ cart.delivery_date }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<h4 class="text-center">Sorry, you have not ordered any item yet!!!</h4>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock content %}

Dept of ISE, BIT 2021-2022 P a g e | 26


GROCERY MANAGEMENT SYSTEM 1BI19IS037

Cart.html
{% extends "main/layout.html" %}
{% block content %}
<div class="cart">
<div class="container">
<div class="row">
<div class="col-sm-9 mt-5">
<h3 class="text-center">Your Cart</h3>
{% if cart_items %}
<div class="table-responsive">
<table class="table table-light">
<thead>
<tr>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">Price</th>
<th scope="col">Total Pieces</th>
</tr>
</thead>
<tbody>
{% for cart in cart_items %}
<tr>
<td>{{ cart.item.title }} <span class="badge badge-{{ cart.item.label_colour }}">{{
cart.item.labels }}</span></td>
<td>{{ cart.item.description }}</td>
<td>{{ cart.item.instructions }}</td>
<td>{{ cart.item.price }}</td>
<td>{{ cart.item.pieces }} pieces</td>
<td><a class="btn btn-danger" href="{% url 'main:remove-from-cart' cart.id
%}">Delete</a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}

Dept of ISE, BIT 2021-2022 P a g e | 27


GROCERY MANAGEMENT SYSTEM 1BI19IS037

<h4 class="text-center">Sorry, Your Cart is Empty. .. Please add Items!!!</h4>


{% endif %}
</div>
<div class="col-sm-3 mt-5 mb-3">
<div class="content-section">
<h3 class="text-center">Order Summary</h3>
<ul class="list-group">
<li class="list-group-item list-group-item-light text-center text-dark">Total: {{ total }}</li>
<li class="list-group-item list-group-item-light text-center text-dark">Number of Orders: {{
count }}</li>
<li class="list-group-item list-group-item-light text-center text-dark">Total Pieces: {{
total_pieces }}</li>
<li class="list-group-item list-group-item-light text-center text-dark"><a class="btn btn-
primary" href="{% url 'main:ordered' %}">Proceed To Checkout</a></li>
<li class="list-group-item list-group-item-light text-center"><a class="btn btn-success"
href="/">Continue Buying</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>

{% endblock content %}
Cart_itemsdelete.html
{% extends "main/layout.html" %}
{% block content %}
<div class="content-section container">
<form method="POST">
{% csrf_token %}
<fieldset class="form-group">
<legend class="border-bottom mb-4">Delete Cart Item</legend>
<h2>Are you sure you want to delete the post "{{ object.item.title }}"</h2>
</fieldset>
<div class="form-group">
<button class="btn btn-danger" type="submit">Yes, Delete</button>
<a class="btn btn-success" href="{% url 'main:cart' %}">Cancel</a>

Dept of ISE, BIT 2021-2022 P a g e | 28


GROCERY MANAGEMENT SYSTEM 1BI19IS037

</div>
</form>
</div>
{% endblock content %}
Dishes.html
{% extends "main/layout.html" %}
{% block content %}
<div class="dishes">
<!--Main layout-->
<main class="mt-3 pt-4 main">
<div class="container dark-grey-text">
<div class="row wow fadeIn">
<div class="col-md-6 mb-4">
<img src="{{ item.image.url }}" class="img-fluid mt-4" alt="">
</div>
<div class="col-md-6 mb-4 information">
<!--Content-->
<div class="p-4 content">
<div class="mt-0">
<h2><u>{{ item.title }}</u><span class="badge badge-{{ item.label_colour }} ml-2">{{
item.labels }}</span></h2>
</div>
<div class="lead">

{% if item.description %}
<h5>{{ item.description }}</h5>
{% endif %}
<h3>P{{ item.price }} per order of {{ item.pieces}} pieces</h3>
<h4>{{ item.instructions }}</h4>
</div>
<a href="{% url 'main:add-to-cart' item.slug %}" class="btn btn-success btn-md my-0 p">Add
to cart</a>
</div>

Dept of ISE, BIT 2021-2022 P a g e | 29


GROCERY MANAGEMENT SYSTEM 1BI19IS037

</div>
<hr>
</div>
</main>
<div class="container">
<h1 class="text-center">Reviews</h1>
<form action="{% url 'main:add_reviews' %}" method="POST" class="mb-3">
{% csrf_token %}
<div class="row">
<div class="col-sm-11">
<input type="text" name="review" class="form-control" placeholder="Enter Your Review">
<input type="hidden" name="rslug" class="form-control" value="{{item.slug}}">
</div>
<div class="col-sm-1">
<button type="submit" class="btn btn-primary">Submit</button>
</div>
</div>
</form>
{% for review in reviews %}
<div class="main-reviews card bg-success mb-3">
<div class="card-body">
<div class="user_details" style="display: flex; border-bottom: 1px solid rgb(31, 30, 30);">
<h3 class="mr-3">{{ review.user.username }} </h3>
<p class="mt-2">{{ review.posted_on }}</p>
</div>
<h4>{{ review.review }}</h4>
</div>
</div>

{% endfor %}
{% endblock content %}

Dept of ISE, BIT 2021-2022 P a g e | 30


GROCERY MANAGEMENT SYSTEM 1BI19IS037

Home.html

{% extends "main/layout.html" %}
{% block content %}
<div class="home bg-danger">
<div id="carouselExampleCaptions" class="carousel slide mb-5" data-ride="carousel"
style="height: 500px;">
<ol class="carousel-indicators">
<li data-target="#carouselExampleCaptions" data-slide-to="0" class="active"></li>
<li data-target="#carouselExampleCaptions" data-slide-to="1"></li>
<li data-target="#carouselExampleCaptions" data-slide-to="2"></li>
</ol>
<div class="carousel-item active">
<img src="../media/grocery.jpg" class="d-block w-100" alt="sushi1" height="500px">
<div class="carousel-caption d-none d-md-block text-dark">
<h1 style="color: rgb(2, 24, 4)">EASY BASKET</h1>
</div>
<div class="carousel-item">
<img src="../media/4.jpg" class="d-block w-100" alt="sushi2" height="500px">
</div>
<div class="carousel-item">
<img src="../media/garantisado.jpg" class="d-block w-100" alt="sushi3" height="500px">
</div>
</div>
<a class="carousel-control-prev" href="#carouselExampleCaptions" role="button" data-
slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="carousel-control-next" href="#carouselExampleCaptions" role="button" data-
slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a

Dept of ISE, BIT 2021-2022 P a g e | 31


GROCERY MANAGEMENT SYSTEM 1BI19IS037

</div>
<div class="container">
<h1 class="text-center text-light mb-3">ITEMS</h1>
<div class="row">
{% for item in menu_items %}
<div class="col-sm-4">
<div class="card mb-3" style="height: fit-content; overflow: auto;">
<img src="{{ item.image.url }}" style="height: 250px;">
<div class="card-body text-center">
<button class="btn btn-warning">By:{{ item.created_by }}</button>
<h5 class="text-center"><a href="{% url 'main:dishes' item.slug %}">{{ item.title }}
</a><span class="badge badge-{{ item.label_colour }}">{{ item.labels }}</span></h5>
<p class="text-center">{{ item.description }}</p>
<h5 class="text-center">P{{ item.price }}</h5>
<a href="{% url 'main:dishes' item.slug %}" class="btn btn-success">View Details</a>
</div>
{% endfor %}
</div>
</div>
</div>
{% endblock content %}
Item_confirmdelete.html
{% extends "main/layout.html" %}
{% block content %}
<div class="content-section container">
<form method="POST">
{% csrf_token %}
<fieldset class="form-group">
<legend class="border-bottom mb-4">Delete Item</legend>
<h2>Are you sure you want to delete the post "{{ item.title }}"</h2>
</fieldset>
<div class="form-group">

Dept of ISE, BIT 2021-2022 P a g e | 32


GROCERY MANAGEMENT SYSTEM 1BI19IS037

<button class="btn btn-danger" type="submit">Yes, Delete</button>


<a class="btn btn-success" href="{% url 'main:item_list' %}">Cancel</a>
</div>
</form>
</div>

{% endblock content %}
Item_form.html
{% extends "main/layout2.html" %}
{% load crispy_forms_tags %}
{% block content %}
<div class="form">
<div class="container">
<div class="row">
<div class="col-sm-12">
<form method="POST" enctype="multipart/form-data">
{% csrf_token %}
<fieldset class="form-group">
<legend class="border-bottom mb-4">Add Item</legend>
{{ form|crispy }}
</fieldset>
<div class="form-group">
<button class="btn btn-primary" type="submit">Add</button>
</div>
</form>
</div>
</div>
{% endblock content %}
Item_list.html
{% extends "main/layout2.html" %}
{% block content %}
<div class="cart">

Dept of ISE, BIT 2021-2022 P a g e | 33


GROCERY MANAGEMENT SYSTEM 1BI19IS037

<div class="row">
<div class="col-sm-12">
{% if items %}
<div class="table-responsive">
<table class="table table-dark">
<thead>
<tr>
<td scope="col">Item No.</td>
<th scope="col">Title</th>

<th scope="col">Decription</th>
<th scope="col">Instructions</th>
<th scope="col">Price</th>
<th scope="col">Pieces</th>
<th></th>
</tr>
</thead>
<tbody>
{% for item in items %}
<tr>
<td>{{ item.id }}</td>
<td>{{ item.title }} <span class="badge badge-{{ item.label_colour }}">{{
item.labels }}</span></td></td>
<td>{{ item.description }}</td>
<td>{{ item.instructions }}</td>
<td>{{ item.price }}</td>
<td>{{ item.pieces }} pieces</td>
<td><a class="btn btn-primary" href="{% url 'main:item-update' item.slug
%}">Update</a></td>
<td><a class="btn btn-danger" href="{% url 'main:item-delete' item.slug
%}">Delete</a></td>
</tr>
{% endfor %}

Dept of ISE, BIT 2021-2022 P a g e | 34


GROCERY MANAGEMENT SYSTEM 1BI19IS037

</tbody>
</table>
</div>
{% else %}
<h4 class="text-center">Sorry, you have not ordered any item yet!!!</h4>
{% endif %}
</div>
</div>
{% endblock content %}
Layout1.html
{% load get_group %}
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-
Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
crossorigin="anonymous">
<link rel="stylesheet" type="text/css" href="{% static 'main/styles.css' %}">
<title>ONLINE SHOPPING</title>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
<a class="navbar-brand" href="/"><h3>GROCERY ONLINE SHOPPING</h3></a>
<button
class="navbar-toggler"
type="button"
data-toggle="collapse"
data-target="#navbarNav"
aria-controls="navbarNav"

Dept of ISE, BIT 2021-2022 P a g e | 35


GROCERY MANAGEMENT SYSTEM 1BI19IS037

aria-expanded="false"
aria-label="Toggle navigation"
>
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav mr-auto">
</ul>
<ul class="navbar-nav ml-auto">
<li><a href="{% url 'main:home' %}" class="mr-2 text-light">Home</a></li>
{% if user.is_authenticated %}
{% if request.user|has_group:"admin_owner" %}
<li><a href="{% url 'main:admin_dashboard' %}" class="mr-2 text-
light">DashBoard</a></li>
<li>
<form class="logout-link" action="{% url 'accounts:logout' %}" method="post">
{% csrf_token %}
<button type="submit" class="mr-2">Logout</button>
</form>
</li>
{% else %}

<li><a href="{% url 'main:cart' %}" class="mr-2 text-light">My Cart˙ </a></li>
<li><a href="{% url 'main:order_details' %}" class="mr-2 text-light">Your
Orders</a></li>
<li>
<form class="logout-link" action="{% url 'accounts:logout' %}" method="post">
{% csrf_token %}
<button type="submit" class="mr-2">Logout</button>
</form>
</li>
{% endif %}
{% else %}
<li><a href="{% url 'accounts:login' %}" class="mr-2 text-light">Login</a></li>

Dept of ISE, BIT 2021-2022 P a g e | 36


GROCERY MANAGEMENT SYSTEM 1BI19IS037

<li><a href="{% url 'accounts:signup' %}" class="mr-2 text-light">SignUp</a></li>


{% endif %}
</ul>
</div>
</nav>
<main role="main">
{% if messages %}
{% for message in messages %}
<div class="alert alert-{{ message.tags }}">
{{ message }}
</div>
{% endfor %}
{% endif %}
{% block content %}{% endblock %}
</main>
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-
KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
integrity="sha384-
ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
integrity="sha384-
JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
crossorigin="anonymous"></script>
<script>

$('.carousel').carousel();
</script>
Order_details.html
{% extends "main/layout.html" %}
{% block content %}
<div class="cart">

Dept of ISE, BIT 2021-2022 P a g e | 37


GROCERY MANAGEMENT SYSTEM 1BI19IS037

<div class="container">
<div class="row">
<div class="col-sm-12 mt-5">
<h3 class="text-center">Active Orders</h3>
{% if items %}
<h4 class="text-center">Total Bill Amount: {{total}} for {{ count }} Orders.</h4>
<h6 class="text-center">Please Pay Either via ATM or Credit Card or Cash on Delivery!</h6>
<div class="table-responsive">
<table class="table table-light">
<thead>
<tr>
<th scope="col">Ordered</th>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">Specification</th>
<th scope="col">Price</th>
<th scope="col">Total Pieces</th>
<th scope="col">Order Status</th>
</tr>
</thead>
<tbody>
{% for item_active in items %}
<tr>
<td>{{ item_active.ordered_date }}</td>
<td>{{ item_active.item.title }} <span class="badge badge-{{
item_active.item.label_colour }}">{{ item_active.item.labels }}</span></td>
<td>{{ item_active.item.description }}</td>
<td>{{ item_active.item.instructions }}</td>
<td>{{ item_active.item.price }}</td>
<td>{{ item_active.item.pieces }} pieces</td>
<td>{{ item_active.status }}</td>
</tr>
{% endfor %}

Dept of ISE, BIT 2021-2022 P a g e | 38


GROCERY MANAGEMENT SYSTEM 1BI19IS037

</tbody>
</table>
</div>
{% else %}
<h4 class="text-center">Sorry, you have not ordered any item yet!!!</h4>
{% endif %}
</div>
</div>
<div class="row">
<div class="col-sm-12 mt-5">
<h3 class="text-center">Past Orders</h3>
{% if cart_items %}
<div class="table-responsive">
<table class="table table-light">
<thead>
<tr>
<th scope="col">Ordered</th>
<th scope="col">Name</th>
<th scope="col">Description</th>
<th scope="col">Price</th>
<th scope="col">Total Pieces</th>
<th scope="col">Order Status</th>
<th scope="col">Delivery Date</th>
</tr>
</thead>
<tbody>
{% for cart in cart_items %}
<tr>
<td>{{ cart.ordered_date }}</td>
<td>{{ cart.item.title }} <span class="badge badge-{{ cart.item.label_colour
}}">{{ cart.item.labels }}</span></td>
<td>{{ cart.item.description }}</td>
<td>{{ cart.item.instructions }}</td>

Dept of ISE, BIT 2021-2022 P a g e | 39


GROCERY MANAGEMENT SYSTEM 1BI19IS037

<td>{{ cart.item.price }}</td>


<td>{{ cart.item.pieces }} pieces</td>
<td>{{ cart.status }}</td>
<td>{{ cart.delivery_date }}</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<h4 class="text-center">Sorry, you have not ordered any item yet!!!</h4>
{% endif %}
</div>
</div>
</div>
</div>
{% endblock content %}
Pending_orders.html
{% extends "main/layout2.html" %}
{% block content %}
<div class="cart">
<div class="row">
<div class="col-sm-12">
<h3 class="text-center">Active Orders</h3>
{% if items %}
<div class="table-responsive">
<table class="table table-dark">
<thead>

<th scope="col">Specification</th>
<th scope="col">Price</th>
<th scope="col">Total Pieces</th>
<th scope="col">Status</th>

Dept of ISE, BIT 2021-2022 P a g e | 40


GROCERY MANAGEMENT SYSTEM 1BI19IS037

</tr>
</thead>
<tbody>
{% for item in items %}
<tr>
<td>{{ item.id }}</td>
<td>{{ item.user.username }}</td>
<td>{{ item.user.email}}</td>
<td>{{ item.item.title }} <span class="badge badge-{{ item.item.label_colour }}">
item.item.labels }}</span></td>
<td>{{ item.item.description }}</td>
<td>{{ item.item.instructions }}</td>
<td>{{ item.item.price }}</td>
<td>{{ item.item.pieces }} pieces</td>
<td>{{ item.status }}</td>
<td>
<form method="POST" action="{% url 'main:update_status' item.id %}" style="display:
flex;">
{% csrf_token %}
<select class="form-control" name="status">
<option value="Active" selected="selected">Active</option>
<option value="Delivered">Delivered</option>
</select>
<button type="submit" class="btn btn-primary">Change</button>
</form>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<h4 class="text-center">Sorry, you have not ordered any item yet!!!</h4>
{% endif %}

Dept of ISE, BIT 2021-2022 P a g e | 41


GROCERY MANAGEMENT SYSTEM 1BI19IS037

</div>
</div>
</div>
{% endblock content %}
Styles.css
.dishes .main .container .row img{
max-width: 540px;
max-height: 450px;
width: fit-content;
}
.dishes .main .container .row .content{
display: flex;
flex-direction: column;
text-align: center;
justify-content: center;
}
.dishes .main .container .row .information{
display: flex;
flex-direction: column;
text-align: center;
justify-content: center;
}

Dept of ISE, BIT 2021-2022 P a g e | 42


GROCERY MANAGEMENT SYSTEM 1BI19IS037

4.4 Back-end Code

Django Code

settings.py
Django settings for Foods_Ordering project.
Generated by 'django-admin startproject' using Django 3.0.4.
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath( file )))
SECRET_KEY = 'v7)ouo@=dhswvnfs!@o$v07^m#+2l^1+c#n%bel2eqn!5f^fx^'
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'main.apps.MainConfig',
'accounts.apps.AccountsConfig',
'crispy_forms',
]
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

Dept of ISE, BIT 2021-2022 P a g e | 43


GROCERY MANAGEMENT SYSTEM 1BI19IS037

ROOT_URLCONF = 'Foods_Ordering.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'Foods_Ordering.wsgi.application'

Create database
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
# Password validation
AUTH_PASSWORD_VALIDATORS = [
{
'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},

Dept of ISE, BIT 2021-2022 P a g e | 44


GROCERY MANAGEMENT SYSTEM 1BI19IS037

{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]
# Internationalization
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Kolkata'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = '/static/'
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
CRISPY_TEMPLATE_PACK = 'bootstrap4'
Urls.py
Foods_Ordering URL Configuration
The `urlpatterns` list routes URLs to views.
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
from django.conf.urls.static import static
admin.site.site_header = "Login Administrator"
admin.site.site_title = "Food-Ordering"
admin.site.index_title = "Food Ordering Admin Site"
urlpatterns = [
path('admin/', admin.site.urls),
path('',include('main.urls')),
path('accounts/', include('accounts.urls')),

Dept of ISE, BIT 2021-2022 P a g e | 45


GROCERY MANAGEMENT SYSTEM 1BI19IS037

]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
wsgi.py
WSGI config for Foods_Ordering project. It exposes the WSGI callable as a module-level variable
named ``application``.
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Foods_Ordering.settings')
application = get_wsgi_application()
Asgi.py
ASGI config for Foods_Ordering project. It exposes the ASGI callable as a module-level variable
named ``application``.
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Foods_Ordering.settings')
application = get_asgi_application()

ADMIN.PY
from django.contrib import adminfrom .models
import Item, CartItems, Reviews
from django.db
import models
class ItemAdmin(admin.ModelAdmin):
fieldsets = [
("Created By", {'fields': ["created_by"]}),
("Title", {'fields': ["title"]}),
("Image", {'fields': ["image"]}),
("Description", {'fields': ["description"]}),
("Price", {'fields': ["price"]}),
("Pieces", {'fields': ["pieces"]}),
("Instructions", {'fields': ["instructions"]}),
("Labels", {'fields': ["labels"]}),

Dept of ISE, BIT 2021-2022 P a g e | 46


GROCERY MANAGEMENT SYSTEM 1BI19IS037

("Label Colour", {'fields': ["label_colour"]}),


("Slug", {'fields': ["slug"]}),
]
list_display = ('id','created_by','title','description','price','labels')
class CartItemsAdmin(admin.ModelAdmin):
fieldsets = [
("Order Status", {'fields' : ["status"]}),
("Delivery Date", {'fields' : ["delivery_date"]})
]
list_display = ('id','user','item','quantity','ordered','ordered_date','delivery_date','status')
list_filter = ('ordered','ordered_date','status')
class ReviewsAdmin(admin.ModelAdmin):
list_display = ('user','item','review','posted_on')
admin.site.register(Item,ItemAdmin)
admin.site.register(CartItems,CartItemsAdmin)
admin.site.register(Reviews,ReviewsAdmin)
from django.apps import AppConfig
class MainConfig(AppConfig):
name = 'main'
decorators.py
from django.http import HttpResponse
from django.shortcuts import redirect
from django.contrib.auth.models import Group
from .models import *
def admin_required(view_func):
def wrapper_func(request, *args, **kwargs):
group = Group.objects.get(user = request.user)
if group.name == 'admin_owner':
return view_func(request, *args, **kwargs)
else:
return redirect('/')
return wrapper_func

Dept of ISE, BIT 2021-2022 P a g e | 47


GROCERY MANAGEMENT SYSTEM 1BI19IS037

forms.py
from django import forms
from .models import Item
class AddForm(forms.ModelForm):
class Meta:
model = Item
fields = ('created_by',
'title', 'image', 'description', 'price', 'pieces', 'instructions', 'labels', 'label_colour', 'slug')
Models.py
from django.db import models
from django.conf import settings
from django.shortcuts import reverse
from django.utils import timezone
from django.contrib.auth.models import User
class Item(models.Model):
LABELS = (
('Best Selling Foods', 'Best Selling Foods'),
('New Food', 'New Food'),
µ
('Spicy Foods˛ ˛
f ', 'Spicy Foodsµ
f '),
)
LABEL_COLOUR = (
('danger', 'danger'),
('success', 'success'),
('primary', 'primary'),
('info', 'info'),
('warning', 'warning'),
)
title = models.CharField(max_length=150)
description = models.CharField(max_length=250,blank=True)
price = models.FloatField()
pieces = models.IntegerField(default=6)
instructions = models.CharField(max_length=250,default="Available")
image = models.ImageField(default='default.png', upload_to='images/')

Dept of ISE, BIT 2021-2022 P a g e | 48


GROCERY MANAGEMENT SYSTEM 1BI19IS037

labels = models.CharField(max_length=25, choices=LABELS, blank=True)


label_colour = models.CharField(max_length=15, choices=LABEL_COLOUR, blank=True)
slug = models.SlugField(default="foods")
created_by = models.ForeignKey(User, on_delete=models.CASCADE)
def str (self):
return self.title
def get_absolute_url(self):
return reverse("main:dishes", kwargs={
'slug': self.slug
})
def get_add_to_cart_url(self):
return reverse("main:add-to-cart", kwargs={
'slug': self.slug
})
def get_item_delete_url(self):
return reverse("main:item-delete", kwargs={
'slug': self.slug
})
def get_update_item_url(self):
return reverse("main:item-update", kwargs={
'slug': self.slug
})
class Reviews(models.Model):
user = models.ForeignKey(User, on_delete = models.CASCADE)
item = models.ForeignKey(Item, on_delete = models.CASCADE)
rslug = models.SlugField()
review = models.TextField()
posted_on = models.DateField(default=timezone.now)
class Meta:
verbose_name = 'Review'
verbose_name_plural = 'Reviews'
def str (self):
return self.review

Dept of ISE, BIT 2021-2022 P a g e | 49


GROCERY MANAGEMENT SYSTEM 1BI19IS037

class CartItems(models.Model):
ORDER_STATUS = (
('Active', 'Active'),
('Delivered', 'Delivered')
)
user = models.ForeignKey(User, on_delete=models.CASCADE)
item = models.ForeignKey(Item, on_delete=models.CASCADE)
ordered = models.BooleanField(default=False)
quantity = models.IntegerField(default=1)
ordered_date = models.DateField(default=timezone.now)
status = models.CharField(max_length=20, choices=ORDER_STATUS, default='Active')
delivery_date = models.DateField(default=timezone.now)
class Meta:
verbose_name = 'Cart Item'
verbose_name_plural = 'Cart Items'
def str (self):
return self.item.title
def get_remove_from_cart_url(self):
return reverse("main:remove-from-cart", kwargs={
'pk' : self.pk
})
def update_status_url(self):
return reverse("main:update_status", kwargs={
'pk' : self.pk
})
Urls.py
from django.urls import path
from . import views
from .views import (
MenuListView, menuDetail, add_to_cart, get_cart_items, order_item, CartDeleteView,
order_details, admin_view, item_list, pending_orders, ItemCreateView, ItemUpdateView,
ItemDeleteView, update_status,add_reviews,
)

Dept of ISE, BIT 2021-2022 P a g e | 50


GROCERY MANAGEMENT SYSTEM 1BI19IS037

app_name = "main"
urlpatterns = [
path('', MenuListView.as_view(), name='home'),
path('dishes/<slug>', views.menuDetail, name='dishes'),
path('item_list/', views.item_list, name='item_list'),
path('item/new/', ItemCreateView.as_view(), name='item-create'),
path('item-update/<slug>/', ItemUpdateView.as_view(), name='item-update'),
path('item-delete/<slug>/', ItemDeleteView.as_view(), name='item-delete'),
path('add-to-cart/<slug>/', views.add_to_cart, name='add-to-cart'),
path('cart/', views.get_cart_items, name='cart'),
path('remove-from-cart/<int:pk>/', CartDeleteView.as_view(), name='remove-from-cart'),
path('ordered/', views.order_item, name='ordered'),
path('order_details/', views.order_details, name='order_details'),
path('admin_view/', views.admin_view, name='admin_view'),
path('pending_orders/', views.pending_orders, name='pending_orders'),
path('admin_dashboard/', views.admin_dashboard, name='admin_dashboard'),
path('update_status/<int:pk>', views.update_status, name='update_status'),
]
Views.py
from django.shortcuts import render, get_object_or_404, redirect
from .models import Item, CartItems, Reviews
from django.contrib import messages
from django.views.generic import (
ListView,
DetailView,
CreateView,
UpdateView,
DeleteView,
)
from django.utils import timezone
from django.contrib.auth.decorators import login_required
from django.contrib.auth.mixins import LoginRequiredMixin, UserPassesTestMixin
from .decorators import *

Dept of ISE, BIT 2021-2022 P a g e | 51


GROCERY MANAGEMENT SYSTEM 1BI19IS037

from django.db.models import Sum


class MenuListView(ListView):
model = Item
template_name = 'main/home.html'
context_object_name = 'menu_items'
def menuDetail(request, slug):
item = Item.objects.filter(slug=slug).first()
reviews = Reviews.objects.filter(rslug=slug).order_by('-id')[:7]
context = {
'item' : item,
'reviews' : reviews,
}
return render(request, 'main/dishes.html', context)
def add_reviews(request):
if request.method == "POST":
user = request.user
rslug = request.POST.get("rslug")
item = Item.objects.get(slug=rslug)
review = request.POST.get("review")
reviews = Reviews(user=user, item=item, review=review, rslug=rslug)
reviews.save()
messages.success(request, "Thank You for Reviewing this Item!!")
return redirect(f"/dishes/{item.slug}")
class ItemCreateView(LoginRequiredMixin, CreateView):
model = Item
fields = ['title', 'image', 'description', 'price', 'pieces', 'instructions', 'labels', 'label_colour', 'slug']
def form_valid(self, form):
form.instance.created_by = self.request.user
return super().form_valid(form)
class ItemUpdateView(LoginRequiredMixin, UserPassesTestMixin, UpdateView):
model = Item
fields = ['title', 'image', 'description', 'price', 'pieces', 'instructions', 'labels', 'label_colour', 'slug']
def form_valid(self, form):

Dept of ISE, BIT 2021-2022 P a g e | 52


GROCERY MANAGEMENT SYSTEM 1BI19IS037

form.instance.created_by = self.request.user
return super().form_valid(form)
def test_func(self):
item = self.get_object()
if self.request.user == item.created_by:
return True
return False
class ItemDeleteView(LoginRequiredMixin, UserPassesTestMixin, DeleteView):
model = Item
success_url = '/item_list'
def test_func(self):
item = self.get_object()
if self.request.user == item.created_by:
return True
return False
def add_to_cart(request, slug):
item = get_object_or_404(Item, slug=slug)
cart_item = CartItems.objects.create(
item=item,
user=request.user,
ordered=False,
)
messages.info(request, "Added to Cart!!Continue Shopping!!")
return redirect("main:cart")
def get_cart_items(request):
cart_items = CartItems.objects.filter(user=request.user,ordered=False)
bill = cart_items.aggregate(Sum('item price'))
number = cart_items.aggregate(Sum('quantity'))
pieces = cart_items.aggregate(Sum('item pieces'))
total = bill.get("item price sum")
count = number.get("quantity sum")
total_pieces = pieces.get("item pieces sum")
context = {

Dept of ISE, BIT 2021-2022 P a g e | 53


GROCERY MANAGEMENT SYSTEM 1BI19IS037

'cart_items':cart_items,
'total': total,
'count': count,
'total_pieces': total_pieces
}
return render(request, 'main/cart.html', context)
class CartDeleteView(LoginRequiredMixin, UserPassesTestMixin, DeleteView):
model = CartItems
success_url = '/cart'
def test_func(self):
cart = self.get_object()
if self.request.user == cart.user:
return True
return False
def order_item(request):
cart_items = CartItems.objects.filter(user=request.user,ordered=False)
ordered_date=timezone.now()
cart_items.update(ordered=True,ordered_date=ordered_date)
messages.info(request, "Item Ordered")
return redirect("main:order_details")
def order_details(request):
items = CartItems.objects.filter(user=request.user, ordered=True,status="Active").order_by('-
ordered_date')
cart_items = CartItems.objects.filter(user=request.user,
ordered=True,status="Delivered").order_by('-ordered_date')
bill = items.aggregate(Sum('item price'))
number = items.aggregate(Sum('quantity'))
pieces = items.aggregate(Sum('item pieces'))
total = bill.get("item price sum")
count = number.get("quantity sum")
total_pieces = pieces.get("item pieces sum")
context = {
'items':items,

Dept of ISE, BIT 2021-2022 P a g e | 54


GROCERY MANAGEMENT SYSTEM 1BI19IS037

'cart_items':cart_items,
'total': total,
'count': count,
'total_pieces': total_pieces
}
return render(request, 'main/order_details.html', context)
def admin_view(request):
cart_items = CartItems.objects.filter(item created_by=request.user,
ordered=True,status="Delivered").order_by('-ordered_date')
context = {
'cart_items':cart_items,
}
return render(request, 'main/admin_view.html', context)
def item_list(request):
items = Item.objects.filter(created_by=request.user)
context = {
'items':items
}
return render(request, 'main/item_list.html', context)
def update_status(request,pk):
if request.method == 'POST':
status = request.POST['status']
cart_items = CartItems.objects.filter(item created_by=request.user,
ordered=True,status="Active",pk=pk)
delivery_date=timezone.now()
if status == 'Delivered':
cart_items.update(status=status, delivery_date=delivery_date)
return render(request, 'main/pending_orders.html')
def pending_orders(request):
items = CartItems.objects.filter(item created_by=request.user,
ordered=True,status="Active").order_by('-ordered_date')
context = {
'items':items,

Dept of ISE, BIT 2021-2022 P a g e | 55


GROCERY MANAGEMENT SYSTEM 1BI19IS037

}
return render(request, 'main/pending_orders.html', context)
def admin_dashboard(request):
cart_items = CartItems.objects.filter(item created_by=request.user, ordered=True)
pending_total = CartItems.objects.filter(item created_by=request.user,
ordered=True,status="Active").count()
completed_total = CartItems.objects.filter(item created_by=request.user,
ordered=True,status="Delivered").count()
count1 = CartItems.objects.filter(item created_by=request.user, ordered=True,item="3").count()
count2 = CartItems.objects.filter(item created_by=request.user, ordered=True,item="4").count()
count3 = CartItems.objects.filter(item created_by=request.user, ordered=True,item="5").count()
total = CartItems.objects.filter(item created_by=request.user,
ordered=True).aggregate(Sum('item price'))
income = total.get("item price sum")
context = {
'pending_total' : pending_total,
'completed_total' : completed_total,
'income' : income,
'count1' : count1,
'count2' : count2,
'count3' : count3,
}
return render(request, 'main/admin_dashboard.html', context)
Migrations.py
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Item',
fields=[

Dept of ISE, BIT 2021-2022 P a g e | 56


GROCERY MANAGEMENT SYSTEM 1BI19IS037

('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,


verbose_name='ID')),
('title', models.CharField(max_length=150)),
('description', models.CharField(blank=True, max_length=250)),
('price', models.FloatField()),
('pieces', models.IntegerField(default=6)),
('instructions', models.CharField(default='Jain Option Available', max_length=250)),
('image', models.ImageField(default='default.png', upload_to='images/')),
('labels', models.CharField(blank=True, choices=[('BestSeller', 'BestSeller'), ('New', 'New'),
('Spicy', 'Spicy')], max_length=25)),
('label_colour', models.CharField(blank=True, choices=[('danger', 'danger'), ('success',
'success'), ('primary', 'primary'), ('info', 'info')], max_length=15)),
('slug', models.SlugField(default='sushi_name')),
],
),
]
Cartitems.py
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('main', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='CartItems',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,
verbose_name='ID')),
('ordered', models.BooleanField(default=False)),

Dept of ISE, BIT 2021-2022 P a g e | 57


GROCERY MANAGEMENT SYSTEM 1BI19IS037

('quantity', models.IntegerField(default=1)),
('specifications', models.CharField(default='Non-Jain/Medium Spicy', max_length=200)),
('delivery_date', models.DateField(default=django.utils.timezone.now, max_length=100)),
('item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
to='main.Item')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL)),
],
),
]
Remove_cartitems.py
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('main', '0002_cartitems'),
]
operations = [
migrations.RemoveField(
model_name='cartitems',
name='delivery_date',
),
]
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('main', '0003_remove_cartitems_delivery_date'),
]
operations = [
migrations.RemoveField(
model_name='cartitems',
name='specifications',
),
]

Dept of ISE, BIT 2021-2022 P a g e | 58


GROCERY MANAGEMENT SYSTEM 1BI19IS037

from django.db import migrations, models


class Migration(migrations.Migration):
dependencies = [
('main', '0004_remove_cartitems_specifications'),
]
operations = [
migrations.AlterField(
model_name='item',
name='labels',
field=models.CharField(blank=True, choices=[('BestSeller', 'BestSeller'), ('New', 'New'),
('Spicyµ ˛
f ', 'Spicyµ
f ')], max_length=25),
),
]
Order.py
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('main', '0005_auto_20200721_0232'),
]
operations = [
migrations.CreateModel(
name='Order',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,
verbose_name='ID')),
('instructions', models.CharField(default='Medium Spicy/Non-Jain', max_length=200)),
('cart', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
to='main.CartItems')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL)),

Dept of ISE, BIT 2021-2022 P a g e | 59


GROCERY MANAGEMENT SYSTEM 1BI19IS037

],
),
]
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('main', '0006_order'),
]
operations = [
migrations.RenameField(
model_name='order',
old_name='cart',
new_name='cart_items',
),
]
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('main', '0008_auto_20200726_0216'),
]
operations = [
migrations.RemoveField(
model_name='cartitems',
name='instructions',
),
]
import datetime
from django.db import migrations, models
from django.utils.timezone import utc
class Migration(migrations.Migration):
dependencies = [
('main', '0009_remove_cartitems_instructions'),
]

Dept of ISE, BIT 2021-2022 P a g e | 60


GROCERY MANAGEMENT SYSTEM 1BI19IS037

operations = [
migrations.AddField(
model_name='cartitems',
name='ordered_date',
field=models.DateField(default=datetime.datetime(2020, 7, 25, 21, 24, 20, 14250,
tzinfo=utc)),
),
]

Auto.py
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('main', '0010_cartitems_ordered_date'),
]
operations = [
migrations.AlterField(
model_name='cartitems',
name='ordered_date',
field=models.DateField(default=django.utils.timezone.now),
),
]
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('main', '0012_auto_20200726_2347'),
]
operations = [
migrations.RemoveField(
model_name='cartitems',
name='status',),

Dept of ISE, BIT 2021-2022 P a g e | 61


GROCERY MANAGEMENT SYSTEM 1BI19IS037

]
Cartiems.py
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0013_remove_cartitems_status'),
]
operations = [
migrations.AddField(
model_name='cartitems',
name='status',
field=models.CharField(blank=True, max_length=20),
),
]
from django.db import migrations
class Migration(migrations.Migration):
dependencies = [
('main', '0014_cartitems_status'),
]
operations = [
migrations.RemoveField(
model_name='cartitems',
name='status',
),
]
Cart_itemsstatus.py
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0015_remove_cartitems_status'),
]
operations = [
migrations.AddField(

Dept of ISE, BIT 2021-2022 P a g e | 62


GROCERY MANAGEMENT SYSTEM 1BI19IS037

model_name='cartitems',
name='status',
field=models.CharField(choices=[('Active', 'Active'), ('Delivered', 'Delivered')],
default='Active', max_length=20),
),
]
Cartitems_deliverydate.py
from django.db import migrations, models
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
('main', '0016_cartitems_status'),
]
operations = [
migrations.AddField(
model_name='cartitems',
name='delivery_date',
field=models.DateField(default=django.utils.timezone.now),
),
]
Items.py
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('main', '0017_cartitems_delivery_date'),
]
operations = [
migrations.AddField(
model_name='item',
name='created_by',

Dept of ISE, BIT 2021-2022 P a g e | 63


GROCERY MANAGEMENT SYSTEM 1BI19IS037

field=models.ForeignKey(default=1, on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL),
preserve_default=False,
),
]
Reviews.py
from django.conf import settings
from django.db import migrations, models
import django.db.models.deletion
import django.utils.timezone
class Migration(migrations.Migration):
dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('main', '0018_item_created_by'),
]
operations = [
migrations.CreateModel(
name='Reviews',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,
verbose_name='ID')),
('rslug', models.SlugField(default='sushi-slug')),
('review', models.TextField()),
('posted_on', models.DateField(default=django.utils.timezone.now)),
('item', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
to='main.Item')),
('user', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL)),
],
),
]
from django.db import migrations, models
class Migration(migrations.Migration):

Dept of ISE, BIT 2021-2022 P a g e | 64


GROCERY MANAGEMENT SYSTEM 1BI19IS037

dependencies = [
('main', '0019_reviews'),
]
operations = [
migrations.AlterField(
model_name='reviews',
name='rslug',
field=models.SlugField(),
),
]

Manage.py
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'Foods_Ordering.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 ':
main()

Dept of ISE, BIT 2021-2022 P a g e | 65


GROCERY MANAGEMENT SYSTEM 1BI19IS037

4.4.1. Table Creation

Creating a basic table involves naming the table and defining its columns and each column's
data type.
The SQL CREATE TABLE statement is used to create a new table.
Syntax
The basic syntax of the CREATE TABLE statement is as follows −
CREATE TABLE table_name(
column1 datatype,
column2 datatype,
column3 datatype,
.....
columnN datatype,
PRIMARY KEY (one or more columns)
);
CREATE TABLE is the keyword telling the database system what you want to do. In this
case, you want to create a new table. The unique name or identifier for the table follows the
CREATE TABLE statement.
Then in brackets comes the list defining each column in the table and what sort of data type
it is.
1. Creation of table auth_group

CREATE TABLE auth_group


(
id INTEGER,
name VARCHAR(150),
PRIMARY KEY(id)
);

2. Creation of table auth_group_permissions

CREATE TABLE auth_group_permissions

Dept of ISE, BIT 2021-2022 P a g e | 66


GROCERY MANAGEMENT SYSTEM 1BI19IS037

(
id INTEGER,
group_id INTEGER,
permission_id INTEGER,
PRIMARY KEY(id)
);

3. Creation of table auth_permission

CREATE TABLE auth_permission


(
id INTEGER,
content_type_id INTEGER,
codename VARCHAR(150),
name VARCHAR(100),
PRIMARY KEY(id),
FOREIGN KEY(id) REFERNCES auth_group_permission(id)
);

4. Creation of table auth_user

CREATE TABLE auth_user


(
id INTEGER,
password VARCHAR(128),
last_login DATETIME,
is_superuser BOOL,
username VARCHAR(150),
first_name VARCHAR(30),
email VARCHAR(254),
is_staff BOOL,
is_active BOOL,
date_joined DATETIME,

Dept of ISE, BIT 2021-2022 P a g e | 67


GROCERY MANAGEMENT SYSTEM 1BI19IS037

last_name VARCHAR(150),
PRIMARY KEY(id, email),
FOREIGN KEY(id) REFERENCES auth_permission(id),
FOREIGN KEY(password) REFERENCES auth_permission(codename)
);

5. Creation of table auth_user_groups

CREATE TABLE auth_user_groups


(
id INTEGER,
user_id INTEGER,
group_id INTEGER,
PRIMARY KEY(id)
);

6. Creation of table auth_user_permissions

CREATE TABLE auth_user_permissions


(
id INTEGER,
user_id INTEGER,
permission_id INTEGER,
FOREIGN KEY(id) REFERENCES auth_user_groups
);

7. Creation of Table admin_log

CREATE TABLE admin_log


(
id INTEGER,
action_time DATETIME,
object_id TEXT,
object_repr VARCHAR(200),

Dept of ISE, BIT 2021-2022 P a g e | 68


GROCERY MANAGEMENT SYSTEM 1BI19IS037

change_message TEXT,
content_type_id INTEGER,
user_id INTEGER,
action_flag SMALLINT UNSIGNED,
PRIMARY KEY(id),
FOREIGN KEY(content_type_id) REFERENCES content_type(id)
);

8. Creation of table content_type

CREATE TABLE content_type


(
id INTEGER,
app_label VARCHAR(100),
model VARCHAR(100),
PRIMARY KEY(id)
);

9. Creation of table migrations

CREATE TABLE migrations


(
id INTEGER,
app VARCHAR(255),
name VARCHAR(255),
applied DATETIME,
FOREIGN KEY(id) REFERENCES content_type_id(id)
);

10. Creation of table main_cartitems

CREATE TABLE main_cartitems


(
id INTEGER,

Dept of ISE, BIT 2021-2022 P a g e | 69


GROCERY MANAGEMENT SYSTEM 1BI19IS037

ordered BOOL,
quantity INTEGER,
item_id INTEGER,
user_id INTEGER,
ordered_date DATE,
status VARCHAR(20),
delivery_date DATE,
FOREIGN KEY(id) REFERENCES main_items(id),
FOREIGN KEY(user_id) REFERENCES auth_user(id)
);

11. Creation of table main_items

CREATE TABLE main_items


(
id INTEGER,
title VARCHAR(150),
description VARCHAR(250),
price REAL,
pieces INTEGER,
instructions VARCHAR(250),
images VARCHAR(100),
labels VARCHAR(25),
label_color VARCHAR(10),
slug VARCHAR(50),
created_by_id INTEGER,
PRIMARY KEY(id)
);

Dept of ISE, BIT 2021-2022 P a g e | 70


GROCERY MANAGEMENT SYSTEM 1BI19IS037

4.4.4 Triggers

A trigger is a stored procedure in database which automatically invokes whenever a special


event in the database occurs. For example, a trigger can be invoked when a row is inserted
into a specified table or when certain table columns are being updated.
Trigger to increment the counter for number of reviews:
CREATE TRIGGER countCitems
ON main_cartitems
AFTER INSERT, DELETE
AS BEGIN
UPDATE count_items
FROM main_cartitems
SET count_items:=count_items+1
UNION
SELECT count_items FROM main_cartitems;
END

Trigger to increment the counter for number of reviews:

CREATE TRIGGER countReviews


ON user_reviews
AFTER INSERT, DELETE
AS BEGIN
UPDATE noOFReviews
FROM user_reviews
SET noOFReviews:=noOFReviews+1
UNION
SELECT noOFReviews FROM user_reviews;
END

Dept of ISE, BIT 2021-2022 P a g e | 71


GROCERY MANAGEMENT SYSTEM 1BI19IS037

4.4.3 Insertion of values in the table

The SQL INSERT INTO Statement is used to add new rows of data to a table in the database.
Syntax
There are two basic syntaxes of the INSERT INTO statement which are shown below.
INSERT INTO TABLE_NAME (column1, column2, column3,...columnN)
VALUES (value1, value2, value3,...valueN);
Here, column1, column2, column3,...columnN are the names of the columns in the table into
which you want to insert the data.
You may not need to specify the column(s) name in the SQL query if you are adding values
for all the columns of the table. But make sure the order of the values is in the same order as
the columns in the table.

The SQL INSERT INTO syntax will be as follows −


INSERT INTO TABLE_NAME VALUES (value1,value2,value3,...valueN);
INSERT INTO main_item VALUES ( '19', 'Orange', 'Fresh and Juicy', '5', '1', 'Store in refrigerator',
'images/orange.jpg', 'Nilgiris', 'success','fruit','8');
INSERT INTO main_cartitems VALUES (‘46’, ‘1’,’ 1’,’ 10’, ‘6’, ‘2020-11-27’ ,’ACTIVE’ , ‘2020-
11-27’);
INSERT INTO main_reviews VALUES (‘9’, ‘good’, ‘2022-01-12’ ,’12’, ‘leafyvegetable’);
INSERT INTO auth_user VALUES(‘6’,
wegKDjDyo8oi$fVsa0vWspQJZz3KS+AexrSBadOjrq/8igAxLNzhnZsE=’, ‘2022-02-06’, ‘1’, ‘ado’,
[email protected]’, ‘0’,’1’, ‘2020-11-26 16:14:10’,’agarwal’);
INSERT INTO Django_admin_log(‘62’, ‘2020-11-26 16:08:14.389694’,’8’,’Lionel
Messi’,’7’,‘6’,‘3’);
INSERT INTO auth_permission VALUES(‘1’,’1’,‘add_logentry’, ‘Can add log entry’);
INSERT INTO django_content_type VALUES(‘7’, ‘main’,‘item’);

Dept of ISE, BIT 2021-2022 P a g e | 72


GROCERY MANAGEMENT SYSTEM 1BI19IS037

CHAPTER 5
SOFTWARE TESTING
Software Testing is a method to check whether the actual software product matches expected
requirements and to ensure that software product is Defect free. It involves execution of
software/system components using manual or automated tools to evaluate one or more
properties of interest. The purpose of software testing is to identify errors, gaps or missing
requirements in contrast to actual requirements.

5.1 Testing Objectives


• Testing is process of executing a program with the intent of finding an error.
• A good test case design is one that has a probability of finding an as yet undiscovered error.
• A successful test is one that uncovers an as yet undiscovered error.
• These above objectives imply a dramatic change in view port.
• Testing cannot show the absence of defects, it can only show that software errors are present

5.2 Testing Principles


• All tests should be traceable to end user requirements.
• Tests should be planned long before testing begins.
• Testing should begin on a small scale and progress towards testing in large.
• Exhaustive testing is not possible.

5.3 Validation Testing


The process of evaluating software during the development process or at the end of the
development process to determine whether it satisfies specified business requirements.
Validation Testing ensures that the product actually meets the client's needs. It can also be
defined as to demonstrate that the product fulfills its intended use when deployed on
appropriate environment.

Dept of ISE, BIT 2021-2022 P a g e | 73


GROCERY MANAGEMENT SYSTEM 1BI19IS037

5.4 Unit Testing


In this test the entire system is divided into smaller entities and each entity is known as a unit
and each unit is tests one at a time. The test ensures the working of each module as per the
requirement in functionality point of view rather actual module visible to the user.

5.5 Integration Testing


In this test each unit is looped together to form a long and continuous chain of modules till it
does not cover the entire system. The test checks the behavior of the interface. This test is
generally performed after unit test.

5.6 Test Cases


Table 5.1 Test Cases
Expected
Test Test Name Actual Output Result
Output
No.
1 Login Successfully Successfully Pass
logged in logged in
2 Adding a new Successfully Successfully Pass
user created created
3 Adding new New data New data Pass
Data
added added
4 Deleting the Data deleted Data deleted Pass
Data
5 Viewing All data All data Pass
details on updated and updated and
Admin side presented presented

Dept of ISE, BIT 2021-2022 P a g e | 74


GROCERY MANAGEMENT SYSTEM 1BI19IS037

5.7 Regression Testing


This test is performed after the integrating test where the system is checked if it gives the
desired output for the expected input data from user.

1. Error displayed in login page on entering wrong password

Fig 5.7.1 Login page with error

2. Error displayed on signup page when user tries to add a new user whose name already exists.

Fig 5.7.2 Username already exists

Dept of ISE, BIT 2021-2022 P a g e | 75


GROCERY MANAGEMENT SYSTEM 1BI19IS037

CHAPTER 6
SNAPSHOTS

Fig 6.1 Home Page

Fig 6.2 Items Page

Fig 6.3 Login Page

Dept of ISE, BIT 2021-2022 P a g e | 76


GROCERY MANAGEMENT SYSTEM 1BI19IS037

Fig 6.4 Sign up form for a new user

Fig 6.5 Item Description after selecting an item

Dept of ISE, BIT 2021-2022 P a g e | 77


GROCERY MANAGEMENT SYSTEM 1BI19IS037

Fig 6.6 Cart items

Fig 6.7 Users orders

Dept of ISE, BIT 2021-2022 P a g e | 78


GROCERY MANAGEMENT SYSTEM 1BI19IS037

Fig 6.8 Admin Login page

Fig 6.9 Admin page

Fig 6.10 Cart items view for admin

Dept of ISE, BIT 2021-2022 P a g e | 79


GROCERY MANAGEMENT SYSTEM 1BI19IS037

Fig 6.11 Admins can add items to cart

Fig 6.12 Admin page which shows items available on catalog

Fig 6.13 Admin adding item to catalog

Dept of ISE, BIT 2021-2022 P a g e | 80


GROCERY MANAGEMENT SYSTEM 1BI19IS037

Fig 6.13 Admin adding item to catalog

Fig 6.14 Admin viewing logged in users

Dept of ISE, BIT 2021-2022 P a g e | 81


GROCERY MANAGEMENT SYSTEM 1BI19IS037

Fig 6.15 Admin has option to add user

Fig 6.16 Admin can view reviews left by customer

Dept of ISE, BIT 2021-2022 P a g e | 82


GROCERY MANAGEMENT SYSTEM 1BI19IS037

CHAPTER 7
CONCLUSION AND FUTURE ENHANCEMENT

7.1 Conclusion

The need for online grocery management system has emerged because of change in working
conditions over the last decade with both partners working for long hours. Also, with
urbanization and soaring land prices, it has become difficult to find large amount of land
within cities like Mumbai, Delhi to open large stores.
Hence, the new hyper-local markets are being opened in outer areas resulting in the
increased distances that one has to travel to get to hyper-local store. This coupled with long
billing queues leave little time for people to shop on stores.
The ubiquitous presence of Internet has made it possible for the grocery stores to go online
and has resulted in growth of e-tailing. Keeping this in mind an online grocery management
system has been developed which has both admin and customer side where customer can
place orders or buy groceries by just a tap in computer or mobiles. It also helps the admin to
keep track of the orders and items made available for users to purchase.

7.2 Future Enhancement

In this project future plans are to improve GUI and add a search tab which allows the users to
easily search for groceries rather than scrolling down in search of items.
We are also planning to planning to add a weekly or monthly tab option which will contain the
groceries required per week or per month, thus allowing the user to order the groceries by just
one click.

Dept of ISE, BIT 2021-2022 P a g e | 83


GROCERY MANAGEMENT SYSTEM 1BI19IS037

REFERENCES
Concepts:

• www.stackoverflow.com
• www.guru99.com
• www.w3schools.com
• www.geeksforgeeks.com
• www.github.com
Books:
• Database System Models, Languages, Ramez Elmasri and Sham Kant B. Navathe, 7th

• Edition, 2017 Pearson.

• Fundamentals of Web Development, Randy Connolly and Ricardo Hoar,


First Impression, 2016 Pearson.

Dept of ISE, BIT 2021-2022 P a g e | 84

You might also like