Created Migrations. Cleaned views python file.

parent cce212e0
# Generated by Django 4.0 on 2021-12-15 03:27
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('main', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='BaseFlavor',
fields=[
('bf_id', models.AutoField(primary_key=True, serialize=False)),
('bf_name', models.CharField(max_length=255)),
],
options={
'db_table': 'base_flavor',
'managed': False,
},
),
migrations.CreateModel(
name='Customer',
fields=[
('customer_id', models.AutoField(primary_key=True, serialize=False)),
('customer_name', models.CharField(max_length=255)),
],
options={
'db_table': 'customer',
'managed': False,
},
),
migrations.CreateModel(
name='Ingredient',
fields=[
('ingredient_id', models.AutoField(primary_key=True, serialize=False)),
('ingredient_name', models.CharField(max_length=255)),
('quantity', models.IntegerField()),
('price_per_serving', models.FloatField()),
('replenished_stock', models.CharField(choices=[('Y', 'Y'), ('N', 'N')], max_length=1)),
],
options={
'db_table': 'ingredient',
'managed': False,
},
),
migrations.CreateModel(
name='Item',
fields=[
('item_id', models.AutoField(primary_key=True, serialize=False)),
('io_quantity', models.IntegerField()),
('total_sales', models.FloatField()),
],
options={
'db_table': 'item',
'managed': False,
},
),
migrations.CreateModel(
name='Orders',
fields=[
('order_id', models.AutoField(primary_key=True, serialize=False)),
('order_date', models.DateField()),
],
options={
'db_table': 'orders',
'managed': False,
},
),
migrations.CreateModel(
name='Size',
fields=[
('size_id', models.AutoField(primary_key=True, serialize=False)),
('serv_size', models.CharField(choices=[('8', '8'), ('12', '12'), ('16', '16')], max_length=2)),
],
options={
'db_table': 'size',
'managed': False,
},
),
]
......@@ -6,12 +6,60 @@
# * Remove `managed = False` lines if you wish to allow Django to create, modify, and delete the table
# Feel free to rename the models, but don't rename db_table values or field names.
from django.db import models
from django.db.models.fields import *
class BaseFlavor(models.Model):
bf_id = models.AutoField(primary_key=True)
bf_name = models.CharField(max_length=255)
class Meta:
managed = False
db_table = 'base_flavor'
class Customer(models.Model):
customer_id = models.AutoField(primary_key=True)
customer_name = models.CharField(max_length=255)
class Meta:
managed = False
db_table = 'customer'
class Ingredient(models.Model):
REPLENISHED_STOCK = [
('Y', 'Y'),
('N', 'N'),
]
ingredient_id = models.AutoField(primary_key=True)
ingredient_name = models.CharField(max_length=255)
quantity = models.IntegerField()
price_per_serving = models.FloatField()
replenished_stock = models.CharField(max_length=1, choices=REPLENISHED_STOCK)
class Meta:
managed = False
db_table = 'ingredient'
class Size(models.Model):
SIZES = [
('8', '8'),
('12', '12'),
('16', '16'),
]
size_id = models.AutoField(primary_key=True)
serv_size = models.CharField(max_length=2, choices=SIZES)
class Meta:
managed = False
db_table = 'size'
class Employee(models.Model):
employee_id = models.IntegerField(primary_key=True)
employee_name = models.CharField(max_length=255)
def __str__(self):
return self.employee_name
class Meta:
managed = False
db_table = 'employee'
......@@ -36,11 +84,33 @@ class EmployeeRole(models.Model):
role_description = models.CharField(max_length=20, choices=ROLES)
is_manager = models.CharField(max_length=1, choices=IS_MANAGER)
def employeename(self):
return self.employee.employee_name
def __str__(self):
return self.employee.employee_name + " is tasked for " + self.role_description
class Meta:
managed = False
db_table = 'employeerole'
class Item(models.Model):
item_id = models.AutoField(primary_key=True)
bf = models.ForeignKey(BaseFlavor, models.DO_NOTHING)
ingredient = models.ForeignKey(Ingredient, models.DO_NOTHING)
size = models.ForeignKey(Size, models.DO_NOTHING)
io_quantity = models.IntegerField()
total_sales = models.FloatField()
def ingredientname(self):
return self.ingredient.ingredient_name, self.size.serv_size, self.bf.bf_name
class Meta:
managed = False
db_table = 'item'
class Orders(models.Model):
order_id = models.AutoField(primary_key=True)
customer_id = models.ForeignKey(Customer, models.DO_NOTHING)
item_id = models.ForeignKey(Item, models.DO_NOTHING)
employee_id = models.ForeignKey(Employee, models.DO_NOTHING)
order_date = models.DateField()
class Meta:
managed = False
db_table = 'orders'
\ No newline at end of file
......@@ -33,15 +33,11 @@ def schedule(request):
)
# 1: FILTER EMPLOYEES BY MANAGER FOR THE DAY - mate
def manager_query(request):
ismanager_query = EmployeeRole.objects.all().filter(is_manager='Y')
return render(request, "blizzardblast/templates/queries/manager_query.html", {'manager': ismanager_query})
# 3 : FILTER BY WEEK - dedz
def week_query(request):
week_query1 = EmployeeRole.objects.all().filter(
role_date__range=["2025-09-01", "2025-09-06"]).order_by('role_date')
......@@ -53,8 +49,6 @@ def week_query(request):
)
# 4: FILTER EMPLOYEES BY ROLES - xtine
def role_query(request):
role_query1 = EmployeeRole.objects.all().filter(role_description='Cashier')
role_query2 = EmployeeRole.objects.all().filter(role_description='Preparation')
......@@ -64,9 +58,8 @@ def role_query(request):
}
)
# 2: FILTER EMPLOYEES IN ALPHABETICAL ORDER - felizia
def alphabetical_query(request):
# 2: FILTER EMPLOYEES IN ALPHABETICAL ORDER - felizia
alphabetical_query = EmployeeRole.objects.order_by(
'employee__employee_name')
for i in alphabetical_query:
......
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