Commit cdb1469f authored by Matthew Dizon's avatar Matthew Dizon

initial commit

parents
Pipeline #1917 canceled with stages
"""
ASGI config for GrabGrub project.
It exposes the ASGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/
"""
import os
from django.core.asgi import get_asgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'GrabGrub.settings')
application = get_asgi_application()
"""
Django settings for GrabGrub project.
Generated by 'django-admin startproject' using Django 3.0.5.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.0/ref/settings/
"""
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.0/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'nrr5g9=i@%33lcy07ajuxiw#%gmp3e@f94%e8x!0gkhwe+0gs-'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'Kiosk',
]
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 = 'GrabGrub.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'GrabGrub.wsgi.application'
# Database
# https://docs.djangoproject.com/en/3.0/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/3.0/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/3.0/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/3.0/howto/static-files/
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
"""GrabGrub URL Configuration
The `urlpatterns` list routes URLs to views. For more information please see:
https://docs.djangoproject.com/en/3.0/topics/http/urls/
Examples:
Function views
1. Add an import: from my_app import views
2. Add a URL to urlpatterns: path('', views.home, name='home')
Class-based views
1. Add an import: from other_app.views import Home
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
Including another URLconf
1. Import the include() function: from django.urls import include, path
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
"""
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('', include('Kiosk.urls'))
]
"""
WSGI config for GrabGrub project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'GrabGrub.settings')
application = get_wsgi_application()
from django.contrib import admin
from .models import *
# Register your models here.
admin.site.register(Account)
admin.site.register(Food)
admin.site.register(Customer)
admin.site.register(Order)
\ No newline at end of file
from django.apps import AppConfig
class KioskConfig(AppConfig):
name = 'Kiosk'
# Generated by Django 3.0.5 on 2021-05-26 22:56
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Account',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('username', models.CharField(max_length=250)),
('password', models.CharField(max_length=250)),
],
),
migrations.CreateModel(
name='Customer',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=250)),
('address', models.CharField(max_length=250)),
('city', models.CharField(max_length=250)),
],
),
migrations.CreateModel(
name='Food',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=250)),
('description', models.CharField(max_length=250)),
('price', models.FloatField(max_length=250)),
('created_at', models.DateTimeField(auto_now_add=True)),
],
),
migrations.CreateModel(
name='Order',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('qty', models.FloatField(max_length=250)),
('ordered_at', models.DateTimeField(auto_now_add=True)),
('payment_mode', models.CharField(choices=[('Cash', 'Cash'), ('Card', 'Card')], default='Cash', max_length=4)),
('cust_order', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Kiosk.Customer')),
('food', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='Kiosk.Food')),
],
),
]
from django.db import models
# Create your models here.
class Account(models.Model):
username = models.CharField(max_length=250)
password = models.CharField(max_length=250)
def getUsername(self):
return f"{self.username}"
def getPassword(self):
return f"{self.password}"
def __str__(self):
return f"Username: {self.username}, Password: {self.password}"
class Food(models.Model):
name = models.CharField(max_length=250)
description = models.CharField(max_length=250)
price = models.FloatField(max_length=250)
created_at = models.DateTimeField(auto_now_add=True)
def getName(self):
return f"{self.name}"
def getDesc(self):
return f"{self.description}"
def getPrice(self):
return f"{self.price}"
def __str__(self):
return f"{self.pk}: {self.name} - {self.price}, {self.description} created at: {self.created_at}"
class Customer(models.Model):
name = models.CharField(max_length=250)
address = models.CharField(max_length=250)
city = models.CharField(max_length=250)
def getName(self):
return f"{self.name}"
def getAddress(self):
return f"{self.address}"
def getCity(self):
return f"{self.city}"
def __str__(self):
return f"{self.pk}: {self.name} - {self.address}, {self.city}"
class Order(models.Model):
CASH = "Cash"
CARD = "Card"
PAYMENT_MODE_CHOICES = [
(CASH, "Cash"),
(CARD, "Card")
]
food = models.ForeignKey(Food, on_delete=models.CASCADE)
qty = models.FloatField(max_length=250)
ordered_at = models.DateTimeField(auto_now_add=True)
cust_order = models.ForeignKey(Customer, on_delete=models.CASCADE)
payment_mode = models.CharField(max_length=4, choices=PAYMENT_MODE_CHOICES, default=CASH)
def getMode(self):
return f"{self.payment_mode}"
def getQuantity(self):
return f"{self.qty}"
def __str__(self):
return f"{self.pk}: Order PK: {self.food} ({self.qty}). For {self.cust_order}: {self.cust_order.getAddress()}, {self.cust_order.getCity()}. {self.payment_mode}, ordered at {self.ordered_at}"
\ No newline at end of file
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
/*!
* Bootstrap Reboot v4.4.1 (https://getbootstrap.com/)
* Copyright 2011-2019 The Bootstrap Authors
* Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
html {
font-family: sans-serif;
line-height: 1.15;
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
article, aside, figcaption, figure, footer, header, hgroup, main, nav, section {
display: block;
}
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #212529;
text-align: left;
background-color: #fff;
}
[tabindex="-1"]:focus:not(:focus-visible) {
outline: 0 !important;
}
hr {
box-sizing: content-box;
height: 0;
overflow: visible;
}
h1, h2, h3, h4, h5, h6 {
margin-top: 0;
margin-bottom: 0.5rem;
}
p {
margin-top: 0;
margin-bottom: 1rem;
}
abbr[title],
abbr[data-original-title] {
text-decoration: underline;
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
cursor: help;
border-bottom: 0;
-webkit-text-decoration-skip-ink: none;
text-decoration-skip-ink: none;
}
address {
margin-bottom: 1rem;
font-style: normal;
line-height: inherit;
}
ol,
ul,
dl {
margin-top: 0;
margin-bottom: 1rem;
}
ol ol,
ul ul,
ol ul,
ul ol {
margin-bottom: 0;
}
dt {
font-weight: 700;
}
dd {
margin-bottom: .5rem;
margin-left: 0;
}
blockquote {
margin: 0 0 1rem;
}
b,
strong {
font-weight: bolder;
}
small {
font-size: 80%;
}
sub,
sup {
position: relative;
font-size: 75%;
line-height: 0;
vertical-align: baseline;
}
sub {
bottom: -.25em;
}
sup {
top: -.5em;
}
a {
color: #007bff;
text-decoration: none;
background-color: transparent;
}
a:hover {
color: #0056b3;
text-decoration: underline;
}
a:not([href]) {
color: inherit;
text-decoration: none;
}
a:not([href]):hover {
color: inherit;
text-decoration: none;
}
pre,
code,
kbd,
samp {
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: 1em;
}
pre {
margin-top: 0;
margin-bottom: 1rem;
overflow: auto;
}
figure {
margin: 0 0 1rem;
}
img {
vertical-align: middle;
border-style: none;
}
svg {
overflow: hidden;
vertical-align: middle;
}
table {
border-collapse: collapse;
}
caption {
padding-top: 0.75rem;
padding-bottom: 0.75rem;
color: #6c757d;
text-align: left;
caption-side: bottom;
}
th {
text-align: inherit;
}
label {
display: inline-block;
margin-bottom: 0.5rem;
}
button {
border-radius: 0;
}
button:focus {
outline: 1px dotted;
outline: 5px auto -webkit-focus-ring-color;
}
input,
button,
select,
optgroup,
textarea {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
button,
input {
overflow: visible;
}
button,
select {
text-transform: none;
}
select {
word-wrap: normal;
}
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
button:not(:disabled),
[type="button"]:not(:disabled),
[type="reset"]:not(:disabled),
[type="submit"]:not(:disabled) {
cursor: pointer;
}
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
padding: 0;
border-style: none;
}
input[type="radio"],
input[type="checkbox"] {
box-sizing: border-box;
padding: 0;
}
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"] {
-webkit-appearance: listbox;
}
textarea {
overflow: auto;
resize: vertical;
}
fieldset {
min-width: 0;
padding: 0;
margin: 0;
border: 0;
}
legend {
display: block;
width: 100%;
max-width: 100%;
padding: 0;
margin-bottom: .5rem;
font-size: 1.5rem;
line-height: inherit;
color: inherit;
white-space: normal;
}
progress {
vertical-align: baseline;
}
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
[type="search"] {
outline-offset: -2px;
-webkit-appearance: none;
}
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-file-upload-button {
font: inherit;
-webkit-appearance: button;
}
output {
display: inline-block;
}
summary {
display: list-item;
cursor: pointer;
}
template {
display: none;
}
[hidden] {
display: none !important;
}
/*# sourceMappingURL=bootstrap-reboot.css.map */
\ No newline at end of file
This diff is collapsed.
/*!
* Bootstrap Reboot v4.4.1 (https://getbootstrap.com/)
* Copyright 2011-2019 The Bootstrap Authors
* Copyright 2011-2019 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/*,::after,::before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus:not(:focus-visible){outline:0!important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0;-webkit-text-decoration-skip-ink:none;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent}a:hover{color:#0056b3;text-decoration:underline}a:not([href]){color:inherit;text-decoration:none}a:not([href]):hover{color:inherit;text-decoration:none}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg{overflow:hidden;vertical-align:middle}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}select{word-wrap:normal}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]:not(:disabled),[type=reset]:not(:disabled),[type=submit]:not(:disabled),button:not(:disabled){cursor:pointer}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none!important}
/*# sourceMappingURL=bootstrap-reboot.min.css.map */
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 40px;
line-height: 40px;
color: white;
text-align: center;
}
\ No newline at end of file
.navbar-custom {
background-color: #800020;
}
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
{% load static %}
<html>
<head>
<title>Inventory System</title>
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700|Material+Icons">
<link rel="stylesheet" href="{% static '/bootstrap/css/bootstrap.css' %}">
<link rel="stylesheet" href="{% static '/bootstrap/css/custom.css' %}">
<script src="{% static '/bootstrap/jquery-3.4.1.slim.min.js' %}"></script>
<script src="{% static '/bootstrap/popper.min.js' %}"></script>
<script src="{% static '/bootstrap/js/bootstrap.min.js' %}"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-light mb-3 sticky-top">
<a class="navbar-brand mb-0" href="/">GrabGrub</a>
<ul class="navbar-nav">
<li class="nav-item mx-2">
Miguel Bandelaria | 191735
</li>
<li class="nav-item mx-2">
Matthew Dizon | 191735
</li>
<li class="nav-item mx-2">
Jansen Lao | 191735
</li>
</ul>
</nav>
<div class="container-fluid">
<div class="col justify-content-center mb-5">
{% block content %}
{% endblock %}
</div>
</div>
<footer class="footer bg-light" style="position: fixed;">
<!-- Copyright -->
<div class="container" style="color: black">&copy; 2020</div>
<!-- Copyright -->
</footer>
</body>
</html>
\ No newline at end of file
{% extends 'Kiosk/base.html' %}
{% load static %}
{% block sidenav %}
<ul class="nav flex-column">
<li class="nav-item">
<a class="nav-link" href="/view_suppliers"> View Suppliers </a>
</li>
<li class="nav-item">
<a class="nav-link" href="/view_bottles"> View Bottles </a>
</li>
<li class="nav-item">
<a class="nav-link" href="/add_bottle"> Add Bottle </a>
</li>
</ul>
{% endblock %}
{% block content %}
<section class="jumbotron text-center">
<div class="container">
<h1 class="jumbotron-heading">Matthew Dizon</h1>
<p>Module 5 Lab - Templates</p>
</div>
</section>
<div class="container marketing text-center">
<div class="row">
<div class="col-lg-4">
<h2>Suppliers</h2>
<p>View the details of the suppliers</p>
<p><a class="btn btn-secondary" href="/view_suppliers" role="button">View details »</a></p>
</div>
<div class="col-lg-4">
<h2>Bottles</h2>
<p>View the details of the bottles</p>
<p><a class="btn btn-secondary" href="/view_bottles" role="button">View details »</a></p>
</div>
<div class="col-lg-4">
<h2>Add Bottle</h2>
<p>Add bottles to the inventory</p>
<p><a class="btn btn-secondary" href="/add_bottle" role="button">View details »</a></p>
</div>
</div>
</div>
<div class="col-12">
<table class="table table-striped">
<thead>
<th scope="col"> Customer </th>
<th scope="col"> Food Ordered </th>
<th scope="col"> Date of Order </th>
<th scope="col"></th>
</thead>
<tbody>
{% for order in orders %}
<tr>
<td> {{ order.cust_order.getName }} </td>
<td> {{ order.food.getName }} </td>
<td> {{ order.ordered_at }} </td>
<td><a href="{% url 'view_order_details' order.pk %}"><button class="btn btn-dark">Details</button></a></td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% endblock %}
\ No newline at end of file
{% extends 'Kiosk/base.html' %}
{% load static %}
{% block content %}
<div class="w-50" style="margin-left: 24%">
<form class="form-signin" method="POST" action="{% url 'login' %}">
{% csrf_token %}
<div class="text-center mb-4">
<div class="h3 mb-3 font-weight-normal">Enter User Details:</div>
<p>Login to GrabGrub</p>
</div>
<div class="form-label-group mt-3">
<input name="username" id="inputEmail" class="form-control" placeholder="Username" required="" autofocus="">
</div>
<div class="form-label-group mt-3">
<input name ="password" type="password" id="inputPassword" class="form-control" placeholder="Password" required="">
</div>
<button class="btn btn-lg btn-primary btn-block mt-3" type="submit">Login</button>
</form>
<a href="{% url 'signup' %}"><button class="btn btn-lg btn-primary btn-block mt-3">Sign Up</button></a>
{% if message == "Account created successfully" %}
<p class="mt-3 alert alert-success"> {{message}}</p>
{% elif message == "Account deleted successfully" %}
<p class="mt-3 alert alert-success"> {{message}}</p>
{% elif message %}
<p class="mt-3 alert alert-danger"> {{message}}</p>
{% endif %}
</div>
{% endblock %}
\ No newline at end of file
{% extends 'Kiosk/base.html' %}
{% load static %}
{% block content %}
<div class="w-50" style="margin-left: 24%">
<form class="form-signin" method="POST" action="{% url 'signup' %}">
{% csrf_token %}
<div class="text-center mb-4">
<div class="h3 mb-3 font-weight-normal">Enter User Details:</div>
<p>Signup to GrabGrub</p>
</div>
<div class="form-label-group mt-3">
<input name="username" id="inputEmail" class="form-control" placeholder="Username" required="" autofocus="">
</div>
<div class="form-label-group mt-3">
<input name ="password" type="password" id="inputPassword" class="form-control" placeholder="Password" required="">
</div>
<input type="hidden" name="message" value="Account created successfully">
<button class="btn btn-lg btn-primary btn-block mt-3" type="submit">Sign Up</button>
</form>
<a href="{% url 'login' %}"><button class="btn btn-lg btn-primary btn-block mt-3">Login</button></a>
{% if message == "Account created successfully" %}
<p class="mt-3 alert alert-success"> {{message}}</p>
{% elif message == "Account deleted successfully" %}
<p class="mt-3 alert alert-success"> {{message}}</p>
{% elif message %}
<p class="mt-3 alert alert-danger"> {{message}}</p>
{% endif %}
</div>
{% endblock %}
\ No newline at end of file
{% extends 'Kiosk/base.html' %}
{% load static %}
{% block content %}
</div>
<div class="card w-75">
<div class="card-header">
Order Details:
</div>
<form method="POST" action="{% url 'update_order' pk=order.pk %}">{% csrf_token %}
<div class="form-group">
<label for="name"> Food: </label>
<input type="text" class="form-control" id="food" name="food" value="{{order.food.getName}}" disabled>
</div>
<div class="form-group">
<label for="name"> Quantity: </label>
<input type="text" class="form-control" id="qty" name="qty" value="{{order.qty}}" required>
</div>
<div class="form-group">
<label for="name"> Date of Order: </label>
<input type="text" class="form-control" id="date" name="date" value="{{order.ordered_at}}" disabled>
</div>
<div class="form-group">
<label for="name"> Customer: </label>
<input type="text" class="form-control" id="customer" name="customer" value="{{order.cust_order.getName}}" disabled>
</div>
<div class="form-group">
<label for="name"> Mode of Payment: </label>
<select name="payment_mode" class="form-select" style="max-width: 200px; margin-right: 75px;" required>
{% if order.payment_mode == "Cash" %}
<option value="Cash" selected>Cash</option>
<option value="Card">Card</option>
{% else %}
<option value="Cash">Cash</option>
<option value="Card" selected>Card</option>
{% endif %}
</select>
</div>
<a href="{% url 'update_order' order.pk %}"><button type="submit" class="mt-3 btn btn-primary">Update Order</button></a>
</form>
</div>
{% endblock %}
{% extends 'Kiosk/base.html' %}
{% load static %}
{% block content %}
<div class="card w-75">
<div class="card-header">
Order Details:
</div>
<ul class="list-group list-group-flush">
<li class="list-group-item"><span style="color: #8AB4F8; font-weight:bold">Food: </span> {{order.food.getName}}</li>
<li class="list-group-item"><span style="color: #8AB4F8; font-weight:bold">Quantity: </span> {{order.qty}}</li>
<li class="list-group-item"><span style="color: #8AB4F8; font-weight:bold">Date of Order: </span> {{order.ordered_at}}</li>
<li class="list-group-item"><span style="color: #8AB4F8; font-weight:bold">Customer: </span> {{order.cust_order.getName}}</li>
<li class="list-group-item"><span style="color: #8AB4F8; font-weight:bold">Mode of Payment: </span> {{order.payment_mode}}</li>
</ul>
</div>
<form action="#" method="post">
{% csrf_token %}
<input type="hidden" name="message" value="Bottle deleted successfully">
<a href="#"><button class="btn btn-secondary my-4">Delete Order</button></a>
</form>
<a href="{% url 'update_order' order.pk %}"><button type="submit" class="mt-3 btn btn-primary">Update Order</button></a>
<a onclick="window.history.go(-1); return false;"><button class="btn btn-secondary">Back</button></a>
{% endblock %}
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.urls import path
from . import views
urlpatterns = [
path('', views.login_view, name='login'),
path('signup', views.signup_view, name="signup"),
path('logout', views.logout_view, name="logout"),
path('home', views.home, name="home"),
path('view_order_details/<int:pk>', views.view_order_details, name="view_order_details"),
path('update_order/<int:pk>', views.update_order, name="update_order"),
]
\ No newline at end of file
from django.shortcuts import render, redirect, get_object_or_404
from .models import *
# Create your views here.
def home(request):
orders = Order.objects.all()
context = {"orders": orders}
return render(request, 'Kiosk/home.html', context)
def view_order_details(request, pk):
order = get_object_or_404(Order, pk=pk)
context = {"order": order}
# url = request.META.get('HTTP_REFERER')
# request.session['url'] = url
# print(url)
return render(request, 'Kiosk/view_order_details.html', context)
def update_order(request, pk):
if(request.method=="POST"):
qty = request.POST.get('qty')
payment_mode = request.POST.get('payment_mode')
Order.objects.filter(pk=pk).update(qty=qty, payment_mode=payment_mode)
return redirect('view_order_details', pk=pk)
else:
order = get_object_or_404(Order, pk=pk)
context = {"order": order}
return render(request, 'Kiosk/update_order.html', context)
### Views for Account Model
def login_view(request):
if request.method == "POST":
username = request.POST.get('username')
password = request.POST.get('password')
try:
account = Account.objects.get(username=username)
except:
return render(request, 'Kiosk/login.html', {'message':'Invalid Login: User Does Not Exist'})
if password == account.password:
return redirect("home")
else:
return render(request, 'Kiosk/login.html', {'message':'Invalid Login: Incorrect Password'})
else:
if request.GET.get('message') == None:
context = {'message': ''}
else:
context = {'message':request.GET.get('message')}
return render(request, 'Kiosk/login.html', context)
def signup_view(request):
if request.method == "POST":
username = request.POST.get('username')
password = request.POST.get('password')
try:
account = Account.objects.get(username=username)
except:
if username != "" and password != "":
Account.objects.create(username=username, password=password)
message=request.POST.get('message')
return redirect(f"/?message={message}")
elif username == "":
return render(request, 'Kiosk/signup.html', {'message':'Please enter a username'})
elif password == "":
return render(request, 'Kiosk/signup.html', {'message':'Please enter a password'})
if account:
return render(request, 'Kiosk/signup.html', {'message':'Account already exists'})
else:
return render(request, 'Kiosk/signup.html', {'message':''})
def logout_view(request):
return redirect('/')
### Views for Food Model
### Views for Customer Model
### Views for Order Model
\ No newline at end of file
#!/usr/bin/env python
"""Django's command-line utility for administrative tasks."""
import os
import sys
def main():
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'GrabGrub.settings')
try:
from django.core.management import execute_from_command_line
except ImportError as exc:
raise ImportError(
"Couldn't import Django. Are you sure it's installed and "
"available on your PYTHONPATH environment variable? Did you "
"forget to activate a virtual environment?"
) from exc
execute_from_command_line(sys.argv)
if __name__ == '__main__':
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment