stc

a simple time card webapp
git clone _git@git.brennen.work:stc.git
Log | Files | Refs | README

commit 6e868d5dd272354bc9eaae22bf3c6cc53e782c35
parent ab88dbd0e1bb949d22919dd4be5630a9d2708da3
Author: Nikolas Mazur <nikolas@pop-os.localdomain>
Date:   Thu, 12 Jan 2023 15:44:10 -0700

Create basic database models

Diffstat:
Amodel.py | 93+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 93 insertions(+), 0 deletions(-)

diff --git a/model.py b/model.py @@ -0,0 +1,92 @@ +import pydantic +import datetime + +from fastapi.encoders import jsonable_encoder +from pydantic import BaseModel, Field + +class Users(BaseModel): + _id:[PydanticObjectId] = Field(None, alias="_id") + slug: str + username: str + role: str + location: str + phone: int + email: str + active: bool + pay_period: str + pay_value: float + + def to_json(self): + return jsonable_encoder(self, exclude_none=True) + + def to_bson(self): + data = self.dict(by_alias=True, exclude_none=True) + + if data["_id"] is None: + data.pop("_id") + return data + + +class Time(BaseModel): + _id: str + # forign key + clock_in: datetime.utcnow #System time + modified_by: str #link to _id of user + date: datetime.date + project: str + clock_out: datetime.utcnow #System time + note: str + perdium: bool + total_time: int #clock_out - clock_in + + def to_json(self): + return jsonable_encoder(self, exclude_none=True) + + def to_bson(self): + data = self.dict(by_alias=True, exclude_none=True) + + if data["_id"] is None: + data.pop("_id") + return data + + +class Fleet(BaseModel): + _id: int + date: datetime.date + operator: int #forign key to userID + safety_checks: bool #array for different safety checks + additional_notes: str + vehicle: int #vehicleID + incident_report: str + mileage: int + + def to_json(self): + return jsonable_encoder(self, exclude_none=True) + + def to_bson(self): + data = self.dict(by_alias=True, exclude_none=True) + + if data["_id"] is None: + data.pop("_id") + return data + + +class Agreement(BaseModel): + _id: int #forign key to user + start_date: int + end_date: int + bid_document: str #Filepath to document + budget: float + cost: int + projects: [ + project_id: int + project_name: str + project_budget: [ + labor_budget: float + travel_budget: int + supplies_budget: int + contact_budget: int + equipment_budget: int + other: complex + ] + ] +\ No newline at end of file