Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Liji mathew #5

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added FoodProject/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added FoodProject/__pycache__/settings.cpython-311.pyc
Binary file not shown.
Binary file added FoodProject/__pycache__/urls.cpython-311.pyc
Binary file not shown.
Binary file added FoodProject/__pycache__/wsgi.cpython-311.pyc
Binary file not shown.
34 changes: 34 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,40 @@
The website is minimized as much as possible to avoid errors when entering data. It also gives an error message when entering invalid data. No formal knowledge is required for the user to use this system. Therefore, every test is easy to use. Online food order systems, as described above, can lead to error-free, safe, reliable and fast management systems. This can help the user focus on his other activities instead of focusing on record keeping. Therefore, it will help the organization to make better use of resources.


__Project Structure__
.foodorder/: The main project directory.
..foodapp/: The main app directory.
...models.py: Defines the database models.
...views.py: Contains the view functions and logic.
...urls.py: Defines URL patterns and routing.
.templates/: Contains HTML templates for rendering views.
.static/: Contains static files like CSS, JavaScript, and images.

__Models__

Food: Represents food items available for order.

Fields: FoodId, FoodName, FoodCat, FoodPrice, FoodImage
Database Table: FP_Food
Cust: Represents customer accounts.

Fields: CustId, CustFName, CustLName, CustCont, CustEmail, CustPass, Address
Database Table: FP_Cust
Admin: Represents admin accounts.

Fields: AdminId, AdminPass
Database Table: FP_Admin
Cart: Represents the user's cart with selected food items.

Fields: CartId, CustEmail, FoodId, FoodQuant
Database Table: FP_Cart
Order: Represents customer orders.

Fields: OrderId, CustEmail, OrderDate, TotalBill
Database Table: FP_Order



Homepage:<br>
![alt text](https://github.com/CosmiX-6/FoodPlaza/blob/main/Screenshots/foodplaza-admin-home-1.png "Home Preview")
![alt text](https://github.com/CosmiX-6/FoodPlaza/blob/main/Screenshots/foodplaza-login.png "Login Preview")
Expand Down
Binary file modified db.sqlite3
Binary file not shown.
Binary file added foodapp/__pycache__/__init__.cpython-311.pyc
Binary file not shown.
Binary file added foodapp/__pycache__/admin.cpython-311.pyc
Binary file not shown.
Binary file added foodapp/__pycache__/apps.cpython-311.pyc
Binary file not shown.
Binary file added foodapp/__pycache__/forms.cpython-311.pyc
Binary file not shown.
Binary file added foodapp/__pycache__/models.cpython-311.pyc
Binary file not shown.
Binary file added foodapp/__pycache__/views.cpython-311.pyc
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
59 changes: 49 additions & 10 deletions foodapp/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@

cursor = connection.cursor()

# Create your views here.


# ---------------------------------------This function renders the index page-----------------------------.
def foodapp(request):
return render(request,'index.html')



#------------------------ This function allows an admin to add food details and redirects to the food list-----------------------------------
def addfood(request):
if request.method=="POST":
form = FoodForm(request.POST,request.FILES)
Expand All @@ -24,19 +28,28 @@ def addfood(request):
form = FoodForm()
return render(request,'addfood.html',{'form':form})



# -------------------------This function retrieves and displays the list of food items--------------------------
def showfood(request):
foods = Food.objects.all()
return render(request,'foodlist.html',{'foodlist':foods})


#-----------------------This function allows an admin to delete a specific food item and redirects to the food list.---------------
def deletefood(request,FoodId):
foods = Food.objects.get(FoodId=FoodId)
foods.delete()
return redirect("/allfood")



#------------------This function retrieves a specific food item for editing.-----------------------------
def getfood(request,FoodId):
foods = Food.objects.get(FoodId=FoodId)
return render(request,'updatefood.html',{'f':foods})



#------------------------This function allows an admin to update the details of a specific food item and redirects to the food list.------------------------
def updatefood(request,FoodId):
foods = Food.objects.get(FoodId=FoodId)
form = FoodForm(request.POST,request.FILES,instance=foods)
Expand All @@ -45,6 +58,7 @@ def updatefood(request,FoodId):
return redirect("/allfood")
return render(request,'updatefood.html',{'f':foods})

#-----------------This function allows a user to register and redirects to the login page.----------------------
def addcust(request):
if request.method=="POST":
form = CustForm(request.POST)
Expand All @@ -57,22 +71,30 @@ def addcust(request):
else :
form = CustForm()
return render(request,'addcust.html',{'form':form})




#------------------------This function retrieves and displays the list of customers.-------------------------
def showcust(request):
custs = Cust.objects.all()
return render(request,'custlist.html',{'custlist':custs})


#--------------This function allows an admin to delete a specific customer and redirects to the customer list.-----------------------
def deletecust(request,CustId):
custs = Cust.objects.get(CustId=CustId)
custs.delete()
return redirect("/allcustomer")


#----------This function retrieves and displays the details of a logged-in customer for editing.-------------------
def getcust(request):
print(request.session['CustId'])
for c in Cust.objects.raw('Select * from FP_Cust where CustEmail="%s"'%request.session['CustId']):
custs=c
return render(request,'updatecust.html',{'c':custs})

#--------This function allows a user to update their details and logs them out for security purposes.--------------------
def updatecust(request,CustId):
custs = Cust.objects.get(CustId=CustId)
form = CustForm(request.POST,instance=custs)
Expand All @@ -85,10 +107,12 @@ def updatecust(request,CustId):
return render(request,'updatecust.html',{'c':custs})


#------------------This function renders the login page------------------------
def login(request):
return render(request,'login.html')


#------------------This function handles user and admin login and sets session variables accordingly.------------------
def doLogin(request):
if request.method=="POST":
uid = request.POST.get('userId','')
Expand All @@ -110,32 +134,43 @@ def doLogin(request):
return render(request,"index.html",{'success':'Welcome '+a.CustEmail})
else:
return render(request,"login.html",{'failure':'Incorrect login details'})



#-------------This function logs out the user or admin by clearing session variables.---------------------------
def doLogout(request):
key_session = list(request.session.keys())
for key in key_session:
del request.session[key]
return render(request,'index.html',{'success':'Logged out successfully'})


#-----------This function allows a user to add food items to their cart.-----------------------
def addcart(request,FoodId):
sql = ' Insert into FP_Cart(CustEmail,FoodId,FoodQuant) values("%s","%d","%d")'%(request.session['CustId'],FoodId,1)
i=cursor.execute(sql)
transaction.commit()
return redirect('/allfood')


#-----------------This function allows a user to remove items from their cart and redirects to the cart page.-----------------
def delcart(request,CartId):
cart = Cart.objects.get(CartId=CartId)
cart.delete()
return redirect("/allcart")


#---------------------This function retrieves and displays the list of items in the user's cart.------------------------
def showcart(request):
cart=Cart.objects.raw('Select CartId,FoodName,FoodPrice,FoodQuant,FoodImage from FP_Food as f inner join FP_Cart as c on f.FoodId=c.FoodId where c.CustEmail="%s"'%request.session['CustId'])
transaction.commit()
return render(request,"cartlist.html",{'cartlist':cart})



#------------------------This function renders the password update page.---------------------------------------
def updatepasswd(request):
return render(request,'updatepasswd.html')



#-----------------This function handles the process of changing the password and logs the user out for security reasons.--------------------------
def changepass(request):
if request.method == "POST":
aid=request.session['AdminId']
Expand All @@ -154,6 +189,8 @@ def changepass(request):
else:
return render(request,'updatepasswd.html',{'failure':'Invalid attempt.'})


#-----------------------This function allows a user to place an order and clears the cart.----------------------------
def placeorder(request):
if request.method=="POST":
price=request.POST.getlist('FoodPrice','')
Expand All @@ -179,10 +216,12 @@ def placeorder(request):
else:
pass


#------------------------This function retrieves and displays a list of orders.----------------------------
def getorder(request):
orders = Order.objects.all()
return render(request,'orderlist.html',{'orderlist':orders})

#--------------------This function updates the quantity of items in the cart.-------------------------
def updateQNT(request,s):
print(s)
ind=s.index('@')
Expand Down