Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Aswin

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 85

Doners & Food Governance

DONORS & FOOD GOVERNANCE

A PROJECT REPORT

Submitted by

A.ASWIN Register NO :C0S10404

S. MOHAMEDAZARUDEEN Register NO:C0S10407

In partial fulfillment for the award of the degree


Of
BACHELOR OF COMPUTER APPLICATION
In

Madurai Kamaraj University

Under the guidance of

Mr.C.Kondalraj , MCA.,B.Ed.,MPhil.,SET.,

CARDAMOM PLANTERS’ ASSOCIATION COLLEGE


DEPARTMENT OF CS&IT
BODINAYAKKANUR.-625 513

APRIL-2023

Department of CS&IT (SF), C.P.A College Page 1


Doners & Food Governance

CARDAMOM PLANTERS’ ASSOCIATION COLLEGE


DEPARTMENT OF CS&IT
BODINAYAKKANUR ,THENI-625513

BONAFIDE CERTIFICATE
This is to certify that this project entitled “DONORS AND FOOD GOVERNANCE”,is a
bonafide work of A.ASWIN (C0S10404) and S.MOHAMEDAZARUDEEN(C0S10407) who
carried out of the work under my supervision, for the partial fulfillment of the requirements for the
award of the degree of BACHELOR OF COMPUTER APPLICATION of Madurai Kamaraj
University, Madurai during December 2022 to May 2023.

Place: Bodinayakanur ,

Date: ……………….

Head of the Department Internal Guide

Submitted for the viva-voice examination held on ………………………..

Internal Examiner External Examiner

Department of CS&IT (SF), C.P.A College Page 2


Doners & Food Governance

ACKNOWLEDGEMENT

We thank Cardamom Planters’ Association College. Bodinayakanur for having given us an


opportunity to do this course. Our sincere thanks to Principal (in-charge)
Dr.S.SIVAKUMAR,.B.E., M.S, Ph.D. for his wholehearted support in completing our project
work.

Our profound thanks to Mr.K.MOHANKUMARAMANGALAM., M.C.A., M.Sc.,


B.Ed., PGDCA., DCH., DGT., Head of the Department of CS & IT, Cardamom Planters’
Association College, Bodinayakanur, for his encouragement in completing this project in
time.

We express our sincere thanks to our guide Mrs Mr.C.Kondalraj , MCA.,B.Ed.,MPhil.,SET


Associate Professor, of CS & IT, Cardamom Planters’ Association College. His constant source
of inspiration and support encouraged us in the successful completion of this project work in time

We convey our heartfelt thanks to all the faculty members of the Computer Science and
Information technology Department for their help and useful suggestions throughout the
project work.

It is also our duty to express our thanks to all who have directly and indirectly helped us in
completing this project work.

Above all we must thank our parents and almighty God, with their grace anything would have
been possible for us.

A.ASWIN

S.MOHAMEDAZARUDEEN

Department of CS&IT (SF), C.P.A College Page 3


Doners & Food Governance

DECLARATION

I here state the project report entitled “DONORS &FOOD GOVERNANCE”


Submitted by A.ASWIN (C0S10404) and S.MOHAMEDAZARUDEEN(C0S10407)
in fulfillment of the requirements the awards BCA (Bachelor Of Computer
Application) of our own work and due acknowledgement has been made in the text to
all the technical information used.

Date : ………………

Place: Bodinayakanur

Signature of the Students

(A.ASWIN

S.MOHAMEDAZARUDEEN)

BCA (Bachelor of Computer Application),

DEPARTMENT OF CS & IT,

CPA COLLEGE,

BODINAYAKANUR,

THENI Dr -625513

Department of CS&IT (SF), C.P.A College Page 4


Doners & Food Governance

CONTENTS

Page
Sl.No Description No
1 ABSTRACT 7

2 INTRODUCTION 9
1.1 Background
1.2 Objective
3 SYSEM SPECIFICATION 12
2.1 Hardware Specification
2.2 Software Specification
4 SOFTWARE DESCRIPTION 14
3.1 Front end
3.2 Back end
3.3 QR Code
5 SYSTEM ANALYSIS 22
4.1 Problem definition
4.2 Existing system
4.3 Proposed system
4.4 Feasibility Analysis
6 WEB APPLICATION 25
5.1 Web Application
5.2 Web Application Work
7 MODULES 28
6.1 Module list
6.2Module description
8 SYSTEM DESIGN 31
7.1 Architectural Design
7.2 Data flow Diagram
9 System Implementation & Maintenance 38

Department of CS&IT (SF), C.P.A College Page 5


Doners & Food Governance

SYSTEM TESTING 41
10 8.1 Backend testing
8.2 Browser Compatibility Testing
8.3 End-to-End Testing
8.4 Integration Testing
8.5 Graphical User Interface (GUI) Testing
8.6 Performance testing
8.7 Functional testing

11 SOURCE CODE 47
9.1 Sample Code
12 SNAPSHOTS 76

10.1Sample Screens
13 CONCLUSION & FUTURE ENHANCEMENTS 81

11. Conclusion
11.2Future scope
14 APPENDIES 83
12.1 Bibliography
12.2Find food recipient organizations
12.3References

Department of CS&IT (SF), C.P.A College Page 6


Doners & Food Governance

ABSTRACT

Department of CS&IT (SF), C.P.A College Page 7


Doners & Food Governance

1. ABSTRACT

Food wastage is increasingly becoming a topic of concern due primarily to the negative
impact it has on the economic and agricultural industry. Research has shown that in
Finland, households seems to be the highest producers of food waste and some of this, is as
a result of food being disposed because they are expired.
The main objective of this thesis was to provide a viable solution that allows mobile users
to track the life cycle of their food inventory efficiently. This project also provides a demo
of better implementation with future enhancement in food packaging. This project was
developed for the Python platform, using Facebook integration to simplify the user
registration and a web server for storing the information
The mobile application, which acts as the client-side component was developed and built in
the Eclipse software environment using the Python SDK alongside external libraries,
Facebook SDK for Facebook integration and ZBarScannerLibrary to read QR code. The
server-side component was developed using the Notepad++ software for the PHP code and
phpMyAdmin for the database management. The end application is able to register user
with their Facebook account and food entries can be added and deleted both on the mobile
device and the server.

Department of CS&IT (SF), C.P.A College Page 8


Doners & Food Governance

INTRODUCTION

Department of CS&IT (SF), C.P.A College Page 9


Doners & Food Governance

2. INTRODUCTION
The prevalence of food waste has been a subject of interest and discussion in recent years
and researches are being done to find effective ways to curb it. It has been identified as a
primary issue in the sustainability of food production and consumption, in addition to the
sustainability of food supply chains. According to Heta-Kaisa Koivupuro, food waste can
be divided into avoidable and unavoidable waste. Avoidable waste includes edible food and
spoiled/damaged edible food, while unavoidable waste consists of the inedible food like
bones, fruit peels, and egg shells among others.
A research shows that in Finland, 5% of purchased food is wasted in households and
an average person wasted about 20-30 kg of food in a year. The average total amount of
food wasted in households yearly is about 120-160 million kilogrammes./1/ Household
wastage could be intentional or not. Many of the food wastage in household could be as a
result of forgetfulness or negligence for the food expiry date. In countries like Finland with
high cost of living, consumers are inclined to buy food nearing its expiry date due to the
discount shop sellers attach periodically.

1.1 Background

The advancement of technology has brought ease to the stressful life of human beings. The
prevalence of mobile technologies enables us to constantly be in touch with the world. By
it, different aspects of our lives are brought together for easy access. For instance, a person
could be making finishing touches with his presentation for next day, discussing with
his/her spouse about dinner, booking a flight for a weekend trip, to mention a few, all in the
same place and likely simultaneously.
The idea for this project was born with my observation of how easily fellow students
dispose expired food products. Due to the high cost of living, many students tend to buy
food products which are close to their expiry date and sometimes in large quantity due to
their discounted prices, as shops attempt to get as much of these products out of their
inventory to reduce their losses. With the proliferation of smartphones, I thought of the
feasibility of using the smartphone as a lifecycle tracker for our food inventory, and be
regularly informed of those products whose expiry date is close by. It is expected that this
would help to reduce the amount of food spillage in the households.

Department of CS&IT (SF), C.P.A College Page 10


Doners & Food Governance

1.2 Objective

The objective of this project was to create a mobile application to assist users in managing
their food inventory. The application would store and display basic information about the
inventory contents and alerts the user of the food products which are due to expire the next
day. Consequentially, users may take actions to avoid the concerned products get wasted or
spoiled. It is believed that a considerable amount of food waste would be avoided in
households if the occupants are well-informed of the timeline of their food stocks.
Provisions have also been made to allow for the multi-device use. Most food management
applications available are mainly concerned with helping users watch their weight and food
in-take and generally requires lots of information from user. The advantage of this project
is the use of the simplest information of food products to monitor the inventory. With an
eye on the future, a demo solution was integrated to show compatibility with future
advancement in food packaging.

Department of CS&IT (SF), C.P.A College Page 11


Doners & Food Governance

SYSTEM SPECIFICATION

Department of CS&IT (SF), C.P.A College Page 12


Doners & Food Governance

SOFTWARE & HARDWARE REQUIREMENT

2.1 Hardware Requirements:

Hardware is the collection of physical elements that constitutes a computer


system. Computer hardware refers to the physical parts or components of a computer such
as monitor, keyboard, computer data storage etc.
Processor AMD PRO A4-350B R4
RAM 4 GB
Hard disk 450.00 GB
Monitor 17” LCD
Mouse two buttons scroll optical mouse

2.2 Software Requirements:


Software is any set of machine-readable instructions that directs a computer’s processor to
perform
specific operation. Software is usually written in high-level programming languages that are
easier
Operating system Windows 10
IDLE Tool Python 3.11 64 bit Django (framework)
Language Python
Front End HTML
Back End My sql

Department of CS&IT (SF), C.P.A College Page 13


Doners & Food Governance

SOFTWARE DESCRIPTION

Department of CS&IT (SF), C.P.A College Page 14


Doners & Food Governance

SOFTWARE DESCRIPTION

3.1 Front end :

Python :

Python is a high-level, interpreted, interactive and object-oriented scripting


language. Python is designed to be highly readable. It uses English keywords
frequently where as other languages use punctuation, and it has fewer syntactical
constructions than other languages.

Python is Interpreted − Python is processed at runtime by the interpreter. You do not


need to compile your program before executing it. This is similar to PERL and PHP.

Python is Interactive − You can actually sit at a Python prompt and interact with the
interpreter directly to write your programs.

Python is Object-Oriented − Python supports Object-Oriented style or technique of


programming that encapsulates code within objects.

Python is a Beginner's Language − Python is a great language for the beginner-level


programmers and supports the development of a wide range of applications from
simple text processing to WWW browsers to games.

History of Python :

Python was developed by Guido van Rossum in the late eighties and early nineties
at the National Research Institute for Mathematics and Computer Science in the
Netherlands.

Python is derived from many other languages, including ABC, Modula-3, C, C++,
Algol-68, SmallTalk, and Unix shell and other scripting languages.

Department of CS&IT (SF), C.P.A College Page 15


Doners & Food Governance

Python is copyrighted. Like Perl, Python source code is now available under the
GNU General Public License (GPL).

Python is now maintained by a core development team at the institute, although


Guido van Rossum still holds a vital role in directing its progress.

Python Features :

Easy-to-learn − Python has few keywords, simple structure, and a clearly defined
syntax. This allows the student to pick up the language quickly.

Easy-to-read − Python code is more clearly defined and visible to the eyes.

Easy-to-maintain − Python's source code is fairly easy-to-maintain.

A broad standard library − Python's bulk of the library is very portable and cross-
platform compatible on UNIX, Windows, and Macintosh.

Interactive Mode − Python has support for an interactive mode which allows
interactive testing and debugging of snippets of code.

Portable − Python can run on a wide variety of hardware platforms and has the same
interface on all platforms.

Extendable − You can add low-level modules to the Python interpreter. These
modules enable programmers to add to or customize their tools to be more efficient.

Databases − Python provides interfaces to all major commercial databases.

GUI Programming − Python supports GUI applications that can be created and
ported to many system calls, libraries and windows systems, such as Windows MFC,
Macintosh, and the X Window system of Unix.

Scalable − Python provides a better structure and support for large programs than
shell scripting.

Apart from the above-mentioned features, Python has a big list of good features, few
are listed below :

Department of CS&IT (SF), C.P.A College Page 16


Doners & Food Governance

• It supports functional and structured programming methods as well as OOP.


• It can be used as a scripting language or can be compiled to byte-code for
building large applications.

• It provides very high-level dynamic data types and supports dynamic type
checking.
• It supports automatic garbage collection.

Python is available on a wide variety of platforms including Linux and Mac OS X.


Let's understand how to set up our Python environment.

• Unix (Solaris, Linux, FreeBSD, AIX, HP/UX, SunOS, IRIX, etc.)


• Win 9x/NT/2000
• Macintosh (Intel, PPC, 68K)
• OS/2
• DOS (multiple versions)
• PalmOS
• Nokia mobile phones
• Windows CE
• Acorn/RISC OS
• BeOS
• Amiga
• VMS/OpenVMS
• QNX
• VxWorks
• Psion

Python has also been ported to the Java and .NET virtual machines

Department of CS&IT (SF), C.P.A College Page 17


Doners & Food Governance

3.2 Back end :

Server-Side Database:

Systems designers report success using SQLite as a data store on server


applications running in the data canter, or in other words, using SQLite as the
underlying storage engine for an application specific database server.

With this pattern, the overall system is still client/server: clients send requests to
the server and get back replies over the network. But instead of sending generic SQL
and getting back raw table content, the client requests and server responses are high-
level and application-specific. The server translates requests into multiple SQL
queries, gathers the results, does post-processing, filtering, and analvsis, then
constructs a high-level reply containing only the essential information.

Developers report that SQLite is often faster than a client/server SQL database
engine in this scenario. Database requests are serialized by the server, so concurrency
is not an issue. Concurrency is also improved by "database sharing'": using separate
database files for different subdomains. For example, the server might have a
separate SQLite database for each user, so that the server can handle hundreds or
thousands of simultaneous connections, but each SQLite database is only used by one
connection.

Database SQLite3 :

• SQLite Database is an open-source database provided in Android


which is used to store data inside the user's device in the form of a
Text file. We can perform so many operations on this data such as
adding new data, updating, reading, and deleting this data.
• SQLite is an offline database that is locally stored in the user's device
and we do not have to create any connection to connect to this
database.

Department of CS&IT (SF), C.P.A College Page 18


Doners & Food Governance

• Data is stored in the SQLite database in the form of tables. When we


stored this data in our SQLite database it is arranged in the form of
tables that are similar to that of an excel sheet. Below is the
representation of our SQLite database which we are storing in our
SQLite database.

SQLite3 :

When you open a CSV in python, and assign it to a variable name, you are using
your computer's memory to save that variable. Accessing data from a database like
SQL İs not only more efficient, but also it allows you to subset and import only the
parts of the data that you need.Sqlite3 provides a SQL- like interface to read, query,
and write SQL databases from Python. Sqlite3 can be used with Pandas to read SỌL
data to the familiar Pandas Data Frame.

SQLite is a C library that provides a lightweight disk-based database that doesn't


require a separate server process and allows accessing the database using a
nonstandard variant of the SQL query language. Some applications can use SQLite
for internal data storage. It's also possible to prototype an application using SQLite
and then port the code to a larger database such as Post SQL or Oracle.

SQLite Types :

• SQLite natively supports the following types: NULL INTEGER, REAL,


TEXT, BLOB.
• The following Python types can thus be sent to SQLite without any problem:
• This is how SQLite types are converted to Python types by default:

Department of CS&IT (SF), C.P.A College Page 19


Doners & Food Governance

SQLite3 Support :

• As described before, SQLite supports only a limited set of types natively. To


use other Python types with SQLite, you must adapt them to one of the
sqlite3 module's supported types for SQLite: one of None Type, int, float, str,
bytes.
• There are two ways to enable the sqlite3 module to adapt a custom Python
type to one of the supported ones

SQLite Advantages :
• Reading and writing operations are very fast for SQLite database. It is almost
35% faster than File system.
• It only loads the data which is needed, rather than reading the entire file and
hold it in memory.
• If you edit small parts, it only overwrite the parts of the file which was
changed.

SQLite Disadvantages :

• SQLite is used to handle low to medium traffic HTTP requests.


• Database size is restricted to 2GB in most cases.

Date Storage :

The main unit of data storage is a database, whish is a collection of tables with
types columns. SQLite 3 server support different data types, including primary types
such as Integer, Float, Decimal, Char (include characters strings), varchar (variable
length character string), binary (for unstructured blods of data), Text (for textual
data) among other.

Any column in an SQLite version 3 database. except an INTEGER PRIMARY


KEY column, may be used to store a value of any storage class.

Department of CS&IT (SF), C.P.A College Page 20


Doners & Food Governance

All values in SQL statements, whether they are literals embedded in SQL statement
text or parameters bound to precompiled SQL statements have an implicit storage
class. Under circumstances described below, the database engine may convert values
between numeric storage classes (INTEGER and REAL) and TEXT during query
execution.

3.3 Quick Response Code (QR Code)

The QR code is the trademark for a type of two-dimensional bar code. It is an optical
machine-readable label used to store information about the item it is attached to. It was
originally designed for use in the automotive industry by a Toyota subsidiary in Japan, but
has become widely popular for other usages because it is faster to read and have more
storage capacity than standard bar codes.
QR codes are usually used to store contact information, Uniform Resource Locations
(URLs), phone numbers, and text.

Department of CS&IT (SF), C.P.A College Page 21


Doners & Food Governance

SYSTEM ANALYSIS

Department of CS&IT (SF), C.P.A College Page 22


Doners & Food Governance

SYSTEM ANALYSIS

4.1 PROBLEM DEFINITION

By creating an online medical shop, the project aims to solve these


problems by providing a convenient and accessible platform for customers to purchase the
medical products they need. The website can also offer features such as product
recommendations, detailed product information, and user reviews to help customers make
informed purchasing decisions. Additionally, the project can help streamline the medical
supply chain by connecting customers with suppliers and distributors, potentially reducing
costs and improving availability

4.2 EXISTING SYSTEM

The existing system for purchasing medical supplies and products typically
involves visiting physical stores or pharmacies to make purchases. This can be
inconvenient for people with mobility issues, those who live far from medical supply
stores, or those who require specific products that may not be available locally. In some
cases, people may resort to purchasing counterfeit or substandard products online, which
can be dangerous and potentially life-threatening

4.3 PROPOSED SYSTEM

the proposed system could include features like prescription upload, chatbot for customer
support, and integration with healthcare providers to offer a comprehensive and seamless
experience for customers. Overall, the proposed system aims to provide a convenient and
reliable platform for customers to purchase medical supplies and products, while also

streamlining the medical supply chain and potentially reducing costs for both customers
and suppliers.

Department of CS&IT (SF), C.P.A College Page 23


Doners & Food Governance

4.4 FEASIBILITY STUDY

A feasibility study for an online medical shop project using HTML and PHP would
typically involve analyzing the technical, economic, and operational viability of the project.
Here are some factors that could be considered.
• Technical Feasibility

• Economic Feasibility

• Scheduled Feasibility

TECHNICAL FEASIBILITY

Technical This would involve assessing whether the technology required to create the
website, including web development tools, hosting, and payment gateway integration, is
readily available and whether the project can be completed within the given timeline

ECONOMIC FEASIBILITY

This would involve analyzing the financial viability of the project, including the initial
investment required, ongoing operating costs, revenue projections, and potential
profitability.

SCHEDULED FEASIBILITY

This would involve assessing whether the project can be integrated into the existing
medical supply chain and whether the website can effectively manage and fulfill orders,
provide customer support, and ensure timely delivery.

Department of CS&IT (SF), C.P.A College Page 24


Doners & Food Governance

WEB APPLICATION

Department of CS&IT (SF), C.P.A College Page 25


Doners & Food Governance

WEB APPLICATION

5.1Web Application

Online systems are systems where the input data enter the computer directly from
the point of origin (usually a terminal or workstation) and/or in which output data are
transmitted directly to that terminal point of origin. (Sippl, Computer Dictionary, 4th
ed). Web application is an application software or a computer program that runs on a
web server and performs tasks over the internet. They are accessed by the users
through a web browser such as Google chrome or Firefox with an active internet
connection. They are programmed using a client- server based structure. Commonly
used web applications include:
Gmail and Google map.

5.2Web Application Work

Web applications are normally coded in many browser-supported languages such


as python, JavaScript, PHP and Perl. Because these languages rely on the browser to
make the program executable. These applications are divided into two types:
dynamic which requires server-side processing and the static without requirement of
server for processing. Web application needs a web server to manage clients’
requests. A web server is a software and hardware that uses or understands a uniform
resource locator (web addresses) and Hypertext Transfer protocol to respond to client
requests made over the World Wide Web (www). The main role of a web server is to
store database information, processing data and delivering web pages to users
through displaying website content.

Department of CS&IT (SF), C.P.A College Page 26


Doners & Food Governance

1. Users access a web application through either a web browser or a mobile


application by making a request to the web server over the Internet.

2. The web server forwards the user’s request to the web application server. The web
application server is to perform the user’s request task such as processing the data
and then generates the output of the requested data

3. The web application server forwards the results back to the web server.

4. The web server delivers the requested data or information to the appropriate client
and appears on its display.

Figure : Web application architecture

Department of CS&IT (SF), C.P.A College Page 27


Doners & Food Governance

MODULE LIST & MODULE


DESCRIPTION

Department of CS&IT (SF), C.P.A College Page 28


Doners & Food Governance

MODULE LIST & MODULE DESCRIPTION

6.1 Modules :

➣Home
 Daily Reports
➣Login
 Customers
 Donor’s - About Details
 ⋆Mahal - About Details
 ⋆Hotels & Restaurant- About Details
 ⋆Other’s - About Details
➣Register

➣ Dashboard
 Post-Category-Prize-Teste-Persons-Likes-Actions
➣Profile

➣Create Post
 Feed Back

6.2 Module Description :

Department of CS&IT (SF), C.P.A College Page 29


Doners & Food Governance

Home Page:

A home page is the primary web page that a visitor will view when they navigate to
a website via a search engine, and it may also function as a landing page to attract visitors.
In some cases, the home page is a site directory, particularly when a website has multiple
home pages

Login Page :

The user enter the user interface.

Customer:

A community interface through which the company could ask its customer base
about product innovation, messaging, and anything else relevant to how the customer
consumes its products and services. (Donor’s-Mahal-Hotels&Restaurent-Others)

Register
Holds all the information related to registrations

Dashboard

The dashboard allows admin to quickly see the health of their whole system.

Profile

The Profile module provides the profile entity type used to collect customer
information.

Create Post

click the add module icon and select the post content module from the list.

Department of CS&IT (SF), C.P.A College Page 30


Doners & Food Governance

SYSTEM DESIGN

Department of CS&IT (SF), C.P.A College Page 31


Doners & Food Governance

SYSTEM DESIGN

7.1 System Design :

Systems design is the process of defining the armature, modules, interfaces, and
data for a system to satisfy specified conditions. Systems design could be seen as the
operation of systems proposition to product development. There's some imbrication
with the disciplines of systems analysis, systems armature, and systems engineering.

7.2 Research Design :

Research design describes the plan that the investigator will take over to develop
the ways of working problems and give guidance in a colorful way of bearing the
exploration. This study uses descriptive exploration design because it's interested in
describing the satisfaction as it exists during the time of study without making
manipulations. It provides the experimenter with an occasion to gain deeper
perceptivity into the subject matter under study. Robson( 2002) points out that a
descriptive study portrays an accurate profile of persons, events, or situations.
Chandran( 2004) also states descriptive study describes the being conditions and
stations through observation and interpretation ways. In the present study, this design
is the most preferable because it helps to consolidate understanding of the current
situation as it exists. It enables the carrying of both quantitative and qualitative data
for the study because of the application of questionnaires and the interview
attendants.

Department of CS&IT (SF), C.P.A College Page 32


Doners & Food Governance

Figure : Use Case Diagram

Figure Use case for client-side application

Department of CS&IT (SF), C.P.A College Page 33


Doners & Food Governance

DATA FLOW DIAGRAM

Department of CS&IT (SF), C.P.A College Page 34


Doners & Food Governance

8.1 Definition of data flow diagram

The DFD takes an input-process-output view of a system i.e. data objects flow into the
software, are transformed by processing elements and resultant data objects flow out of the
software. Data objects represented by labeled arrows and transformations are represented
by circles also called as bubbles. DFD is presented in a hierarchical fashion
i.e. the first data flow model represents the system as a whole. Subsequent DFD refine the
context diagram (level 0 DFD), providing increasing details with each subsequent level.
The DFD enables the software engineer to develop models of the information domain and
functional domain at the same time. As the DFD is refined into greater levels of details, the
analyst performs an implicit functional decomposition of the system. At the same time.
DFD refinement results in a corresponding refinement of the data as it moves through the
process that embody the application. A context-level DFD for the system the primary
external entities produce information for use by the system and consume information
generated by the system. The labeled arrows represents data objects or data hierarchy.

Data flow diagram

8.1 Zero Level DFD – Courier Management System :

Department of CS&IT (SF), C.P.A College Page 35


Doners & Food Governance

8.2 First Level DFD – Courier Management System :

8.3 overview of the waste categorisation used and the:

Department of CS&IT (SF), C.P.A College Page 36


Doners & Food Governance

8.4 Project Architectural Flow

8.5 Project Result Flow

Department of CS&IT (SF), C.P.A College Page 37


Doners & Food Governance

SYSTEM IMPLEMENTATION
& MAINTENANCE

Department of CS&IT (SF), C.P.A College Page 38


Doners & Food Governance

SYSTEM IMPLEMENTATION & MAINTENANCE

9.1 Implementation :

This phase related to installing the software on the client side. The various
procedure are involved for implementing a software which include giving
documentation of the software to the client which consist of basic as well as technical
part. It also includes giving proper training sessions and presentations to the client
regarding the working of the software. It also includes checking of various hardware
resources available with the client and making sure the software is running properly
on this machine.

9.2 Maintenance :

In this phase the programmer or some other technical employers of the company,
which is developing the software in order to manage the hanging requirements of the
client from time to time, do review. If there is any failure in the software or the client
is nit able to access the database then the same is intimated to the developer who has
to take care of it within the certain amount of time.

The table below highlights the attributes of the model.

Table 1.Description of Food model attributes

Attribute Description
Name Name of the food to be stored.
Expiry Date Best-before date of the food product
Entry Date Date of entry of food information
Reminder Time chosen by user to be reminded a day before expiry date

Department of CS&IT (SF), C.P.A College Page 39


Doners & Food Governance

Figure .Overview of project structure in Eclipse

Department of CS&IT (SF), C.P.A College Page 40


Doners & Food Governance

Figure: Overview of the Python

SYSTEM TESTING

Department of CS&IT (SF), C.P.A College Page 41


Doners & Food Governance

SYSTEM TESTING

10.1 Types Of System Testing :

There are different types of system testing techniques which include: unit testing,
Integration testing, System testing, sanity testing, smoke testing, Interface testing,
regression testing, and beta/acceptance testing only to mention a few. (Software
Testing Help, 2023)
For the purpose of this project I conducted the following types of test:

a) Backend testing

b) Browser Compatibility Testing

c) End-to-End Testing

d) Integration Testing

e) Graphical User Interface (GUI) Testing

f) Performance testing

g) Functional testing

10.2 Back-End Testing :

It is used to test the functionality and workability of the back-end system.


Whenever an input or data is entered on front-end application, it stores in the
database and the testing of such database is known as Database Testing or Backend
testing. There are different databases like SQL Server, MySQL, and Oracle etc.
Database testing involves testing of table Structure, schema, stored procedure, data

Department of CS&IT (SF), C.P.A College Page 42


Doners & Food Governance

structure and so on. In back-end testing GUI is not involved, testers are directly
connected to the database with proper access and testers can easily verify data by
running a few queries on the database. There can be issues identified like data loss,
deadlock, data corruption etc. during this back-end testing and these issues are
critical to fixing before the system goes live into the production environment.
(Software Testing Help, 2023)

10.3 Test conducted :

I was able to test all the tables in database rms and multi_login and all the tables
and no issues were identified that is no data loss, no deadlock or data corruption.

10.4 Browser Compatibility Testing :

It is a subtype of Compatibility Testing (which is explained below) and is


performed by the testing team.Browser Compatibility Testing is performed for web
applications and it ensures that the software can run with the combination of different
browser and operating system. This type of testing also validates whether web
application runs on all versions of all browsers or not. (Software Testing Help, 2023)

10.5 Test Conducted :

I tested the system with Microsoft edge, Chrome, work stream browser and opera.
In all the browsers the system was operational, however on other browser the system
was slower to launch such as Microsoft edge which took 100 seconds as opposed to
the rest which ranged from 40 seconds to 55seconds.

10.6 End-to-End Testing :

Similar to system testing, End-to-end testing involves testing of a complete


application environment in a situation that mimics real-world use, such as interacting

Department of CS&IT (SF), C.P.A College Page 43


Doners & Food Governance

with a database, using network communications, or interacting with other hardware,


applications, or systems if appropriate.
In a mimic of the real world the system worked perfectly no matter
the number of users logged in to the system. (Software Testing Help, 2023)

10.7 Integration Testing :

Testing of all integrated modules to verify the combined functionality after


integration is termed as Integration Testing. Modules are typically code modules,
individual applications, client and server applications on a network, etc. This type of
testing is especially relevant to client/server and distributed systems

10.8 Tests conducted :

I was able to test all components of the courier management system.


The first test I conducted was registering a user as a normal user and an
administrator user, thereafter I logged in into the system. Once a registration was
made it reflected in the database and in the back-end where the administrator can add
or remove a user or upgrade a user. The second test conducted, I simulated sending a
parcel and the changing the status to see if ut will reflect to the database and it
happened as expected.

10.9 Graphical User Interface (GUI) Testing :

The objective of this GUI testing is to validate the GUI as per the business
requirement. The expected GUI of the application is mentioned in the Detailed
Design Document and GUI mockup screens.The GUI testing includes the size of the
buttons and input field present on the screen, alignment of all Text, tables and
content in the tables. It also validates the workability of the application, after
selecting different side menus and changing different names, it validates that the page

Department of CS&IT (SF), C.P.A College Page 44


Doners & Food Governance

does not fluctuate and the alignment remains same after moving from one module to
another. (Software Testing Help, 2023)

10.10 Test conducted :

I was able to test the system on different devices such as a laptop, computer,
smart-phone and large-screen smart phone in all instance the system function
properly and the buttons and screens adapted according to size of the screen and I
was easy for users to use on the different devices.

10.11 Functional Testing :

This is where a select group of the target population will test the system to
ascertain the functional requirements are attained.

10.12 Performance Testing :

The various non-functional requirements as contained on the business requirements


document will be tested by the team piloting the system. In particular, the system will
under stress testing to see whether it can handle errors. Since the time is
limited,complete performance, testing will only be possible once the system is
published and starts being used by residents.

Department of CS&IT (SF), C.P.A College Page 45


Doners & Food Governance

SAMPLE CODE

Department of CS&IT (SF), C.P.A College Page 46


Doners & Food Governance

SAMPLE CODE

11.1SOURCE CODE

A set of instructions/ commands and statements which is written by a programmer by using


a computer programming language. Like C, C++ assembly language etc. So statements
written in any programming language is termed as source code

MANAGE

#!/usr/bin/env python
import os
import sys

if __name__ == '__main__':
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'FoodBank.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)

ACCOUNT

Admne

Department of CS&IT (SF), C.P.A College Page 47


Doners & Food Governance

from django.contrib import admin


from .models import Profile

admin.site.register(Profile)

Apps
from django.apps import AppConfig
class AccountsConfig(AppConfig):
name = 'accounts'

Forms
from django import forms
from .models import Profile
from django.contrib.auth.forms import UserCreationForm, UserChangeForm
from django.contrib.auth.models import User

class RegisterForm(UserCreationForm):
username = forms.CharField(widget=forms.TextInput(attrs={'class':'form-
control','placeholder':'Enter your username'}),
help_text="<small>Required. 150 characters or fewer. Letters, digits
and @/./+/-/_ only.</small>")
email = forms.EmailField(widget=forms.EmailInput(attrs={'class': 'form-
control','placeholder':'Enter your Email Address'}))
first_name = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control',
'placeholder': 'Enter your First Name'}))
last_name = forms.CharField(widget=forms.TextInput(
attrs={'class': 'form-control', 'placeholder': 'Enter your Last Name'}))
password1 =
forms.CharField(label="Password",widget=forms.PasswordInput(attrs={'class':'form-
control'}),
help_text="<small><ul><li>Your password can't be too similar to
your other personal information.</li>\
<li>Your password must contain at least 8 characters.</li>\
<li>Your password can't be a commonly used password.</li>\
<li>Your password can't be entirely numeric.</li></ul></small>")

Department of CS&IT (SF), C.P.A College Page 48


Doners & Food Governance

password2 = forms.CharField(label="Password confirmation",


widget=forms.PasswordInput(attrs={'class': 'form-control'}),\

help_text="<small>Enter the same password as before, for verification.</small>")


class Meta:
model = User
fields=['username','email','first_name','last_name','password1', 'password2',]

Models
from django.db import models
from django.contrib.auth.models import User
from django.db.models.signals import post_save
from django.dispatch import receiver

class Profile(models.Model):
user = models.OneToOneField(User,on_delete=models.CASCADE)
image = models.ImageField(upload_to='profiles',default='profiles/default.jpg')

def __str__(self):
return self.user.username

@receiver(post_save, sender=User)
def user_created(sender, instance, created, *args, **kwargs):
if created:
Profile.objects.create(user=instance)
else:
instance.profile.save()

tests
from django.test import TestCase

# Create your tests here.

Department of CS&IT (SF), C.P.A College Page 49


Doners & Food Governance

Urls

from django.urls import path


from django.contrib.auth.views import LoginView, PasswordResetView,
PasswordResetDoneView,\
PasswordResetConfirmView, PasswordResetCompleteView
from .views import LogoutView, RegisterView, ProfileView, ImageUpdateView

urlpatterns = [
path('login/', LoginView.as_view(), name='login'),
path('logout/', LogoutView.as_view(), name='logout'),
path('register/', RegisterView.as_view(), name='register'),
path('password_reset/', PasswordResetView.as_view(), name='password_reset'),
path('password_reset/done/', PasswordResetDoneView.as_view(),
name='password_reset_done'),
path('password_reset/confirm/<uidb64>/<token>/',
PasswordResetConfirmView.as_view(), name='password_reset_confirm'),
path('password_reset/complete/', PasswordResetCompleteView.as_view(),
name='password_reset_complete'),
path('profile/<int:pk>/', ProfileView.as_view(), name='profile'),
path('profile/picture/', ImageUpdateView.as_view(), name='update_image'),
]

Views

from django.shortcuts import render, redirect, get_object_or_404


from django.views.generic import View, TemplateView, CreateView, UpdateView
from django.contrib.auth import logout
from .forms import RegisterForm
from django.urls import reverse_lazy
from django.contrib.auth.models import User

Department of CS&IT (SF), C.P.A College Page 50


Doners & Food Governance

from django.contrib.auth.mixins import LoginRequiredMixin


from .models import Profile

from django.contrib.messages.views import SuccessMessageMixin

class LogoutView(View):
def get(self, request, *args, **kwargs):
logout(request)
return redirect('home')

class RegisterView(SuccessMessageMixin, CreateView):


template_name = 'registration/register.html'
form_class = RegisterForm
success_message = "Account Created Successfully"
success_url = reverse_lazy('login')

class ProfileView(LoginRequiredMixin, SuccessMessageMixin, UpdateView):


form_class = RegisterForm
template_name = 'registration/profile.html'
queryset = User.objects.all()
success_url = reverse_lazy('my_posts')
success_message = "Profile Updated Successfully"

class ImageUpdateView(LoginRequiredMixin, TemplateView):


template_name = 'registration/profile_picture.html'

def post(self, request, *args, **kwargs):


img = request.FILES.get('image')
user = get_object_or_404(User, username=request.user.username)

Department of CS&IT (SF), C.P.A College Page 51


Doners & Food Governance

user.profile.image = img
user.save()

return redirect('profile', request.user.id)

MIGRATIONS
0001_initial
# Generated by Django 2.1.7 on 2019-03-10 16:53

from django.conf import settings


from django.db import migrations, models
import django.db.models.deletion

class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Profile',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False,
verbose_name='ID')),
('image', models.ImageField(default='profiles/default.jpg', upload_to='profiles')),
('user',
models.OneToOneField(on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL)),
],
),

Department of CS&IT (SF), C.P.A College Page 52


Doners & Food Governance

FOODBANK
Settings
"""
Django settings for FoodBank project.

Generated by 'django-admin startproject' using Django 2.1.7.

For more information on this file, see


https://docs.djangoproject.com/en/2.1/topics/settings/

For the full list of settings and their values, see


https://docs.djangoproject.com/en/2.1/ref/settings/
"""

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__)))

# Quick-start development settings - unsuitable for production


# See https://docs.djangoproject.com/en/2.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!


SECRET_KEY = 'p#xylf*v67dvw^1k#yv@ie!xlzdqo8$1j96$4hmk2#@q*#w6yc'

# SECURITY WARNING: don't run with debug turned on in production!


DEBUG = True

ALLOWED_HOSTS = []

Department of CS&IT (SF), C.P.A College Page 53


Doners & Food Governance

# Application definition

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.humanize',
'restaurants.apps.RestaurantsConfig',
'accounts.apps.AccountsConfig',
]

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',
]

ROOT_URLCONF = 'FoodBank.urls'

TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],

Department of CS&IT (SF), C.P.A College Page 54


Doners & Food Governance

'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',
'restaurants.context_processor.categories',
'restaurants.context_processor.user_liked_posts',
'restaurants.context_processor.recent_posts',

],
},
},]

WSGI_APPLICATION = 'FoodBank.wsgi.application'

# Database
# https://docs.djangoproject.com/en/2.1/ref/settings/#databases

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}

# Password validation
# https://docs.djangoproject.com/en/2.1/ref/settings/#auth-password-validators

Department of CS&IT (SF), C.P.A College Page 55


Doners & Food Governance

AUTH_PASSWORD_VALIDATORS = [
{

'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
},
{
'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
},
]

# Internationalization
# https://docs.djangoproject.com/en/2.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

# Static files (CSS, JavaScript, Images)


# https://docs.djangoproject.com/en/2.1/howto/static-files/

Department of CS&IT (SF), C.P.A College Page 56


Doners & Food Governance

STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')


MEDIA_URL = '/media/'

LOGIN_REDIRECT_URL = 'my_posts'

# Email configuration
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = 'Your email'
EMAIL_HOST_PASSWORD = 'your email password'

Urls
from django.conf import settings
from django.conf.urls.static import static
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
path('admin/', admin.site.urls),
path('', include('restaurants.urls')),
path('accounts/', include('accounts.urls')),

Department of CS&IT (SF), C.P.A College Page 57


Doners & Food Governance

if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)

Wsgi
"""
WSGI config for FoodBank project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see


https://docs.djangoproject.com/en/2.1/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'FoodBank.settings')

application = get_wsgi_application()

RESTAURANTS
Admin
from django.contrib import admin

Department of CS&IT (SF), C.P.A College Page 58


Doners & Food Governance

from .models import Restaurant, Comment

@admin.register(Restaurant)
class RestaurantAdmin(admin.ModelAdmin):
list_display = ['title', 'categories', 'user',
'location', 'price', 'taste', 'persons', ]
search_fields = ['title']
list_filter = ['user', 'created_at']
list_per_page = 20
date_hierarchy = 'created_at'

@admin.register(Comment)
class CommentAdmin(admin.ModelAdmin):
list_display = ['__str__', 'user', 'created_at']
search_fields = ['text']
list_per_page = 20
date_hierarchy = 'created_at'

Apps
from django.apps import AppConfig

class RestaurantsConfig(AppConfig):
name = 'restaurants'

Context_processor

from django.shortcuts import get_object_or_404


from restaurants.models import Restaurant

Department of CS&IT (SF), C.P.A College Page 59


Doners & Food Governance

def categories(request):

cat_list = []
all_cat = Restaurant.objects.all()
for cat in all_cat:
name_list = cat.categories.split(',')
for item in name_list:
cat_list.append(item)
cat_dict = {'categories': set(cat_list)}
return cat_dict

def user_liked_posts(request):
if request.user.is_authenticated:
posts = Restaurant.objects.filter(likes=request.user.id)
return {'user_liked_posts': posts}
else:
return {'user_liked_posts': None}

def recent_posts(request):
posts = Restaurant.objects.all().order_by('-created_at')[:5]
return {'recent_posts': posts}

Forms
from django import forms
from .models import Restaurant,Comment
from .snippets import choices

class RestaurantCreateForm(forms.ModelForm):
title = forms.CharField(widget=forms.TextInput(attrs={'class':'form-
control','placeholder': 'Enter title'}))
categories = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control',
'placeholder': 'Categories separated by comma. Example: chinese,thai'}))
image = forms.ImageField(widget=forms.FileInput(attrs={'class': 'form-control-file'}))

Department of CS&IT (SF), C.P.A College Page 60


Doners & Food Governance

location = forms.CharField(widget=forms.TextInput(
attrs={'class': 'form-control', 'placeholder': 'Enter Location'}))

price = forms.IntegerField(widget=forms.NumberInput(
attrs={'class': 'form-control', 'placeholder': 'Enter Price'}))
vat = forms.IntegerField(widget=forms.NumberInput(attrs={'class': 'form-
control','placeholder':'Vat in %'}))
taste = forms.ChoiceField(widget=forms.Select(attrs={'class': 'form-
control'}),choices=choices)
persons = forms.ChoiceField(widget=forms.Select(
attrs={'class': 'form-control'}), choices=choices)
details = forms.CharField(widget=forms.Textarea(attrs={'class': 'form-control'}))

class Meta:
model = Restaurant
fields = ['title','image','categories','location','price','vat','taste','persons','details']

Models
from django import forms
from .models import Restaurant,Comment
from .snippets import choices

class RestaurantCreateForm(forms.ModelForm):
title = forms.CharField(widget=forms.TextInput(attrs={'class':'form-
control','placeholder': 'Enter title'}))
categories = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control',
'placeholder': 'Categories separated by comma. Example: chinese,thai'}))
image = forms.ImageField(widget=forms.FileInput(attrs={'class': 'form-control-file'}))
location = forms.CharField(widget=forms.TextInput(
attrs={'class': 'form-control', 'placeholder': 'Enter Location'}))
price = forms.IntegerField(widget=forms.NumberInput(
attrs={'class': 'form-control', 'placeholder': 'Enter Price'}))
vat = forms.IntegerField(widget=forms.NumberInput(attrs={'class': 'form-
control','placeholder':'Vat in %'}))

Department of CS&IT (SF), C.P.A College Page 61


Doners & Food Governance

taste = forms.ChoiceField(widget=forms.Select(attrs={'class': 'form-


control'}),choices=choices)
persons = forms.ChoiceField(widget=forms.Select(

attrs={'class': 'form-control'}), choices=choices)


details = forms.CharField(widget=forms.Textarea(attrs={'class': 'form-control'}))

class Meta:
model = Restaurant
fields = ['title','image','categories','location','price','vat','taste','persons','details']

from django import forms


from .models import Restaurant,Comment
from .snippets import choices

class RestaurantCreateForm(forms.ModelForm):
title = forms.CharField(widget=forms.TextInput(attrs={'class':'form-
control','placeholder': 'Enter title'}))
categories = forms.CharField(widget=forms.TextInput(attrs={'class': 'form-control',
'placeholder': 'Categories separated by comma. Example: chinese,thai'}))
image = forms.ImageField(widget=forms.FileInput(attrs={'class': 'form-control-file'}))
location = forms.CharField(widget=forms.TextInput(
attrs={'class': 'form-control', 'placeholder': 'Enter Location'}))
price = forms.IntegerField(widget=forms.NumberInput(
attrs={'class': 'form-control', 'placeholder': 'Enter Price'}))
vat = forms.IntegerField(widget=forms.NumberInput(attrs={'class': 'form-
control','placeholder':'Vat in %'}))
taste = forms.ChoiceField(widget=forms.Select(attrs={'class': 'form-
control'}),choices=choices)
persons = forms.ChoiceField(widget=forms.Select(
attrs={'class': 'form-control'}), choices=choices)
details = forms.CharField(widget=forms.Textarea(attrs={'class': 'form-control'}))

class Meta:
model = Restaurant

Department of CS&IT (SF), C.P.A College Page 62


Doners & Food Governance

fields = ['title','image','categories','location','price','vat','taste','persons','details']

Snippets
from django.utils.text import slugify

choices = (
(1, 'One'),
(2, 'Two'),
(3, 'Three'),
(4, 'Four'),
(5, 'Five'),
(6, 'Six'),
(7, 'Seven'),
(8, 'Eight'),
(9, 'Nine'),
(10, 'Ten'),
)

def generate_unique_slug(klass, field):


"""
return unique slug if origin slug is exist.
eg: `foo-bar` => `foo-bar-1`

:param `klass` is Class model.


:param `field` is specific field for title.
"""
origin_slug = slugify(field)
unique_slug = origin_slug
numb = 1
while klass.objects.filter(slug=unique_slug).exists():
unique_slug = '%s-%d' % (origin_slug, numb)
numb += 1

Department of CS&IT (SF), C.P.A College Page 63


Doners & Food Governance

return unique_slug

Tests
from django.test import TestCase

# Create your tests here.

Urls
from django.urls import path
from .views import RestaurantListView, RestaurantDetailView,\
RestaurantCreateView, RestaurantUpdateView, RestaurantDeleteView,\
MyPostView

urlpatterns = [
path('', RestaurantListView.as_view(), name='home'),
path('create/', RestaurantCreateView.as_view(), name='create'),
path('<slug:slug>/', RestaurantDetailView.as_view(), name='detail'),
path('<slug:slug>/update', RestaurantUpdateView.as_view(), name='update'),
path('<slug:slug>/delete', RestaurantDeleteView.as_view(), name='delete'),
path('dashboard/myposts/', MyPostView.as_view(), name='my_posts'),
]

Views
from django.shortcuts import render, get_object_or_404, redirect
from django.views.generic import ListView, DetailView, CreateView, UpdateView,
DeleteView
from .forms import RestaurantCreateForm
from django.utils.decorators import method_decorator
from django.urls import reverse_lazy
from django.db.models import Q
from django.contrib.auth.decorators import login_required
from .models import Restaurant, Comment

Department of CS&IT (SF), C.P.A College Page 64


Doners & Food Governance

from django.contrib.auth.mixins import LoginRequiredMixin


from django.contrib.messages.views import SuccessMessageMixin

from django.contrib import messages

class RestaurantListView(ListView):
queryset = Restaurant.objects.all()
paginate_by = 6
template_name = 'restaurants/restaurant_list.html'

def get_queryset(self):
queryset = super().get_queryset()
q = self.request.GET.get('q')
cat = self.request.GET.get('cat')
author = self.request.GET.get('author')
if q:
queryset = queryset.filter(
Q(title__icontains=q) |
Q(details__icontains=q)
).distinct()
if cat:
queryset = queryset.filter(categories__icontains=cat)

if author:
queryset = queryset.filter(user__username=author)
return queryset

@method_decorator(login_required)
def post(self, request, *args, **kwargs):
post_id = request.POST.get('unlike')
post_id2 = request.POST.get('like')
if post_id is not None:

Department of CS&IT (SF), C.P.A College Page 65


Doners & Food Governance

post = get_object_or_404(Restaurant, id=post_id)


post.likes.remove(request.user)

if post_id2 is not None:


post_id2 = request.POST.get('like')
post = get_object_or_404(Restaurant, id=post_id2)
post.likes.add(request.user)
return redirect('home')

class RestaurantDetailView(DetailView):
queryset = Restaurant.objects.all()

@method_decorator(login_required)
def post(self, request, *args, **kwargs):
comment = request.POST.get('comment')
c_slug = request.POST.get('slug')
if comment:
if c_slug:
post = get_object_or_404(Restaurant, slug=c_slug)
comment = Comment.objects.create(
user=request.user, post=post, text=comment)
comment.save()
return redirect('detail', c_slug)
return redirect('detail', c_slug)

class RestaurantCreateView(LoginRequiredMixin, SuccessMessageMixin, CreateView):


template_name = 'restaurants/restaurant_form.html'
form_class = RestaurantCreateForm
success_url = reverse_lazy('my_posts')
success_message = "Post Created Successfully"

Department of CS&IT (SF), C.P.A College Page 66


Doners & Food Governance

def form_valid(self, form):


instance = form.save(commit=False)

instance.user = self.request.user
return super().form_valid(form)

class RestaurantUpdateView(LoginRequiredMixin, SuccessMessageMixin, UpdateView):


form_class = RestaurantCreateForm
template_name = 'restaurants/restaurant_form.html'
success_url = reverse_lazy('my_posts')
success_message = "Post Updated Successfully"

def get_queryset(self):
return Restaurant.objects.filter(user=self.request.user)

class RestaurantDeleteView(LoginRequiredMixin, SuccessMessageMixin, DeleteView):


success_url = reverse_lazy('my_posts')
success_message = "Post Deleted Successfully"

def delete(self, request, *args, **kwargs):


messages.success(self.request, self.success_message)
return super().delete(request, *args, **kwargs)

def get_queryset(self):
return Restaurant.objects.filter(user=self.request.user)

class MyPostView(LoginRequiredMixin, ListView):


template_name = 'restaurants/my_posts.html'

def get_queryset(self):

Department of CS&IT (SF), C.P.A College Page 67


Doners & Food Governance

return Restaurant.objects.filter(user=self.request.user)

Views

from django.shortcuts import render, get_object_or_404, redirect


from django.views.generic import ListView, DetailView, CreateView, UpdateView,
DeleteView
from .forms import RestaurantCreateForm
from django.utils.decorators import method_decorator
from django.urls import reverse_lazy
from django.db.models import Q
from django.contrib.auth.decorators import login_required
from .models import Restaurant, Comment
from django.contrib.auth.mixins import LoginRequiredMixin
from django.contrib.messages.views import SuccessMessageMixin
from django.contrib import messages

class RestaurantListView(ListView):
queryset = Restaurant.objects.all()
paginate_by = 6
template_name = 'restaurants/restaurant_list.html'

def get_queryset(self):
queryset = super().get_queryset()
q = self.request.GET.get('q')
cat = self.request.GET.get('cat')
author = self.request.GET.get('author')
if q:
queryset = queryset.filter(
Q(title__icontains=q) |
Q(details__icontains=q)

Department of CS&IT (SF), C.P.A College Page 68


Doners & Food Governance

).distinct()
if cat:

queryset = queryset.filter(categories__icontains=cat)

if author:
queryset = queryset.filter(user__username=author)
return queryset

@method_decorator(login_required)
def post(self, request, *args, **kwargs):
post_id = request.POST.get('unlike')
post_id2 = request.POST.get('like')
if post_id is not None:
post = get_object_or_404(Restaurant, id=post_id)
post.likes.remove(request.user)
if post_id2 is not None:
post_id2 = request.POST.get('like')
post = get_object_or_404(Restaurant, id=post_id2)
post.likes.add(request.user)
return redirect('home')

class RestaurantDetailView(DetailView):
queryset = Restaurant.objects.all()

@method_decorator(login_required)
def post(self, request, *args, **kwargs):
comment = request.POST.get('comment')
c_slug = request.POST.get('slug')
if comment:
if c_slug:
post = get_object_or_404(Restaurant, slug=c_slug)

Department of CS&IT (SF), C.P.A College Page 69


Doners & Food Governance

comment = Comment.objects.create(
user=request.user, post=post, text=comment)

comment.save()
return redirect('detail', c_slug)
return redirect('detail', c_slug)

class RestaurantCreateView(LoginRequiredMixin, SuccessMessageMixin, CreateView):


template_name = 'restaurants/restaurant_form.html'
form_class = RestaurantCreateForm
success_url = reverse_lazy('my_posts')
success_message = "Post Created Successfully"

def form_valid(self, form):


instance = form.save(commit=False)
instance.user = self.request.user
return super().form_valid(form)

class RestaurantUpdateView(LoginRequiredMixin, SuccessMessageMixin, UpdateView):


form_class = RestaurantCreateForm
template_name = 'restaurants/restaurant_form.html'
success_url = reverse_lazy('my_posts')
success_message = "Post Updated Successfully"

def get_queryset(self):
return Restaurant.objects.filter(user=self.request.user)

class RestaurantDeleteView(LoginRequiredMixin, SuccessMessageMixin, DeleteView):


success_url = reverse_lazy('my_posts')
success_message = "Post Deleted Successfully"

Department of CS&IT (SF), C.P.A College Page 70


Doners & Food Governance

def delete(self, request, *args, **kwargs):

messages.success(self.request, self.success_message)
return super().delete(request, *args, **kwargs)

def get_queryset(self):
return Restaurant.objects.filter(user=self.request.user)

class MyPostView(LoginRequiredMixin, ListView):


template_name = 'restaurants/my_posts.html'

def get_queryset(self):
return Restaurant.objects.filter(user=self.request.user)

MIGRATIONS
0001_initial

# Generated by Django 2.1.7 on 2019-03-07 18:07

from django.conf import settings


from django.db import migrations, models
import django.db.models.deletion

class Migration(migrations.Migration):

initial = True

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]

operations = [
migrations.CreateModel(
name='Category',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID')),

Department of CS&IT (SF), C.P.A College Page 71


Doners & Food Governance

('name', models.CharField(help_text='Separate Category by Comma',


max_length=200)),
],

options={
'verbose_name_plural': 'Categories',
},
),
migrations.CreateModel(
name='Comment',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID')),
('text', models.TextField(max_length=500)),
('created_at', models.DateTimeField(auto_now_add=True)),
],
),
migrations.CreateModel(
name='Like',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID')),
],
),
migrations.CreateModel(
name='Restaurant',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID')),
('title', models.CharField(max_length=120)),
('image', models.ImageField(upload_to='restaurants/')),
('location', models.CharField(max_length=120)),
('price', models.IntegerField()),
('vat', models.PositiveIntegerField(default=0)),
('taste', models.PositiveIntegerField(choices=[(1, 'One'), (2, 'Two'), (3,
'Three'), (4, 'Four'), (5, 'Five'), (6, 'Six'), (7, 'Seven'), (8, 'Eight'), (9, 'Nine'), (10,
'Ten')])),
('persons', models.PositiveIntegerField(choices=[(1, 'One'), (2, 'Two'), (3,
'Three'), (4, 'Four'), (5, 'Five'), (6, 'Six'), (7, 'Seven'), (8, 'Eight'), (9, 'Nine'), (10,
'Ten')])),
('details', models.TextField()),
('slug', models.SlugField(blank=True, unique=True)),
('views', models.IntegerField(default=0)),
('created_at', models.DateTimeField(auto_now_add=True)),
('updated_at', models.DateTimeField(auto_now=True)),
('is_active', models.BooleanField(default=True)),
('user',
models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL)),

Department of CS&IT (SF), C.P.A College Page 72


Doners & Food Governance

],
),
migrations.AddField(

model_name='like',
name='post',

field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
related_name='post_likes', to='restaurants.Restaurant'),
),
migrations.AddField(
model_name='like',
name='user',

field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
related_name='user_likes', to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='comment',
name='post',

field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
related_name='comments', to='restaurants.Restaurant'),
),
migrations.AddField(
model_name='comment',
name='user',

field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL),
),
migrations.AddField(
model_name='category',
name='restaurant',

field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE,
related_name='categories', to='restaurants.Restaurant'),
),
]

0002_auto_20190308_1057

# Generated by Django 2.1.7 on 2019-03-08 04:57

from django.db import migrations

Department of CS&IT (SF), C.P.A College Page 73


Doners & Food Governance

class Migration(migrations.Migration):

dependencies = [
('restaurants', '0001_initial'),
]

operations = [
migrations.RemoveField(
model_name='like',
name='post',
),
migrations.RemoveField(
model_name='like',
name='user',
),
migrations.DeleteModel(
name='Like',
),
]

0003_restaurant_likes

# Generated by Django 2.1.7 on 2019-03-08 05:00

from django.conf import settings


from django.db import migrations, models

class Migration(migrations.Migration):

dependencies = [
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
('restaurants', '0002_auto_20190308_1057'),
]

operations = [
migrations.AddField(
model_name='restaurant',
name='likes',
field=models.ManyToManyField(blank=True, related_name='post_likes',
to=settings.AUTH_USER_MODEL),
),
]
0004_auto_20190310_1527

Department of CS&IT (SF), C.P.A College Page 74


Doners & Food Governance

# Generated by Django 2.1.7 on 2019-03-10 09:27

from django.db import migrations, models

class Migration(migrations.Migration):

dependencies = [
('restaurants', '0003_restaurant_likes'),
]

operations = [
migrations.RemoveField(
model_name='category',
name='restaurant',
),
migrations.AddField(
model_name='restaurant',
name='categories',
field=models.CharField(default='fastfood', max_length=120),
preserve_default=False,
),
migrations.AlterField(
model_name='restaurant',
name='views',
field=models.IntegerField(blank=True, default=0),
),
migrations.DeleteModel(
name='Category',
),
]

Department of CS&IT (SF), C.P.A College Page 75


Doners & Food Governance

SNAPSHOT’S

Department of CS&IT (SF), C.P.A College Page 76


Doners & Food Governance

12.1 SAMPLE SCREENS

Figure : Home Page

Figure :Login Page

Department of CS&IT (SF), C.P.A College Page 77


Doners & Food Governance

Figure : Register

Department of CS&IT (SF), C.P.A College Page 78


Doners & Food Governance

Figure : Dashboard

Department of CS&IT (SF), C.P.A College Page 79


Doners & Food Governance

Figure : Profile

Figure : Create post

Department of CS&IT (SF), C.P.A College Page 80


Doners & Food Governance

CONCLUSION &
FUTURE ENHANCEMENTS

Department of CS&IT (SF), C.P.A College Page 81


Doners & Food Governance

CONCLUSION & FUTURE ENHANCEMENTS

13.1 CONCLUSION :

Our study examines the problems caused by food waste Many severe side effects
economically and socially However, food waste can be prevented.Mobile application
technology is helpful in food waste management.The purpose of the app is to
promote better eating Management, our proposed solution is to reduce food.Wastage
is reduced by facilitating group food sharing using mobile Technology. This work is
the first step in design Great system to reduce daily food waste . This design can
also be customized to meet your specific requirements. I hope that this design will
help you in honing your bents. This is how you make a Courier Management System
in Django in your python systems. In your Django systems, you can always expand
and essay indispensable ways to apply the Courier Management System in Django

13.2 . FUTURE SCOPE

From the research, we understood that people are trying to move more towards donating
food via food waste management mobile application, as it saves time from searching online
for different websites and collecting NGOs contact information and is much faster. Our
plans for this system shall be to transform this mobile application using API for a better
user experience. We would also like to expand our project by adding more platforms like
contacting delivery companies for collection of food, etc. Another feature that sounds
demanding is to show the live location of delivery of food. To simplify, our system shall
offer a faster booking process and faster response to user demand which will saves time of
the user.

Department of CS&IT (SF), C.P.A College Page 82


Doners & Food Governance

APPENDIES

14.1 BIBLIOGRAPHY

WEBSITE REFERENCE:

• The Complete React Tutorial for 2021 – Learn Major React Concepts by
Building a Project (freecodecamp.org)

• React Tutorial (w3schools.com)

• https://www.w3schools.com/php/

YOUTUBE CHANNELS:

• Lama Dev

• freeCodeCamp.org

• Web Dev Simplified

• Simplilearn
.

Department of CS&IT (SF), C.P.A College Page 83


Doners & Food Governance

14.2 FIND FOOD RECIPIENT ORGANIZATIONS

The following sites contain tools that allow users to search for food banks, pantries, soup
kitchens and shelters that may be interested in accepting wholesome, excess food:

 Feeding America’s Find Your Local Foodbank has a map of Feeding America


member food banks. Some of these food banks might have a minimum donation
size requirement. Feeding America also operates the Meal Connect app , which
connects donors to local food banks.
 Sustainable America’s Food Rescue Locator  is a directory of organizations that
rescue, glean, transport, prepare, and distribute food to the needy in their
communities. 
 AmpleHarvest.org allows you to search food pantries by zip code and shows the
search results on an interactive map.
 Hunger Free America operates the USDA’s National Hunger Clearinghouse, where
people can seek food assistance. 

The following organizations are examples of food donation organizations that provide a
mechanism for entities to donate wholesome, excess food to those in need:

 Food Recovery Network (FRN) is a student-led organization and national network


of college students, food businesses and non-profits whose goal is to combat wasted
food and hunger. FRN chapters donate surplus food to food-insecure communities.
 Food Donation Connection provides an alternative to discarding surplus wholesome
food by linking food service donors with surplus food to local hunger relief
agencies.
 Rock and Wrap It Up! is an anti-poverty think tank. It partners with music, sports
and TV/film production organizations, as well as hospitals, hotels and schools to
donate food that is prepared, but not served or sold, to indigent persons across the
United States and Canada.

Department of CS&IT (SF), C.P.A College Page 84


Doners & Food Governance

14.5 REFERENCES

[1] Nicole Josiane Janet Kennard, Food Waste Management, Newcastle University: School
of Natural and

Environmental Sciences.

[2] Roopika Nigam and Sanjana Sharma, “Food Waste Management,” Amity Journal of
Energy &Environment Studies 2017, Vol. 3, Number 2.

[3] Sakthi P, Jagannath S, Suman N, Sakthivel A and Nandhini A, “Survey on Waste Food
Management and

Donating Web Application”, International Journal of Research Publication and Reviews,


Vol. 3, No. 5, pp

2416-2417, May 2022.

[4] Chengwei Liu, Yixiang Chan, Syed Hasnain Alam Kazmi, Hao Fu, “Financial Fraud
Detection Model:

Based on Random Forest,” International Journal of Economics and Finance, Vol. 7, Issue.
7, pp. 178-188,

2015.

[5] Shyam Khadka, 2017. “Reducing Food Waste Vital for India’s Food Security”

[6] Guillermo Garcia-GarciaElliot Wooley, Shahin Rahimifard, James Colwill, Rodd


White, Lousie Needham.

2016, “A Methodology for Sustainable Management of Food Waste” Volume 68, Page 13
DOI: 10.1007 /

978-3-319-57078-5_2.

Department of CS&IT (SF), C.P.A College Page 85

You might also like