Skip to content
4 changes: 3 additions & 1 deletion App/controllers/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ def get_admin(id):
return db.session.get(Admin, id)

def get_all_admins():
return db.session.scalars(db.select(Admin)).all()
return db.session.scalars(
db.select(Admin)
).all()

def get_all_admins_json():
admins = get_all_admins()
Expand Down
18 changes: 14 additions & 4 deletions App/controllers/bid.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
from App.models import Bid
from App.models import Bid, Evaluation
from App.database import db

def create_bid(lotID, sourceGroupID, receipientGroupID, bidDocumentLink):
newbid = Bid(lotID, sourceGroupID, receipientGroupID, bidDocumentLink)
def create_bid(lotID, sourceGroupID, recipientGroupID, bidDocument, bidDocumentName, quotationAmount):
newbid = Bid(lotID, sourceGroupID, recipientGroupID, bidDocument, bidDocumentName, quotationAmount)
db.session.add(newbid)
db.session.commit()
return newbid
Expand All @@ -11,7 +11,9 @@ def get_bid(id):
return db.session.get(Bid, id)

def get_all_bids():
return db.session.scalars(db.select(Bid)).all()
return db.session.scalars(
db.select(Bid)
).all()

def get_all_bids_json():
bids = get_all_bids()
Expand All @@ -23,6 +25,14 @@ def get_all_bids_json():
def remove_bid(id):
bid = get_bid(id)
if bid:
evaluations = db.session.scalars(
db.select(Evaluation)
.filter_by(bidID=bid.id)
)

for evaluation in evaluations:
db.session.delete(evaluation)

db.session.delete(bid)
db.session.commit()
return True
Expand Down
40 changes: 26 additions & 14 deletions App/controllers/evaluation.py
Original file line number Diff line number Diff line change
@@ -1,36 +1,46 @@
from App.models import Evaluation
from App.database import db

def create_evaluation(sourceGroupID, receipientGroupID, bidID, lotID, specsMet, presentation, professionalism, budget):
neweval = Evaluation(sourceGroupID, receipientGroupID, bidID, lotID, specsMet, presentation, professionalism, budget)
def create_evaluation(sourceGroupID, recipientGroupID, bidID, lotID, specsMet, presentation, professionalism, budget):
neweval = Evaluation(sourceGroupID, recipientGroupID, bidID, lotID, specsMet, presentation, professionalism, budget)
db.session.add(neweval)
db.session.commit()
return neweval

def edit_evaluation(id, specsMet, presentation, professionalism, budget, deviceType=None, resolution=None, os=None, cpu=None, ram=None, drive=None, gpu=None, peripherals=None, features=None, io=None):
def edit_evaluation(id, specsMet, presentation, professionalism, budget, specsSelected=None, deviceType=None, resolution=None, os=None, cpu=None, ram=None, drive=None, gpu=None, peripherals=None, features=None, io=None):
eva = get_evaluation(id)
if eva:
eva.overallScore = round((((specsMet + presentation + professionalism + budget)/25) * 10), 1)

if deviceType:
if specsMet is not None:
eva.specsMet = specsMet
if presentation is not None:
eva.presentation = presentation
if professionalism is not None:
eva.professionalism = professionalism
if budget is not None:
eva.budget = budget
if specsSelected is not None:
eva.specsSelected = specsSelected
if deviceType is not None:
eva.deviceType = deviceType
if resolution:
if resolution is not None:
eva.resolution = resolution
if os:
if os is not None:
eva.os = os
if cpu:
if cpu is not None:
eva.cpu = cpu
if ram:
if ram is not None:
eva.ram = ram
if drive:
if drive is not None:
eva.drive = drive
if gpu:
if gpu is not None:
eva.gpu = gpu
if peripherals:
if peripherals is not None:
eva.peripherals = peripherals
if features:
if features is not None:
eva.features = features
if io:
if io is not None:
eva.io = io

db.session.commit()
Expand All @@ -46,7 +56,9 @@ def get_evaluation(id):
return db.session.get(Evaluation, id)

def get_all_evaluations():
return db.session.scalars(db.select(Evaluation)).all()
return db.session.scalars(
db.select(Evaluation)
).all()

def get_all_evaluations_json():
evals = get_all_evaluations()
Expand Down
28 changes: 26 additions & 2 deletions App/controllers/group.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
from App.models import Group
from App.models import *
from .bid import remove_bid
from .evaluation import remove_evaluation
from .rfp import remove_rfp
from .studentGroup import remove_studentGroup
from .lotGroup import remove_lotGroup
from App.database import db
from sqlalchemy import or_

def create_group(groupName):
group = Group(groupName)
Expand All @@ -18,7 +24,9 @@ def get_group(id):
return db.session.get(Group, id)

def get_all_groups():
return db.session.scalars(db.select(Group)).all()
return db.session.scalars(
db.select(Group)
).all()

def get_all_groups_json():
groups = get_all_groups()
Expand All @@ -30,6 +38,22 @@ def get_all_groups_json():
def remove_group(id):
group = get_group(id)
if group:
members = db.session.scalars(
db.select(StudentGroup)
.filter_by(groupID=id)
).all()

for member in members:
remove_studentGroup(member.studentID, member.groupID)

lotGroups = db.session.scalars(
db.select(LotGroup)
.filter_by(groupID=id)
).all()

for lotGroup in lotGroups:
remove_lotGroup(lotGroup.lotID, lotGroup.groupID)

db.session.delete(group)
db.session.commit()
return True
Expand Down
38 changes: 36 additions & 2 deletions App/controllers/initialize.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,42 @@
from .user import create_user
from App.database import db

from .lot import create_lot, edit_lotRFP_details
from .student import create_student
from .admin import create_admin
from App.models import *

def initialize():
db.drop_all()
db.create_all()
create_user('bob', 'bobpass')

create_admin("bob", "bobpass")

create_lot("GIS Lab", "Medium, capable of having 20 machines", 160000.00)
create_lot("Government Office Lab", "Small, capable of having 10 machines", 110000.00)
create_lot("University Computer Lab", "Medium, capable of having 30 machines", 250000.00)
create_lot("Data Center", "Large, capable of having 500 machines", 25000000.00)
create_lot("Medical Imaging Lab", "Medium, capable of having 15 machines", 320000.00)
create_lot("Architecture & Design Studio", "Small, capable of having 12 machines", 195000.00)

edit_lotRFP_details(1, "Workstation Desktop", "Intel Core i9-13900K", "64GB DDR5", "27-inch 4K IPS", "Windows 11 Pro", "2TB NVMe SSD", "NVIDIA RTX 4080", "4x USB-A, 2x USB-C, HDMI 2.1, DisplayPort 1.4", "Mechanical Keyboard, Ergonomic Mouse, Drawing Tablet", "Webcam, WiFi 6E, Bluetooth 5.2")
edit_lotRFP_details(2, "Laptop", "AMD Ryzen 7 7745HX", "32GB DDR5", "15.6-inch FHD 144Hz", "Windows 11 Pro / Ubuntu 22.04 Dual Boot", "1TB NVMe SSD", "NVIDIA RTX 3060", "3x USB-A, 2x USB-C, HDMI 2.0, SD Card Reader", "Wireless Keyboard, Wireless Mouse, USB Hub", "Fingerprint Reader, WiFi 6, Bluetooth 5.0")
edit_lotRFP_details(3, "Desktop PC", "Intel Core i5-13400", "16GB DDR4", "24-inch FHD", "Windows 11 Home", "512GB NVMe SSD", "Intel UHD Graphics 730", "4x USB-A, 1x USB-C, HDMI 1.4, VGA", "Standard Keyboard, Optical Mouse", "Webcam, WiFi 5, Bluetooth 4.2")
edit_lotRFP_details(4, "High-Performance Workstation", "AMD Ryzen Threadripper 7960X", "128GB DDR5 ECC", "Dual 32-inch 4K", "Ubuntu 22.04 LTS", "4TB NVMe SSD RAID", "NVIDIA RTX 4090 x2", "6x USB-A, 4x USB-C, 2x Thunderbolt 4, Dual Ethernet", "Ergonomic Keyboard, Precision Mouse, USB-C Docking Station", "10GbE Network Card, WiFi 6E, Bluetooth 5.2, Liquid Cooling")
edit_lotRFP_details(5, "High-Performance Workstation", "Intel Xeon W-2295", "128GB DDR4 ECC", "Dual 27-inch 4K IPS", "Windows 11 Pro", "2TB NVMe SSD + 4TB HDD", "NVIDIA RTX A5000", "6x USB-A, 4x USB-C, 2x Thunderbolt 3, Dual Ethernet", "Medical-Grade Mouse, Ergonomic Keyboard, 3D Connexion SpaceMouse", "DICOM Compatibility, WiFi 6E, Bluetooth 5.2, ECC Memory Support")
edit_lotRFP_details(6, "High-End Desktop", "Intel Core i9-13900K", "64GB DDR5", "Dual 32-inch 4K OLED", "Windows 11 Pro", "2TB NVMe SSD + 2TB HDD", "NVIDIA RTX 4090", "4x USB-A, 4x USB-C, 2x Thunderbolt 4, SD Card Reader", "Wireless Ergonomic Keyboard, Precision Mouse, Drawing Tablet (Wacom)", "Pantone-Calibrated Display, WiFi 6E, Bluetooth 5.2, Hardware Color Calibrator")


create_student("jack", "20240123", "jackpass")
create_student("cooper", "20231245", "cooperpass")
create_student("john", "20229876", "johnpass")
create_student("ray", "20246789", "raypass")

create_student("tony", "20235678", "tonypass")
create_student("steve", "20242345", "stevepass")
create_student("clint", "20238901", "clintpass")
create_student("bruce", "20238902", "brucepass")

create_student("ultron", "20264789", "ultronpass")
create_student("thanos", "20242435", "thanospass")
create_student("loki", "20328901", "lokipass")
create_student("red skull", "20235342", "redskullpass")
45 changes: 31 additions & 14 deletions App/controllers/lot.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from App.models import Lot
from App.models import Lot, LotGroup
from App.database import db
from sqlalchemy.orm.attributes import flag_modified
from sqlalchemy import or_, and_

def create_lot(labType, labSize, budget):
newlot = Lot(labType, labSize, budget)
Expand All @@ -13,7 +14,9 @@ def get_lot(id):
return db.session.get(Lot, id)

def get_all_lots():
return db.session.scalars(db.select(Lot)).all()
return db.session.scalars(
db.select(Lot)
).all()

def get_all_lots_json():
lots = get_all_lots()
Expand All @@ -39,25 +42,25 @@ def edit_lot(id, labType=None, labSize=None, budget=None):
def edit_lotRFP_details(id, deviceType=None, resolution=None, os=None, cpu=None, ram=None, drive=None, gpu=None, peripherals=None, features=None, io=None):
lot = get_lot(id)
if lot:
if deviceType:
if deviceType is not None:
lot.deviceType = deviceType
if resolution:
if resolution is not None:
lot.resolution = resolution
if os:
if os is not None:
lot.os = os
if cpu:
if cpu is not None:
lot.cpu = cpu
if ram:
if ram is not None:
lot.ram = ram
if drive:
if drive is not None:
lot.drive = drive
if gpu:
if gpu is not None:
lot.gpu = gpu
if peripherals:
if peripherals is not None:
lot.peripherals = peripherals
if features:
if features is not None:
lot.features = features
if io:
if io is not None:
lot.io = io

db.session.commit()
Expand All @@ -71,7 +74,21 @@ def get_lotRFP_details_json(id):
return None

def remove_lot(id):
from .group import remove_group

lot = get_lot(id)
if lot:
db.session.delete(lot)
db.session.commit()
assigned = db.session.scalars(
db.select(LotGroup)
.filter_by(lotID=lot.id)
).first()

if not assigned:
db.session.delete(lot)
db.session.commit()
return True
else:
remove_group(assigned.groupID)
db.session.delete(lot)
db.session.commit()
return False
46 changes: 44 additions & 2 deletions App/controllers/lotGroup.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
from App.models import LotGroup
from App.models import LotGroup, RFP, Bid, Evaluation, Group
from App.database import db
from sqlalchemy import and_, or_
from .rfp import remove_rfp
from .bid import remove_bid
from .evaluation import remove_evaluation

def add_lotGroup(lotID, groupID):
newentry = LotGroup(lotID, groupID)
Expand All @@ -10,7 +14,9 @@ def get_lotGroup(lotID, groupID):
return db.session.get(LotGroup, (lotID, groupID))

def get_all_lotGroups():
return db.session.scalars(db.select(LotGroup)).all()
return db.session.scalars(
db.select(LotGroup)
).all()

def get_all_lotGroups_json():
entries = get_all_lotGroups()
Expand All @@ -22,6 +28,42 @@ def get_all_lotGroups_json():
def remove_lotGroup(lotID, groupID):
entry = get_lotGroup(lotID, groupID)
if entry:
nextLot = db.session.scalars(
db.select(LotGroup)
.filter(and_(LotGroup.groupID == groupID, LotGroup.lotID != lotID))
).first()

group = db.session.scalars(
db.select(Group)
.filter_by(id=groupID)
).first()

group.status = "pending"

rfps = db.session.scalars(
db.select(RFP)
.filter(or_(RFP.lotID == lotID, RFP.groupID == groupID))
).all()

for rfp in rfps:
remove_rfp(rfp.groupID, rfp.lotID)

bids = db.session.scalars(
db.select(Bid)
.filter(or_(Bid.lotID == lotID, Bid.sourceGroupID == groupID, Bid.recipientGroupID == groupID))
).all()

for bid in bids:
remove_bid(bid.id)

evals = db.session.scalars(
db.select(Evaluation)
.filter(or_(Evaluation.sourceGroupID == groupID, Evaluation.recipientGroupID == groupID, Evaluation.lotID == lotID))
).all()

for eva in evals:
remove_evaluation(eva.id)

db.session.delete(entry)
db.session.commit()
return True
Expand Down
15 changes: 13 additions & 2 deletions App/controllers/rfp.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from App.models import RFP
from App.models import RFP, Bid
from App.database import db
from .lot import get_lot
from .bid import remove_bid

def create_rfp(groupID, lotID):
rfp = RFP(groupID, lotID)
Expand Down Expand Up @@ -30,7 +31,9 @@ def get_rfp(groupID, lotID):
return db.session.get(RFP, (groupID, lotID))

def get_all_rfps():
return db.session.scalars(db.select(RFP)).all()
return db.session.scalars(
db.select(RFP)
).all()

def get_all_rfps_json():
rfps = get_all_rfps()
Expand All @@ -42,6 +45,14 @@ def get_all_rfps_json():
def remove_rfp(groupID, lotID):
rfp = get_rfp(groupID, lotID)
if rfp:
bids = db.session.scalars(
db.select(Bid)
.filter_by(lotID= lotID)
)

for bid in bids:
remove_bid(bid.id)

db.session.delete(rfp)
db.session.commit()
return True
Expand Down
Loading
Loading