def addNotebook(subject, teacher, className): subject = subject.lower().strip() teacher = teacher.lower().strip() className = className.lower().strip() return asJson(dh.addNotebook(subject, teacher, className)) pass
def get(self, userPin): # strip search and convert to lower-case userPin = userPin.strip().lower() searchResult = DatabaseHandling.searchNearByShops(userPin) if searchResult is not 'Empty' and searchResult is not False: return searchResult else: return toJson(searchResult)
def get(self, userCity): # strip search and convert to lower-case userCity = userCity.strip().lower() searchResult = DatabaseHandling.searchInUserCity(userCity) if searchResult is not 'Empty' and searchResult is not False: return searchResult else: return toJson(searchResult)
def get(self, search): # strip search and convert to lower-case search = search.strip().lower() searchResult = DatabaseHandling.searchBox(search) if searchResult is not 'Empty' and searchResult is not False: return searchResult else: return toJson(searchResult)
def get(self, selectedCategory): # strip search and convert to lower-case selectedCategory = selectedCategory.strip().lower() searchResult = DatabaseHandling.searchByCategory(selectedCategory) if searchResult is not 'Empty' and searchResult is not False: return searchResult else: return toJson(searchResult)
def createAccount(name, email, password, confirmPassword): # creates new account name = name.lower().strip() email = email.lower().strip() if password == confirmPassword: return asJson(dh.createAccount(name, email, password)) else: return asJson('Passwords did not match!') pass
def get(self, of, email): # strip strings and convert to lower-case email = email.strip().lower() of = of.strip().lower() isDataFetched = DatabaseHandling.getUserOwnerInfo(of, email) if isDataFetched is not False: return isDataFetched else: return toJson(isDataFetched)
def get(self, email, shopId, note, book): """ :param book: '1': book slot, '0': ask slot details """ # strip strings and convert to lower-case email = email.strip().lower() shopId = shopId.strip() note = note.strip() book = book.strip().lower() if book == '0': book = False else: book = True # step 1: check isShopTakingBookings isShopTakingBookings = DatabaseHandling.isShopTakingBookings(shopId) print(isShopTakingBookings) if isShopTakingBookings is True: # step 2: check current queue AND `time_req_per_customer` is exceeding `closing_time` or not # and insert data in the database """ Before inserting check that the current slot time provided by the program is clashing with already booked-slot (of some other shop and the slot timing is clashing each other) or not. Hence, in slot-clashing case, slot booking is cancelled. """ isBookingDone = DatabaseHandling.isBookingDone( shopId, email, note, book) if isBookingDone is True: # booking is done successfully # now, generate TOKEN number for user (Token number: n'th slot position of user for the day (today)) isTokenGenerated, tokenNumber = DatabaseHandling.generateToken( email, shopId) if isTokenGenerated is True: # token generated. token generated will be sent to the user via email # sending email to user and owner DatabaseHandling.sendEmailNotificationToUser( email, shopId, tokenNumber) DatabaseHandling.sendEmailNotificationToOwner( userEmail=email, shopId=shopId, tokenNumber=tokenNumber) # return isBookingDone (True) rather than token number or email sent status return toJson(isBookingDone) else: return toJson( "True") # this statement will be never executed else: return toJson(isBookingDone) else: return toJson('Shop is currently not taking any booking requests.')
def post(self, of, email): # strip strings and convert to lower-case of = of.strip().lower() email = email.strip().lower() # check email isEmailValid = Validation.validateEmail(email) if isEmailValid == 'True': isDeleted = DatabaseHandling.deleteAccount(of, email) return toJson(isDeleted) else: return toJson(isEmailValid)
def get(self, of, phone, email): # strip strings and convert to lower-case of = of.strip().lower() phone = phone.strip() email = email.strip().lower() # check phone isPhoneValid = Validation.validatePhone(phone) if isPhoneValid == 'True': # check email isEmailValid = Validation.validateEmail(email) if isEmailValid == 'True': isSent = DatabaseHandling.findAccount(of, phone, email) # OTP sent. Display message: OTP has been sent. If not received then press findAccount button again DatabaseHandling.sendEmailVerification(phone, email) return toJson(isSent) else: return toJson(isEmailValid) else: return toJson(isPhoneValid)
def get(self, of, email, otp): # strip strings and convert to lower-case of = of.strip().lower() email = email.strip().lower() otp = otp.strip() # check email isEmailValid = Validation.validateEmail(email) if isEmailValid == 'True': isVerified = DatabaseHandling.verifyOTP(of, email, otp) return toJson(isVerified) else: return toJson(isEmailValid)
def get(self, filter, email): """ :param filter: 'upcoming' or 'earlier' """ # strip strings and convert to lower-case filter = filter.strip().lower() email = email.strip().lower() # get events getEvents = DatabaseHandling.getUserEvents(filter, email) if getEvents is not 'Empty' and getEvents is not False: return getEvents else: return toJson(getEvents)
def get(self, loginAs, email, password): # strip strings and convert to lower-case email = email.strip().lower() # check email isEmailValid = Validation.validateEmail(email) if isEmailValid == 'True': isCorrect = DatabaseHandling.login(loginAs, email, password) if isCorrect == True: print('You are logged in ') return toJson(True) else: return toJson('Check validity, password, email and try again') else: return toJson(isEmailValid)
def get(self, phone, email): # strip strings and convert to lower-case phone = phone.strip() email = email.strip().lower() # check phone isPhoneValid = Validation.validatePhone(phone) if isPhoneValid == 'True': # check email isEmailValid = Validation.validateEmail(email) if isEmailValid == 'True': isSent = DatabaseHandling.sendEmailVerification(phone, email) return toJson(isSent) else: return toJson(isEmailValid) else: return toJson(isPhoneValid)
def get(self, userName, address, city, pinCode, phone, email, password, confirmPassword): print('received user info') # strip strings and convert to lower-case userName = userName.strip().lower() address = address.strip().lower() city = city.strip().lower() pinCode = pinCode.strip() phone = phone.strip() email = email.strip().lower() # match passwords isPasswordMatched = Validation.matchPasswords(password, confirmPassword) if isPasswordMatched != 'True': return toJson(isPasswordMatched) if userName == '' or address == '' or city == '' or pinCode == '' or phone == '' or email == '' or password == '': return toJson('field(s) found empty') # check pin isPinValid = Validation.validatePinCode(pinCode) if isPinValid == 'True': # check phone isPhoneValid = Validation.validatePhone(phone) if isPhoneValid == 'True': # check email isEmailValid = Validation.validateEmail(email) if isEmailValid == 'True': isInserted = DatabaseHandling.insertUserDataIntoDB( userName, address, city, pinCode, phone, email, password) return toJson(isInserted) else: return toJson(isEmailValid) else: return toJson(isPhoneValid) else: return toJson(isPinValid)
def post(self, of, email, otp, password, confirmPassword): # strip strings and convert to lower-case of = of.strip().lower() email = email.strip().lower() otp = otp.strip() # match passwords isPasswordMatched = Validation.matchPasswords(password, confirmPassword) if isPasswordMatched != 'True': return toJson(isPasswordMatched) # check email isEmailValid = Validation.validateEmail(email) if isEmailValid == 'True': isPasswordChanged = DatabaseHandling.changePassword( of, otp, email, password) return toJson(isPasswordChanged) else: return toJson(isEmailValid)
def post(self, userName, address, city, pinCode, phone, email): # strip strings and convert to lower-case userName = userName.strip().lower() address = address.strip().lower() city = city.strip().lower() pinCode = pinCode.strip().lower() phone = phone.strip().lower() # check pinCode isPinValid = Validation.validatePinCode(pinCode) if isPinValid == 'True': # check phone isPhoneValid = Validation.validatePhone(phone) if isPhoneValid == 'True': # now, update data to the database isUpdated = DatabaseHandling.updateUserInfo( userName, address, city, pinCode, phone, email) return toJson(isUpdated) else: return toJson(isPhoneValid) else: return toJson(isPinValid)
def login(email, password): # logging in email = email.lower().strip() return asJson(dh.login(email, password)) pass
def getNotebookDetails(subject): subject = subject.strip().lower() return dh.getNotebookDetails(subject) pass
def get(self, shopName, ownerName, shopType, openingTime, closingTime, timeReqPerUser, address, city, pinCode, phone, email, password, confirmPassword): print('received owner info') # strip strings and convert to lower-case shopName = shopName.strip().lower() ownerName = ownerName.strip().lower() shopType = shopType.strip().lower() openingTime = openingTime.strip() closingTime = closingTime.strip() timeReqPerUser = timeReqPerUser.strip() address = address.strip().lower() city = city.strip().lower() pinCode = pinCode.strip() phone = phone.strip() email = email.strip().lower() if shopName == '' or ownerName == '' or shopType == '' or openingTime == '' or closingTime == '' or timeReqPerUser == '' or address == '' or city == '' or pinCode == '' or phone == '' or email == '' or password == '': return toJson('field(s) found empty') # match passwords isPasswordMatched = Validation.matchPasswords(password, confirmPassword) if isPasswordMatched != 'True': return toJson(isPasswordMatched) # check pin isPinValid = Validation.validatePinCode(pinCode) if isPinValid == 'True': # check phone isPhoneValid = Validation.validatePhone(phone) if isPhoneValid == 'True': # check email isEmailValid = Validation.validateEmail(email) if isEmailValid == 'True': # check openingTime isOpeningTimeValid = Validation.validateOpeningClosingTime( openingTime) if isOpeningTimeValid == 'True': # check closingTime isClosingTimeValid = Validation.validateOpeningClosingTime( closingTime) if isClosingTimeValid == 'True': # check timeReqPerUser isTimeReqPerUserValid = Validation.validateTimeRequiredPerUser( timeReqPerUser) if isTimeReqPerUserValid == 'True': # check (by comparing) shop opening and closing time is valid or not isShopTimingValid = Validation.validateCompareOpeningClosingTimeMismatch( openingTime, closingTime) if isShopTimingValid == 'True': # all inputs verified; now, insert data into database isInserted = DatabaseHandling.insertOwnerDataIntoDB( shopName, ownerName, shopType, openingTime, closingTime, timeReqPerUser, address, city, pinCode, phone, email, password) return toJson(isInserted) else: return toJson(isShopTimingValid) else: return toJson(isTimeReqPerUserValid) else: return toJson(isClosingTimeValid) else: return toJson(isOpeningTimeValid) else: return toJson(isEmailValid) else: return toJson(isPhoneValid) else: return toJson(isPinValid)
@app.route('/add/notebook/<string:subject>/<string:teacher>/<string:className>' ) def addNotebook(subject, teacher, className): subject = subject.lower().strip() teacher = teacher.lower().strip() className = className.lower().strip() return asJson(dh.addNotebook(subject, teacher, className)) pass @app.route('/notebook/details/<string:subject>') def getNotebookDetails(subject): subject = subject.strip().lower() return dh.getNotebookDetails(subject) pass @app.route('/login/<string:email>/<string:password>') def login(email, password): # logging in email = email.lower().strip() return asJson(dh.login(email, password)) pass dh.start() app.run(debug=True)
def get(self, shopId, filter): """ :param filter: 'upcoming' or 'earlier' """ getBookings = DatabaseHandling.getShopBookings(shopId, filter) return toJson(getBookings)
def get(self, shopId, variable): # set `is_open` as 0/1 in `owner` isSet = DatabaseHandling.setShopBooking(shopId, variable) return toJson(isSet)
def atStarting(): # call this function first most DatabaseHandling.start()
def post(self, shopName, ownerName, shopType, openingTime, closingTime, timeReqPerUser, address, city, pinCode, phone, email): # this function updates owner's information in the database (except email, shop_id). # owner cannot update account during working hours # strip strings and convert to lower-case email = email.strip() shopName = shopName.strip().lower() ownerName = ownerName.strip().lower() shopType = shopType.strip().lower() openingTime = openingTime.strip().lower() closingTime = closingTime.strip().lower() timeReqPerUser = timeReqPerUser.strip().lower() address = address.strip().lower() city = city.strip().lower() pinCode = pinCode.strip().lower() phone = phone.strip().lower() # check openingTime isOpeningTimeValid = Validation.validateOpeningClosingTime(openingTime) if isOpeningTimeValid == 'True': # check closingTime isClosingTimeValid = Validation.validateOpeningClosingTime( closingTime) if isClosingTimeValid == 'True': # check timeReqPerUser isTimeReqPerUserValid = Validation.validateTimeRequiredPerUser( timeReqPerUser) if isTimeReqPerUserValid == 'True': # check pinCode isPinCodeValid = Validation.validatePinCode(pinCode) if isPinCodeValid == 'True': # check phone isPhoneValid = Validation.validatePhone(phone) if isPhoneValid == 'True': # check (by comparing) shop opening and closing time is valid or not isShopTimingValid = Validation.validateCompareOpeningClosingTimeMismatch( openingTime, closingTime) if isShopTimingValid == 'True': # update data in the database (account cannot be updated during working hours) isUpdated = DatabaseHandling.updateOwnerInfo( shopName, ownerName, shopType, openingTime, closingTime, timeReqPerUser, address, city, pinCode, phone, email) return toJson(isUpdated) else: return toJson(isShopTimingValid) else: return toJson(isPhoneValid) else: return toJson(isPinCodeValid) else: return toJson(isTimeReqPerUserValid) else: return toJson(isClosingTimeValid) else: return toJson(isOpeningTimeValid)