Aswin
Aswin
Aswin
A PROJECT REPORT
Submitted by
Mr.C.Kondalraj , MCA.,B.Ed.,MPhil.,SET.,
APRIL-2023
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: ……………….
ACKNOWLEDGEMENT
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
DECLARATION
Date : ………………
Place: Bodinayakanur
(A.ASWIN
S.MOHAMEDAZARUDEEN)
CPA COLLEGE,
BODINAYAKANUR,
THENI Dr -625513
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
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
ABSTRACT
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.
INTRODUCTION
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.
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.
SYSTEM SPECIFICATION
SOFTWARE DESCRIPTION
SOFTWARE DESCRIPTION
Python :
Python is Interactive − You can actually sit at a Python prompt and interact with the
interpreter directly to write your programs.
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.
Python is copyrighted. Like Perl, Python source code is now available under the
GNU General Public License (GPL).
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.
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.
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 :
• It provides very high-level dynamic data types and supports dynamic type
checking.
• It supports automatic garbage collection.
Python has also been ported to the Java and .NET virtual machines
Server-Side Database:
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 :
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 Types :
SQLite3 Support :
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 :
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.
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.
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.
SYSTEM ANALYSIS
SYSTEM ANALYSIS
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
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.
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.
WEB APPLICATION
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.
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.
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
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 :
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.
SYSTEM DESIGN
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.
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.
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.
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.
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
SYSTEM TESTING
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
c) End-to-End Testing
d) Integration Testing
f) Performance testing
g) Functional testing
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)
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.
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.
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
does not fluctuate and the alignment remains same after moving from one module to
another. (Software Testing Help, 2023)
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.
This is where a select group of the target population will test the system to
ascertain the functional requirements are attained.
SAMPLE CODE
SAMPLE CODE
11.1SOURCE 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
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>")
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
Urls
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
class LogoutView(View):
def get(self, request, *args, **kwargs):
logout(request)
return redirect('home')
user.profile.image = img
user.save()
MIGRATIONS
0001_initial
# Generated by Django 2.1.7 on 2019-03-10 16:53
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)),
],
),
FOODBANK
Settings
"""
Django settings for FoodBank project.
import os
ALLOWED_HOSTS = []
# 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')],
'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
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_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static'),
]
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')),
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL,document_root=settings.MEDIA_ROOT)
Wsgi
"""
WSGI config for FoodBank project.
import os
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'FoodBank.settings')
application = get_wsgi_application()
RESTAURANTS
Admin
from django.contrib import admin
@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
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'}))
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 %'}))
class Meta:
model = Restaurant
fields = ['title','image','categories','location','price','vat','taste','persons','details']
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
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'),
)
return unique_slug
Tests
from django.test import TestCase
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
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:
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)
instance.user = self.request.user
return super().form_valid(form)
def get_queryset(self):
return Restaurant.objects.filter(user=self.request.user)
def get_queryset(self):
return Restaurant.objects.filter(user=self.request.user)
def get_queryset(self):
return Restaurant.objects.filter(user=self.request.user)
Views
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:
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)
def get_queryset(self):
return Restaurant.objects.filter(user=self.request.user)
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)
def get_queryset(self):
return Restaurant.objects.filter(user=self.request.user)
MIGRATIONS
0001_initial
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')),
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)),
],
),
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
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
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
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',
),
]
SNAPSHOT’S
Figure : Register
Figure : Dashboard
Figure : Profile
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
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.
APPENDIES
14.1 BIBLIOGRAPHY
WEBSITE REFERENCE:
• The Complete React Tutorial for 2021 – Learn Major React Concepts by
Building a Project (freecodecamp.org)
• https://www.w3schools.com/php/
YOUTUBE CHANNELS:
• Lama Dev
• freeCodeCamp.org
• Simplilearn
.
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:
The following organizations are examples of food donation organizations that provide a
mechanism for entities to donate wholesome, excess food to those in need:
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
[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”
2016, “A Methodology for Sustainable Management of Food Waste” Volume 68, Page 13
DOI: 10.1007 /
978-3-319-57078-5_2.