Ejemplo n.º 1
0
 def __init__(self, name, owner, priceDay, priceHalf):
     self.id = None
     self.name = name
     self.priceDay = priceDay
     self.priceHalf = priceHalf
     self.owner = owner
     self.description = None
     self.toolController = ToolController()
     self.calendarController = CalendarController()
     self.userController = UserController()
Ejemplo n.º 2
0
 def updateUserToolsList(self):
     self.listOfUserToolsWidget.delete(0, tk.END)
     self.listOfUserTools.clear()
     self.listOfUserTools = ToolController().findAllToolsHiredByUser(
         self.loggedUser)
     self.chargeLabel.config(
         text=UserController().getUserCurrentCharge(self.loggedUser))
     for tool in self.listOfUserTools:
         self.listOfUserToolsWidget.insert(tk.END, tool)
Ejemplo n.º 3
0
    def createAccount(self):
        userName=self.loginEntry.get()
        password=self.passwordEntry.get()
        user=User(userName, password)
        try:
            if(UserController().saveUserToDatabase(user)):
                messagebox.showinfo("Message", "ACCOUNT CREATED")
            else:
                messagebox.showinfo("ERROR", "LOGIN ALREADY TAKEN")

        except:
            messagebox.showinfo("ERROR","IDK ERR")
Ejemplo n.º 4
0
 def login(self):
     userName=self.loginEntry.get()
     password=self.passwordEntry.get()
     user=UserController().findUser(userName)
     try:
         if(password==user.password):
             self.master.withdraw()
             MainWindow(user,root)
             print("LOGGING IN...")
         else:
             messagebox.showinfo("ERROR","INCORRECT PASSWORD")
     except:
         messagebox.showinfo("ERROR","INCORRECT LOGIN")
    def bookButtonClick(self):
        values = [self.listOfDatesWidget.get(idx) for idx in self.listOfDatesWidget.curselection()  if self.listOfDatesWidget.get(idx).split('_')[1]=="FREE"]
        toolTmp=ToolController().findTool(self.selectedTool)
        price=0
        if (values.__len__() > 3):
            messagebox.showinfo("TO MANY DAYS", "YOU CAN ONLY PICK 3 DAYS AT THE SAME TIME")
        else:
            if(self.bookType.get()):
                typeOfBooking="HALF"
            else: typeOfBooking="DAY"
            for value in values:
                date = value.split('_')[0]
                price=price+toolTmp.book(datetime.strptime(date,"%Y-%m-%d").date(),self.loggedUser,1,typeOfBooking)
            UserController().addChargeForUser(self.INSURANCE,self.loggedUser)

            messageWindow=MessageWindow(self.loggedUser,price,self.var,self,self.INSURANCE)
            self.withdraw()
            messageWindow.wait_window()
            self.destroy()
            self.owner.updateUserToolsList()
Ejemplo n.º 6
0
 def saveUser(self):
     UserController().saveUserToDatabase(self)
     return self
Ejemplo n.º 7
0
class Tool():
    def __init__(self, name, owner, priceDay, priceHalf):
        self.id = None
        self.name = name
        self.priceDay = priceDay
        self.priceHalf = priceHalf
        self.owner = owner
        self.description = None
        self.toolController = ToolController()
        self.calendarController = CalendarController()
        self.userController = UserController()

    def __str__(self):
        return "{0}_{1}_{2}_{3}".format(self.name, self.owner, self.priceDay,
                                        self.priceHalf)

    def saveToolToDatabase(self):
        self.toolController.saveToolToDatabase(self)
        self.calendarController.saveToolCalendar(self.name)

    def getCalendar(self):
        calendarRow = self.calendarController.getCalendarForTool(self)
        return calendarRow

    def book(self, dateToBook, userName, days=1, type="DAY"):
        if days in range(1, 4):
            for i in range(0, days):
                self.calendarController.bookToolForDate(
                    self, dateToBook + timedelta(i), userName, type)
            if type == "HALF":
                charge = self.priceHalf * days
            else:
                charge = self.priceDay * days
            self.userController.addChargeForUser(charge, userName)
            return (charge)
        else:
            print("BOOKING LIMIT UP TO 3 DAYS")
            return None

    def giveBack(self, returningDate, userName):
        cal = self.getCalendar()
        datesForUser = []
        for i in range(0, cal.__len__()):
            if cal[i][1].lower() == userName + "_day" or cal[i][1].lower(
            ) == userName + "_half":
                datesForUser.append(cal[i][0])
                dateToReturn = datetime.strptime(cal[i][0], '%Y-%m-%d').date()
                CalendarController().returnTool(self, dateToReturn)
        lastDate = datetime.strptime(datesForUser[datesForUser.__len__() - 1],
                                     '%Y-%m-%d').date()
        dif = (returningDate - lastDate).days
        extraCharge = 0
        if dif > 0:
            extraCharge = dif * self.priceDay * 2
            newCharge = self.userController.getUserCurrentCharge(
                userName) + extraCharge
            self.userController.addChargeForUser(newCharge, userName)
        else:
            dif = 0
        return (dif, extraCharge)

    def getDescription(self):
        return ToolController().getDescriptionForTool(self.name)

    def setDescription(self, desc):
        ToolController().setDescriptionForTool(self.name, desc)
Ejemplo n.º 8
0
 def iluminatiFunction(self, eve):
     messagebox.showinfo("ILLUMINATI IS HERE!",
                         UserController().wholeUsersCharge())