├── pr1 ├── __init__.py ├── __pycache__ │ ├── urls.cpython-310.pyc │ ├── urls.cpython-38.pyc │ ├── wsgi.cpython-310.pyc │ ├── wsgi.cpython-38.pyc │ ├── __init__.cpython-38.pyc │ ├── settings.cpython-38.pyc │ ├── __init__.cpython-310.pyc │ └── settings.cpython-310.pyc ├── asgi.py ├── wsgi.py ├── urls.py └── settings.py ├── cafe ├── migrations │ ├── __init__.py │ ├── __pycache__ │ │ ├── 0007_bill.cpython-38.pyc │ │ ├── __init__.cpython-38.pyc │ │ ├── 0001_initial.cpython-38.pyc │ │ ├── 0003_order_price.cpython-38.pyc │ │ ├── 0008_bill_bill_time.cpython-38.pyc │ │ ├── 0005_order_bill_clear.cpython-38.pyc │ │ ├── 0006_user_order_count.cpython-38.pyc │ │ ├── 0002_alter_order_table.cpython-38.pyc │ │ └── 0004_menu_item_list_order.cpython-38.pyc │ ├── 0006_user_order_count.py │ ├── 0003_order_price.py │ ├── 0004_menu_item_list_order.py │ ├── 0005_order_bill_clear.py │ ├── 0002_alter_order_table.py │ ├── 0008_bill_bill_time.py │ ├── 0007_bill.py │ └── 0001_initial.py ├── tests.py ├── __pycache__ │ ├── admin.cpython-38.pyc │ ├── apps.cpython-310.pyc │ ├── apps.cpython-38.pyc │ ├── urls.cpython-310.pyc │ ├── urls.cpython-38.pyc │ ├── views.cpython-38.pyc │ ├── admin.cpython-310.pyc │ ├── manager.cpython-38.pyc │ ├── models.cpython-310.pyc │ ├── models.cpython-38.pyc │ ├── views.cpython-310.pyc │ ├── __init__.cpython-310.pyc │ ├── __init__.cpython-38.pyc │ └── manager.cpython-310.pyc ├── apps.py ├── admin.py ├── manager.py ├── urls.py ├── models.py └── views.py ├── .gitattributes ├── db.sqlite3 ├── static ├── logo.png └── cart_img.png ├── media └── fimage │ ├── dal_fry.png │ ├── mix_veg.png │ ├── dal_tadka.png │ ├── jeera_rice.png │ ├── manchurian.png │ ├── rasgulla.png │ ├── steam_rice.png │ ├── masala_papad.png │ ├── shahi_tukda.png │ ├── tandoor_roti.png │ ├── butter_tandoor.png │ ├── paneer_chatpata.png │ ├── paneer_chilli.png │ ├── roasted_papad.png │ ├── masala_papad_uLBfzPx.png │ └── roasted_papad_1XLzljM.png ├── templates ├── offers.html ├── my_orders.html ├── reviews.html ├── all_orders.html ├── bills.html ├── home.html ├── generate_bill.html ├── profile.html ├── login.html ├── manage_menu.html ├── cart.html ├── menu.html ├── signup.html └── base.html ├── README.md └── manage.py /pr1/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /cafe/migrations/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.html linguist-detectable=false 2 | -------------------------------------------------------------------------------- /cafe/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /db.sqlite3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/db.sqlite3 -------------------------------------------------------------------------------- /static/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/static/logo.png -------------------------------------------------------------------------------- /static/cart_img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/static/cart_img.png -------------------------------------------------------------------------------- /media/fimage/dal_fry.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/media/fimage/dal_fry.png -------------------------------------------------------------------------------- /media/fimage/mix_veg.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/media/fimage/mix_veg.png -------------------------------------------------------------------------------- /media/fimage/dal_tadka.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/media/fimage/dal_tadka.png -------------------------------------------------------------------------------- /media/fimage/jeera_rice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/media/fimage/jeera_rice.png -------------------------------------------------------------------------------- /media/fimage/manchurian.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/media/fimage/manchurian.png -------------------------------------------------------------------------------- /media/fimage/rasgulla.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/media/fimage/rasgulla.png -------------------------------------------------------------------------------- /media/fimage/steam_rice.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/media/fimage/steam_rice.png -------------------------------------------------------------------------------- /media/fimage/masala_papad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/media/fimage/masala_papad.png -------------------------------------------------------------------------------- /media/fimage/shahi_tukda.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/media/fimage/shahi_tukda.png -------------------------------------------------------------------------------- /media/fimage/tandoor_roti.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/media/fimage/tandoor_roti.png -------------------------------------------------------------------------------- /media/fimage/butter_tandoor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/media/fimage/butter_tandoor.png -------------------------------------------------------------------------------- /media/fimage/paneer_chatpata.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/media/fimage/paneer_chatpata.png -------------------------------------------------------------------------------- /media/fimage/paneer_chilli.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/media/fimage/paneer_chilli.png -------------------------------------------------------------------------------- /media/fimage/roasted_papad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/media/fimage/roasted_papad.png -------------------------------------------------------------------------------- /cafe/__pycache__/admin.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/__pycache__/admin.cpython-38.pyc -------------------------------------------------------------------------------- /cafe/__pycache__/apps.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/__pycache__/apps.cpython-310.pyc -------------------------------------------------------------------------------- /cafe/__pycache__/apps.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/__pycache__/apps.cpython-38.pyc -------------------------------------------------------------------------------- /cafe/__pycache__/urls.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/__pycache__/urls.cpython-310.pyc -------------------------------------------------------------------------------- /cafe/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /cafe/__pycache__/views.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/__pycache__/views.cpython-38.pyc -------------------------------------------------------------------------------- /media/fimage/masala_papad_uLBfzPx.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/media/fimage/masala_papad_uLBfzPx.png -------------------------------------------------------------------------------- /pr1/__pycache__/urls.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/pr1/__pycache__/urls.cpython-310.pyc -------------------------------------------------------------------------------- /pr1/__pycache__/urls.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/pr1/__pycache__/urls.cpython-38.pyc -------------------------------------------------------------------------------- /pr1/__pycache__/wsgi.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/pr1/__pycache__/wsgi.cpython-310.pyc -------------------------------------------------------------------------------- /pr1/__pycache__/wsgi.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/pr1/__pycache__/wsgi.cpython-38.pyc -------------------------------------------------------------------------------- /cafe/__pycache__/admin.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/__pycache__/admin.cpython-310.pyc -------------------------------------------------------------------------------- /cafe/__pycache__/manager.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/__pycache__/manager.cpython-38.pyc -------------------------------------------------------------------------------- /cafe/__pycache__/models.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/__pycache__/models.cpython-310.pyc -------------------------------------------------------------------------------- /cafe/__pycache__/models.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/__pycache__/models.cpython-38.pyc -------------------------------------------------------------------------------- /cafe/__pycache__/views.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/__pycache__/views.cpython-310.pyc -------------------------------------------------------------------------------- /media/fimage/roasted_papad_1XLzljM.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/media/fimage/roasted_papad_1XLzljM.png -------------------------------------------------------------------------------- /pr1/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/pr1/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /pr1/__pycache__/settings.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/pr1/__pycache__/settings.cpython-38.pyc -------------------------------------------------------------------------------- /cafe/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /cafe/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /cafe/__pycache__/manager.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/__pycache__/manager.cpython-310.pyc -------------------------------------------------------------------------------- /pr1/__pycache__/__init__.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/pr1/__pycache__/__init__.cpython-310.pyc -------------------------------------------------------------------------------- /pr1/__pycache__/settings.cpython-310.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/pr1/__pycache__/settings.cpython-310.pyc -------------------------------------------------------------------------------- /cafe/migrations/__pycache__/0007_bill.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/migrations/__pycache__/0007_bill.cpython-38.pyc -------------------------------------------------------------------------------- /cafe/migrations/__pycache__/__init__.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/migrations/__pycache__/__init__.cpython-38.pyc -------------------------------------------------------------------------------- /cafe/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class CafeConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'cafe' 7 | -------------------------------------------------------------------------------- /cafe/migrations/__pycache__/0001_initial.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/migrations/__pycache__/0001_initial.cpython-38.pyc -------------------------------------------------------------------------------- /cafe/migrations/__pycache__/0003_order_price.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/migrations/__pycache__/0003_order_price.cpython-38.pyc -------------------------------------------------------------------------------- /cafe/migrations/__pycache__/0008_bill_bill_time.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/migrations/__pycache__/0008_bill_bill_time.cpython-38.pyc -------------------------------------------------------------------------------- /cafe/migrations/__pycache__/0005_order_bill_clear.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/migrations/__pycache__/0005_order_bill_clear.cpython-38.pyc -------------------------------------------------------------------------------- /cafe/migrations/__pycache__/0006_user_order_count.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/migrations/__pycache__/0006_user_order_count.cpython-38.pyc -------------------------------------------------------------------------------- /cafe/migrations/__pycache__/0002_alter_order_table.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/migrations/__pycache__/0002_alter_order_table.cpython-38.pyc -------------------------------------------------------------------------------- /templates/offers.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %}Offers 4 | {% endblock title %} 5 | 6 | {% block body %} 7 | 8 |

Offers Page

9 | 10 | {% endblock body %} -------------------------------------------------------------------------------- /cafe/migrations/__pycache__/0004_menu_item_list_order.cpython-38.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Kaushik-Dhoot/Order-food-using-QR_code/HEAD/cafe/migrations/__pycache__/0004_menu_item_list_order.cpython-38.pyc -------------------------------------------------------------------------------- /cafe/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from cafe.models import * 3 | # Register your models here. 4 | 5 | admin.site.register(User) 6 | admin.site.register(menu_item) 7 | admin.site.register(rating) 8 | admin.site.register(order) 9 | admin.site.register(bill) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Order-food-using-QR_code- 2 | A food ordering website for restaurant and café for dine-in and takeaway 3 | 4 | This project is made for dine-in or takeaway food ordering at restaurant or cafe using qr code 5 | 6 | To run the project run commands : 7 | 8 | python manage.py makemigrations 9 | python manage.py migrate 10 | python manage.py runserver 11 | 12 | To create superuser(admin) : 13 | python manage.py createsuperuser 14 | -------------------------------------------------------------------------------- /pr1/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for pr1 project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.1/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pr1.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /pr1/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for pr1 project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.1/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pr1.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /cafe/migrations/0006_user_order_count.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.13 on 2023-06-02 05:35 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('cafe', '0005_order_bill_clear'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='user', 15 | name='order_count', 16 | field=models.IntegerField(default=0), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /cafe/migrations/0003_order_price.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.13 on 2023-05-25 08:46 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('cafe', '0002_alter_order_table'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='order', 15 | name='price', 16 | field=models.CharField(default='0', max_length=5), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /cafe/migrations/0004_menu_item_list_order.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.13 on 2023-05-25 17:52 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('cafe', '0003_order_price'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='menu_item', 15 | name='list_order', 16 | field=models.IntegerField(default=0), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /cafe/migrations/0005_order_bill_clear.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.13 on 2023-05-31 18:45 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('cafe', '0004_menu_item_list_order'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AddField( 14 | model_name='order', 15 | name='bill_clear', 16 | field=models.BooleanField(default=False), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /cafe/migrations/0002_alter_order_table.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.13 on 2023-05-24 07:59 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('cafe', '0001_initial'), 10 | ] 11 | 12 | operations = [ 13 | migrations.AlterField( 14 | model_name='order', 15 | name='table', 16 | field=models.CharField(default='take away', max_length=15), 17 | ), 18 | ] 19 | -------------------------------------------------------------------------------- /cafe/migrations/0008_bill_bill_time.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.13 on 2023-06-09 19:55 2 | 3 | from django.db import migrations, models 4 | import django.utils.timezone 5 | 6 | 7 | class Migration(migrations.Migration): 8 | 9 | dependencies = [ 10 | ('cafe', '0007_bill'), 11 | ] 12 | 13 | operations = [ 14 | migrations.AddField( 15 | model_name='bill', 16 | name='bill_time', 17 | field=models.DateTimeField(default=django.utils.timezone.now), 18 | preserve_default=False, 19 | ), 20 | ] 21 | -------------------------------------------------------------------------------- /manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'pr1.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /cafe/manager.py: -------------------------------------------------------------------------------- 1 | from django.contrib.auth.base_user import BaseUserManager 2 | 3 | 4 | class UserManager(BaseUserManager): 5 | use_in_migrations = True 6 | 7 | def create_user(self, phone, password=None, **extra_fields): 8 | 9 | if not phone: 10 | raise ValueError('Phone is required') 11 | 12 | user = self.model(phone=phone, **extra_fields) 13 | user.set_password(password) 14 | user.save(using=self._db) 15 | 16 | return user 17 | 18 | def create_superuser(self, phone, password, **extra_fields): 19 | extra_fields.setdefault('is_staff', True) 20 | extra_fields.setdefault('is_active', True) 21 | extra_fields.setdefault('is_superuser', True) 22 | 23 | return self.create_user(phone, password, **extra_fields) 24 | -------------------------------------------------------------------------------- /cafe/migrations/0007_bill.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.13 on 2023-06-02 10:41 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | dependencies = [ 9 | ('cafe', '0006_user_order_count'), 10 | ] 11 | 12 | operations = [ 13 | migrations.CreateModel( 14 | name='bill', 15 | fields=[ 16 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 17 | ('order_items', models.CharField(max_length=5000)), 18 | ('name', models.CharField(default='', max_length=50)), 19 | ('bill_total', models.IntegerField()), 20 | ('phone', models.CharField(max_length=10)), 21 | ], 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /pr1/urls.py: -------------------------------------------------------------------------------- 1 | """pr1 URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/4.1/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path, include 18 | 19 | urlpatterns = [ 20 | path('admin/', admin.site.urls), 21 | path('', include('cafe.urls')), 22 | ] 23 | 24 | admin.site.site_header = 'SnackDonalds Admin' 25 | admin.site.index_title = 'SnackDonalds Admin Portal' 26 | admin.site.site_title = 'SnackDonalds' 27 | -------------------------------------------------------------------------------- /templates/my_orders.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %}My_orders 4 | {% endblock title %} 5 | 6 | {% block body %} 7 | 8 | {% for message in messages %} 9 | 13 | {% endfor %} 14 | 15 | 16 | 17 |

Your Orders

20 | 21 |
22 | 23 | {% for table, orders in order_by_table.items %} 24 | 25 |
26 |
27 | 28 | {% for o in orders %} 29 | 30 |

Order Time: {{ o.order_time }}

31 | 32 | {% for item_key, item_values in o.items_json.items %} 33 |

{{ item_values.1 }} : {{ item_values.0 }}

34 | {% endfor %} 35 | 36 |

Total : {{o.price}}

37 |
38 | 39 | {% endfor %} 40 | 41 | {% endfor %} 42 | 43 |
44 | 45 |
46 | 47 | {% endblock body %} -------------------------------------------------------------------------------- /cafe/urls.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | from django.urls import path, include 3 | from cafe import views 4 | from django.conf import settings 5 | from django.conf.urls.static import static 6 | 7 | urlpatterns = [ 8 | # path('', views.home, name='home'), 9 | path('', views.menu, name='menu'), 10 | path('delete_dish//', views.delete_dish, name='delete_dish'), 11 | path('offers', views.offers, name='offers'), 12 | path('reviews', views.reviews, name='reviews'), 13 | path('profile', views.profile, name='profile'), 14 | path('all_orders', views.all_orders, name='all_orders'), 15 | path('manage_menu', views.manage_menu, name='manage_menu'), 16 | path('cart', views.cart, name='cart'), 17 | # path('checkout', views.checkout, name='checkout'), 18 | path('my_orders', views.my_orders, name='my_orders'), 19 | path('login', views.Login, name='login'), 20 | path('signup', views.signup, name='signup'), 21 | path('logout', views.Logout, name='logout'), 22 | path('generate_bill', views.generate_bill, name='generate_bill'), 23 | path('view_bills', views.view_bills, name='view_bills'), 24 | ] 25 | 26 | if settings.DEBUG: 27 | urlpatterns += static(settings.MEDIA_URL, 28 | document_root=settings.MEDIA_ROOT) 29 | -------------------------------------------------------------------------------- /templates/reviews.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %}Reviews 4 | {% endblock title %} 5 | 6 | {% block body %} 7 | 8 | 9 | 10 | {% if user.is_authenticated %} 11 |
12 | 13 |

Write a review

14 | 15 |
16 | {% csrf_token %} 17 |
18 | 19 | 20 | 21 |
22 | 23 | 24 |
25 | 26 |
27 | {% endif %} 28 |
29 |

Reviews :

30 |
31 | 32 | {% for r in reviews%} 33 |
34 | 35 |

{{r.name}}

36 |
{{r.comment}}
37 |
{{r.created_at}}
38 | 39 |
40 | {% endfor %} 41 | 42 | {% endblock body %} -------------------------------------------------------------------------------- /templates/all_orders.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %}All Orders 4 | {% endblock title %} 5 | 6 | {% block body %} 7 | 8 |
9 | 10 | {% for table, orders in order_by_table.items %} 11 | 12 |
13 | 14 | {% if table == 'Take Away' %} 15 |

{{ table }}

16 | {% else %} 17 |

Table No : {{table}}

18 | {% endif %} 19 |
20 |
21 | 22 | {% for o in orders %} 23 | 24 |

Order Time: {{ o.order_time }}

25 | 26 | {% for item_key, item_values in o.items_json.items %} 27 |

{{ item_values.1 }} : {{ item_values.0 }}

28 | {% endfor %} 29 |

Total : {{o.price}}

30 | 31 |

Name: {{ o.name }}

32 | {% if not o.bill_clear %} 33 | 34 | {%else%} 35 |
Bill Cleared
36 | {% endif %} 37 |
38 | {% endfor %} 39 | 40 |
41 | 42 | {% endfor %} 43 | 44 |
45 | 46 |
47 | {% endblock body %} 48 | 49 | 50 | {%block js%} 51 | 52 | 57 | 58 | {%endblock js%} -------------------------------------------------------------------------------- /templates/bills.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | 4 | {% block title %}Bill{% endblock title %} 5 | 6 | {%block body%} 7 | 8 | {% for message in messages %} 9 | 13 | {% endfor %} 14 | 15 |
16 |
17 |

All Bills :

18 |
19 | {% for b in bills %} 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | {% for item, values in b.order_items.items %} 31 | 32 | 33 | 34 | 35 | 36 | {% endfor %} 37 |
38 |
39 |
Invoice number : {{b.id}}
40 |
Invoice time : {{b.bill_time}}
41 | {% if b.name != "Unknown" %} 42 |
Name: {{ b.name }}
43 |
Phone: {{ b.phone }}
44 | {% endif %} 45 |
Bill Total : {{ b.bill_total }}
46 |
47 | {% endfor %} 48 | 49 |
Item nameQtyTotal
{{ item }}{{ values.0 }}{{ values.1 }}
50 | 51 |
52 | 53 | 54 | 55 | {%endblock body%} 56 | 57 | {% block js %} 58 | 61 | 62 | 63 | {%endblock js%} -------------------------------------------------------------------------------- /templates/home.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %}Home{% endblock title %} 4 | 5 | {% block body %} 6 | 7 | {% comment %}

Home page

{% endcomment %} 8 | 9 | {% for message in messages %} 10 | 14 | {% endfor %} 15 | {% comment %} Crousel {% endcomment %} 16 | 37 | {% comment %} {% endcomment %} 38 | 39 | {% endblock body %} -------------------------------------------------------------------------------- /templates/generate_bill.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | 4 | {% block title %}Bill{% endblock title %} 5 | 6 | {%block body%} 7 | 8 | {% for message in messages %} 9 | 13 | {% endfor %} 14 | 15 |
16 |
17 |

Bill No : {{inv_id}}

18 | {% if name != "Unknown" %} 19 |
Name: {{ name }}
20 |
Phone: {{ phone }}
21 | {% endif %} 22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | {% for key, value in order_dict.items %} 33 | 34 | 35 | 36 | 37 | 38 | {% endfor %} 39 | 40 |
Item nameQtyTotal
{{ key }}{{ value.0 }}{{ value.1 }}
41 |

Bill Total: {{ bill_total }}

42 |
43 | 44 |
45 |
46 | 47 | 48 | {%endblock body%} 49 | 50 | {% block js %} 51 | 56 | 57 | 58 | {%endblock js%} -------------------------------------------------------------------------------- /templates/profile.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %}Profile 4 | {% endblock title %} 5 | 6 | {% block body %} 7 | 8 | {% for message in messages %} 9 | 13 | {% endfor %} 14 | 15 |
16 |
17 |
18 |
19 |
20 |

Profile

21 |
22 |
23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 |
First name{{request.user.first_name}}
Last name{{request.user.last_name}}
Phone Number{{request.user.phone}}
Total Orders{{request.user.order_count}}
44 | 45 | 46 | 47 |
48 |
49 |
50 |
51 |
52 | 53 | {% endblock body %} -------------------------------------------------------------------------------- /cafe/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | from django.contrib.auth.models import AbstractUser 3 | from .manager import UserManager 4 | # Create your models here. 5 | 6 | 7 | class User(AbstractUser): 8 | 9 | email = None 10 | username = None 11 | phone = models.CharField(max_length=10, unique=True) 12 | phone_verified = models.BooleanField(default=False) 13 | cafe_manager = models.BooleanField(default=False) 14 | order_count = models.IntegerField(default=0) 15 | 16 | objects = UserManager() 17 | 18 | USERNAME_FIELD = 'phone' 19 | REQUIRED_FIELDS = [] 20 | 21 | 22 | class menu_item(models.Model): 23 | 24 | item_id = models.AutoField 25 | name = models.CharField(max_length=50) 26 | category = models.CharField(max_length=50, default='') 27 | desc = models.CharField(max_length=250) 28 | pic = models.ImageField(upload_to='fimage') 29 | price = models.CharField(max_length=4, default='0') 30 | list_order = models.IntegerField(default=0) 31 | 32 | def __str__(self): 33 | return self.name 34 | 35 | 36 | class rating(models.Model): 37 | 38 | name = models.CharField(max_length=30) 39 | comment = models.CharField(max_length=250) 40 | r_date = models.DateField() 41 | 42 | def __str__(self): 43 | return f"{self.name}\'s review" 44 | 45 | 46 | class order(models.Model): 47 | order_id = models.AutoField(primary_key=True) 48 | items_json = models.CharField(max_length=5000) 49 | name = models.CharField(max_length=30, default='') 50 | phone = models.CharField(max_length=10, default='') 51 | table = models.CharField(max_length=15, default='take away') 52 | price = models.CharField(max_length=5, default='0') 53 | order_time = models.DateTimeField() 54 | bill_clear = models.BooleanField(default=False) 55 | 56 | 57 | class bill(models.Model): 58 | order_items = models.CharField(max_length=5000) 59 | name = models.CharField(default='', max_length=50) 60 | bill_total = models.IntegerField() 61 | phone = models.CharField(max_length=10) 62 | bill_time = models.DateTimeField() 63 | -------------------------------------------------------------------------------- /templates/login.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | 4 | {%block title%}Login{%endblock title%} 5 | 6 | {% block body %} 7 | 8 | 25 | 26 | 27 |
28 |
29 |
30 |
31 | Sample image 33 |
34 |
35 | 36 | {% for message in messages %} 37 | 41 | {% endfor %} 42 | 43 | 44 |
45 | {% csrf_token %} 46 | 47 | 48 |
49 | 51 | 52 |
53 | 54 | 55 |
56 | 58 | 59 |
60 | 61 |
62 | Forgot password? 63 |
64 | 65 |
66 | 68 |

Don't have an account? Register

70 |
71 | 72 |
73 |
74 |
75 |
76 | 77 |
78 | 79 | {% endblock body %} -------------------------------------------------------------------------------- /templates/manage_menu.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {%block title%} Manage Menu {%endblock title%} 4 | 5 | {% block body %} 6 | 7 | {% for message in messages %} 8 | 12 | {% endfor %} 13 | 14 |
15 | 16 |

Add a dish

17 | 18 |
19 | {% csrf_token %} 20 | 21 | 22 |
23 | 24 | 25 |
26 | 27 |
28 | 39 | 40 |
41 | 42 |
43 | 44 | 45 |
46 | 47 |
48 | 49 | 50 |
51 | 52 |
53 | 54 | 55 |
56 | 57 | 58 | 59 |
60 | 61 |
62 | 63 | 64 |
65 | {%for i in items%} 66 |
67 | ... 68 |
69 | 70 |

{{i.name}}

71 |
₹{{i.price}}
72 |

{{i.desc}}

73 |
74 | {% csrf_token %} 75 | {% if user.is_superuser %} 76 | 77 | 78 | {%else%} 79 | Add to cart 80 | {%endif%} 81 |
82 |
83 |
84 | {%endfor%} 85 |
86 | 87 | {% endblock body %} 88 | 89 | -------------------------------------------------------------------------------- /templates/cart.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %}Cart 4 | {% endblock title %} 5 | 6 | {% block body %} 7 | 8 | {% for message in messages %} 9 | 13 | {% endfor %} 14 | 15 | 16 | 17 |
18 |

Review your order

19 |
20 |
21 | {% csrf_token %} 22 | 23 | 24 |
25 | 26 |
    27 | 28 |
29 |
    30 |
  • Total = 31 | 32 | 0 33 |
  • 34 |
    35 |
36 | 37 |
38 | 39 | 40 | Add More items 41 |
42 |
43 |
44 | 45 | 46 | 47 | {% endblock body %} 48 | 49 | {%block js%} 50 | 51 | 117 | 118 | {%endblock js%} -------------------------------------------------------------------------------- /templates/menu.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | {% block title %}Menu 4 | {% endblock title %} 5 | 6 | {% block body %} 7 | 8 | {% for message in messages %} 9 | 13 | {% endfor %} 14 | 15 | {% for category, menu_items in items_by_category.items %} 16 |

{{category}}:

17 |
18 | {%for i in menu_items%} 19 |
20 | 21 |
22 |

{{i.name}}

23 |
{{i.price}}
24 |

{{i.desc}}

25 | {% if user.is_superuser %} 26 |
27 | {% csrf_token %} 28 | 29 |
30 | 31 | {% else %} 32 | 33 | 34 | 35 | {%endif%} 36 |
37 |
38 | {%endfor%} 39 |
40 | {%endfor%} 41 | 42 |
45 | 46 |
47 | 48 | 49 | {% endblock body %} 50 | 51 | 52 | {%block js%} 53 | 54 | 114 | 115 | {%endblock js%} -------------------------------------------------------------------------------- /cafe/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.2.13 on 2023-05-23 11:04 2 | 3 | import cafe.manager 4 | from django.db import migrations, models 5 | import django.utils.timezone 6 | 7 | 8 | class Migration(migrations.Migration): 9 | 10 | initial = True 11 | 12 | dependencies = [ 13 | ('auth', '0012_alter_user_first_name_max_length'), 14 | ] 15 | 16 | operations = [ 17 | migrations.CreateModel( 18 | name='menu_item', 19 | fields=[ 20 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 21 | ('name', models.CharField(max_length=50)), 22 | ('category', models.CharField(default='', max_length=50)), 23 | ('desc', models.CharField(max_length=250)), 24 | ('pic', models.ImageField(upload_to='fimage')), 25 | ('price', models.CharField(default='0', max_length=4)), 26 | ], 27 | ), 28 | migrations.CreateModel( 29 | name='order', 30 | fields=[ 31 | ('order_id', models.AutoField(primary_key=True, serialize=False)), 32 | ('items_json', models.CharField(max_length=5000)), 33 | ('name', models.CharField(default='', max_length=30)), 34 | ('phone', models.CharField(default='', max_length=10)), 35 | ('table', models.CharField(default='take away', max_length=3)), 36 | ('order_time', models.DateTimeField()), 37 | ], 38 | ), 39 | migrations.CreateModel( 40 | name='rating', 41 | fields=[ 42 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 43 | ('name', models.CharField(max_length=30)), 44 | ('comment', models.CharField(max_length=250)), 45 | ('r_date', models.DateField()), 46 | ], 47 | ), 48 | migrations.CreateModel( 49 | name='User', 50 | fields=[ 51 | ('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 52 | ('password', models.CharField(max_length=128, verbose_name='password')), 53 | ('last_login', models.DateTimeField(blank=True, null=True, verbose_name='last login')), 54 | ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), 55 | ('first_name', models.CharField(blank=True, max_length=150, verbose_name='first name')), 56 | ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), 57 | ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), 58 | ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), 59 | ('date_joined', models.DateTimeField(default=django.utils.timezone.now, verbose_name='date joined')), 60 | ('phone', models.CharField(max_length=10, unique=True)), 61 | ('phone_verified', models.BooleanField(default=False)), 62 | ('cafe_manager', models.BooleanField(default=False)), 63 | ('groups', models.ManyToManyField(blank=True, help_text='The groups this user belongs to. A user will get all permissions granted to each of their groups.', related_name='user_set', related_query_name='user', to='auth.Group', verbose_name='groups')), 64 | ('user_permissions', models.ManyToManyField(blank=True, help_text='Specific permissions for this user.', related_name='user_set', related_query_name='user', to='auth.Permission', verbose_name='user permissions')), 65 | ], 66 | options={ 67 | 'verbose_name': 'user', 68 | 'verbose_name_plural': 'users', 69 | 'abstract': False, 70 | }, 71 | managers=[ 72 | ('objects', cafe.manager.UserManager()), 73 | ], 74 | ), 75 | ] 76 | -------------------------------------------------------------------------------- /pr1/settings.py: -------------------------------------------------------------------------------- 1 | """ 2 | Django settings for pr1 project. 3 | 4 | Generated by 'django-admin startproject' using Django 4.1.2. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.1/topics/settings/ 8 | 9 | For the full list of settings and their values, see 10 | https://docs.djangoproject.com/en/4.1/ref/settings/ 11 | """ 12 | import os 13 | from pathlib import Path 14 | 15 | # Build paths inside the project like this: BASE_DIR / 'subdir'. 16 | BASE_DIR = Path(__file__).resolve().parent.parent 17 | 18 | # Quick-start development settings - unsuitable for production 19 | # See https://docs.djangoproject.com/en/4.1/howto/deployment/checklist/ 20 | 21 | # SECURITY WARNING: keep the secret key used in production secret! 22 | SECRET_KEY = 'django-insecure-^#ku(-=1nwd8wnfe&1eri+k)_(8g@!n*#p3&!i4=!!c)&rhl3v' 23 | 24 | # SECURITY WARNING: don't run with debug turned on in production! 25 | DEBUG = True 26 | USE_TZ = False 27 | 28 | ALLOWED_HOSTS = [ 29 | 'e0398dde-191c-43d5-8dfc-bc9e465afc40.id.repl.co', 30 | 'pr1.dhootkaushik.repl.co' 31 | ] 32 | 33 | # Application definition 34 | 35 | INSTALLED_APPS = [ 36 | 'django.contrib.admin', 37 | 'django.contrib.auth', 38 | 'django.contrib.contenttypes', 39 | 'django.contrib.sessions', 40 | 'django.contrib.messages', 41 | 'django.contrib.staticfiles', 42 | 'django.contrib.humanize', 43 | 'cafe', 44 | ] 45 | 46 | MIDDLEWARE = [ 47 | 'django.middleware.security.SecurityMiddleware', 48 | 'django.contrib.sessions.middleware.SessionMiddleware', 49 | 'django.middleware.common.CommonMiddleware', 50 | 'django.middleware.csrf.CsrfViewMiddleware', 51 | 'django.contrib.auth.middleware.AuthenticationMiddleware', 52 | 'django.contrib.messages.middleware.MessageMiddleware', 53 | 'django.middleware.clickjacking.XFrameOptionsMiddleware', 54 | ] 55 | 56 | ROOT_URLCONF = 'pr1.urls' 57 | 58 | TEMPLATES = [ 59 | { 60 | 'BACKEND': 'django.template.backends.django.DjangoTemplates', 61 | 'DIRS': ['templates', 'static'], 62 | 'APP_DIRS': True, 63 | 'OPTIONS': { 64 | 'context_processors': [ 65 | 'django.template.context_processors.debug', 66 | 'django.template.context_processors.request', 67 | 'django.contrib.auth.context_processors.auth', 68 | 'django.contrib.messages.context_processors.messages', 69 | ], 70 | }, 71 | }, 72 | ] 73 | 74 | WSGI_APPLICATION = 'pr1.wsgi.application' 75 | 76 | # Database 77 | # https://docs.djangoproject.com/en/4.1/ref/settings/#databases 78 | 79 | DATABASES = { 80 | 'default': { 81 | 'ENGINE': 'django.db.backends.sqlite3', 82 | 'NAME': BASE_DIR / 'db.sqlite3', 83 | } 84 | } 85 | 86 | # Password validation 87 | # https://docs.djangoproject.com/en/4.1/ref/settings/#auth-password-validators 88 | 89 | AUTH_PASSWORD_VALIDATORS = [ 90 | { 91 | 'NAME': 92 | 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator', 93 | }, 94 | { 95 | 'NAME': 96 | 'django.contrib.auth.password_validation.MinimumLengthValidator', 97 | }, 98 | { 99 | 'NAME': 100 | 'django.contrib.auth.password_validation.CommonPasswordValidator', 101 | }, 102 | { 103 | 'NAME': 104 | 'django.contrib.auth.password_validation.NumericPasswordValidator', 105 | }, 106 | ] 107 | 108 | # Internationalization 109 | # https://docs.djangoproject.com/en/4.1/topics/i18n/ 110 | 111 | LANGUAGE_CODE = 'en-us' 112 | 113 | TIME_ZONE = 'UTC' 114 | 115 | USE_I18N = True 116 | 117 | USE_TZ = True 118 | 119 | # Static files (CSS, JavaScript, Images) 120 | # https://docs.djangoproject.com/en/4.1/howto/static-files/ 121 | 122 | # Default primary key field type 123 | # https://docs.djangoproject.com/en/4.1/ref/settings/#default-auto-field 124 | 125 | DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField' 126 | 127 | # Created Manually 128 | 129 | AUTH_USER_MODEL = 'cafe.User' 130 | 131 | STATIC_URL = 'static/' 132 | STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static')] 133 | 134 | MEDIA_URL = '/media/' 135 | MEDIA_ROOT = os.path.join(BASE_DIR, 'media/') 136 | -------------------------------------------------------------------------------- /templates/signup.html: -------------------------------------------------------------------------------- 1 | {% extends 'base.html' %} 2 | 3 | 4 | 5 | {%block title%}SignUp{%endblock title%} 6 | 7 | {% block body %} 8 | 9 |
10 |
11 |
12 |
13 |
14 | 15 |

Sign up

16 | {% for message in messages %} 17 | 21 | {% endfor %} 22 | 23 |
24 | {% csrf_token %} 25 | 26 |
27 | 28 |
29 | 30 | 31 |
32 |
33 | 34 |
35 | 36 |
37 | 38 | 39 |
40 |
41 | 42 |
43 | 44 |
45 | 46 | 47 |
48 |
49 | 50 |
51 | 52 |
53 | 54 | 55 | 59 |
60 |
61 | 62 |
63 | 64 |
65 | 66 | 67 |
68 |
69 | 70 |
71 | 73 |

Already have an account! Login

75 |
76 | 77 |
78 | 79 |
80 |
81 | 82 | Sample image 84 | 85 |
86 |
87 |
88 |
89 |
90 | 91 | {% endblock body %} -------------------------------------------------------------------------------- /templates/base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | {% block title %}{% endblock title %} || Cafe 7 | 8 | 9 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 103 | 104 | 105 | 106 | 107 | 108 | {% block body %} {% endblock body %} 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | {%block js%}{%endblock js%} 118 | 133 | 134 | -------------------------------------------------------------------------------- /cafe/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, redirect, get_object_or_404 2 | from django.contrib.auth import authenticate, get_user_model, login, logout 3 | from django.contrib import messages 4 | from cafe.models import * 5 | from django.core.files.storage import FileSystemStorage 6 | from datetime import date, datetime, timedelta 7 | import json, ast 8 | from itertools import groupby 9 | from django.db.models import Sum 10 | 11 | User = get_user_model() 12 | 13 | 14 | def menu(request): 15 | context = {} 16 | 17 | menu_items = menu_item.objects.all().order_by('list_order') 18 | items_by_category = {} 19 | 20 | for key, group in groupby(menu_items, key=lambda x: x.category): 21 | items_by_category[key] = list(group) 22 | 23 | context = {'items_by_category': items_by_category} 24 | 25 | return render(request, 'menu.html', context) 26 | 27 | 28 | def all_orders(request): 29 | 30 | context = {} 31 | orders = order.objects.all().order_by('-order_time') 32 | order_by_table = {} 33 | 34 | for key, group in groupby(orders, key=lambda x: x.table): 35 | order_by_table[key] = list(group) 36 | 37 | for table, orders in order_by_table.items(): 38 | for ord in orders: 39 | items_json_str = ord.items_json 40 | ord.items_json = json.loads(items_json_str) 41 | 42 | context = {'order_by_table': order_by_table} 43 | 44 | return render(request, 'all_orders.html', context) 45 | 46 | 47 | def offers(request): 48 | return render(request, 'offers.html') 49 | 50 | 51 | def reviews(request): 52 | 53 | if request.method == 'POST': 54 | fname = request.user.first_name 55 | lname = request.user.last_name 56 | cmt = request.POST.get('comment') 57 | date_today = date.today() 58 | 59 | review = rating(name=fname + ' ' + lname, 60 | comment=cmt, 61 | r_date=date_today) 62 | review.save() 63 | 64 | all_reviews = rating.objects.all().order_by('-r_date') 65 | context = {} 66 | context['reviews'] = all_reviews 67 | 68 | return render(request, 'reviews.html', context) 69 | 70 | 71 | def profile(request): 72 | if request.user.is_anonymous: 73 | messages.error(request, 'Please Login first!!') 74 | return redirect('login') 75 | return render(request, 'profile.html') 76 | 77 | 78 | def manage_menu(request): 79 | if request.method == 'POST' and request.FILES['img']: 80 | if (request.user.is_anonymous): 81 | messages.error(request, 'Please Login to continue!') 82 | return redirect('login') 83 | if not ((request.user.is_superuser) or (request.user.cafe_manager)): 84 | messages.error(request, 'Only Staff members are allowed!') 85 | return redirect('menu') 86 | else: 87 | name = request.POST.get('name') 88 | price = request.POST.get('price') 89 | desc = request.POST.get('desc') 90 | cat = request.POST.get('cat') 91 | img = request.FILES['img'] 92 | 93 | if cat.lower() == 'papad': 94 | lising_order = 1 95 | elif cat.lower() == 'starter': 96 | listing_order = 2 97 | elif cat.lower() == 'bread': 98 | listing_order = 4 99 | elif cat.lower() == 'gravy': 100 | listing_order = 3 101 | elif cat.lower() == 'dal': 102 | listing_order = 5 103 | elif cat.lower() == 'rice': 104 | listing_order = 6 105 | elif cat.lower() == 'dessert': 106 | listing_order = 7 107 | elif cat.lower() == 'beverage': 108 | listing_order = 8 109 | 110 | dish = menu_item(name=name, 111 | price=price, 112 | desc=desc, 113 | category=cat.lower(), 114 | pic=img, 115 | list_order=listing_order) 116 | dish.save() 117 | messages.success(request, 'Dish added successfully!') 118 | return redirect('menu') 119 | 120 | return render( 121 | request, 122 | 'manage_menu.html', 123 | ) 124 | 125 | 126 | def delete_dish(request, item_id): 127 | 128 | dish = get_object_or_404(menu_item, id=item_id) 129 | if request.user.is_superuser: 130 | if request.method == 'POST': 131 | dish.delete() 132 | messages.success(request, 'Dish removed successfully!') 133 | return redirect('menu') 134 | else: 135 | messages.error(request, 'Only admins are allowed!') 136 | return redirect('menu') 137 | 138 | 139 | def cart(request): 140 | 141 | if request.method == 'POST': 142 | if request.user.is_anonymous: 143 | name = 'Unknown' 144 | phone = 'Unknown' 145 | else: 146 | name = request.user.first_name + ' ' + request.user.last_name 147 | phone = request.user.phone 148 | items_json = request.POST.get('items_json') 149 | table_number = request.POST.get('table_value') 150 | total = request.POST.get('price') 151 | print(total) 152 | 153 | now = datetime.now() 154 | now_ist = now + timedelta(hours=5, minutes=30) 155 | 156 | if table_number == 'null': 157 | table_number = 'Take Away' 158 | 159 | new_order = order(name=name, 160 | phone=phone, 161 | items_json=items_json, 162 | table=table_number, 163 | order_time=now_ist, 164 | price=total) 165 | new_order.save() 166 | 167 | if request.user.is_anonymous: 168 | messages.success( 169 | request, 170 | 'Order Placed!! Thanks for ordering. You can sign up to save your information!!' 171 | ) 172 | return redirect('/') 173 | else: 174 | 175 | usr = User.objects.get(phone=phone) 176 | usr.order_count += 1 177 | usr.save() 178 | messages.success(request, 'Order Placed!! Thanks for ordering') 179 | return redirect('my_orders') 180 | 181 | return render(request, 'cart.html') 182 | 183 | 184 | def my_orders(request): 185 | 186 | phone = request.user.phone 187 | 188 | context = {} 189 | orders = order.objects.filter(phone=phone) 190 | order_by_table = {} 191 | 192 | for key, group in groupby(orders, key=lambda x: x.table): 193 | order_by_table[key] = list(group) 194 | for table, orders in order_by_table.items(): 195 | for ord in orders: 196 | items_json_str = ord.items_json 197 | ord.items_json = json.loads(items_json_str) 198 | 199 | context = {'order_by_table': order_by_table} 200 | 201 | return render(request, 'my_orders.html', context) 202 | 203 | 204 | def Login(request): 205 | 206 | if request.method == 'POST': 207 | phone = request.POST.get('phone') 208 | password = request.POST.get('password') 209 | 210 | user = authenticate(phone=phone, password=password) 211 | 212 | if user is not None: 213 | login(request, user) 214 | messages.success(request, 'Logged in successfully !') 215 | return redirect('profile') 216 | 217 | else: 218 | messages.error(request, 'Login failed, Invalid Credentials!') 219 | return redirect('login') 220 | 221 | return render(request, 'login.html') 222 | 223 | 224 | def Logout(request): 225 | logout(request) 226 | messages.success(request, 'Logged out successfully !') 227 | return redirect('login') 228 | 229 | 230 | def signup(request): 231 | 232 | if request.method == "POST": 233 | fname = request.POST.get('fname') 234 | lname = request.POST.get('lname') 235 | phone = request.POST.get('number') 236 | pass_word = request.POST.get('password') 237 | c_pass_word = request.POST.get('cpassword') 238 | 239 | if User.objects.filter(phone=phone).exists(): 240 | messages.error( 241 | request, 242 | 'Mobile number already regestired. Please Login to continue') 243 | return redirect('login') 244 | 245 | my_user = User.objects.create_user(phone=phone, password=pass_word) 246 | my_user.first_name = fname 247 | my_user.last_name = lname 248 | my_user.save() 249 | messages.success(request, 'User created successfully !!') 250 | 251 | return redirect('login') 252 | 253 | return render(request, 'signup.html') 254 | 255 | 256 | def generate_bill(request): 257 | t_number = request.GET.get('table') 258 | 259 | order_for_table = order.objects.filter(table=t_number, bill_clear=False) 260 | total_bill = 0 261 | now = datetime.now() 262 | now_ist = now + timedelta(hours=5, minutes=30) 263 | 264 | bill_items = [] 265 | c_name = '' 266 | c_phone = '' 267 | for o in order_for_table: 268 | total_bill += int(o.price) 269 | o.bill_clear = True 270 | o.save() 271 | 272 | bill_items.append({ 273 | 'order_items': o.items_json, 274 | }) 275 | c_name = o.name 276 | c_phone = o.phone 277 | 278 | order_dict = {} 279 | for item in bill_items: 280 | for key, value in item.items(): 281 | order_items = json.loads(value) 282 | for pr_key, pr_value in order_items.items(): 283 | order_dict[pr_value[1].lower()] = [ 284 | pr_value[0], (pr_value[2] * pr_value[0]) 285 | ] 286 | new_bill = bill(order_items=order_dict, 287 | name=c_name, 288 | bill_total=total_bill, 289 | phone=c_phone, 290 | bill_time=now_ist) 291 | new_bill.save() 292 | 293 | context = {} 294 | 295 | context = { 296 | 'order_dict': order_dict, 297 | 'bill_total': total_bill, 298 | 'name': c_name, 299 | 'phone': c_phone, 300 | 'inv_id': new_bill.id, 301 | } 302 | return render(request, 'generate_bill.html', context) 303 | 304 | 305 | def view_bills(request): 306 | 307 | if request.user.is_anonymous: 308 | messages.error(request, 'You Must be an admin user to view this!') 309 | return redirect('') 310 | 311 | all_bills = bill.objects.all().order_by('-bill_time') 312 | 313 | for b in all_bills: 314 | b.order_items = ast.literal_eval(b.order_items) 315 | 316 | context = {'bills': all_bills} 317 | 318 | return render(request, 'bills.html', context) 319 | --------------------------------------------------------------------------------