def on_release(self): with open(self.name + MANAGER_FILE) as f: code = ''.join(f.readlines()) MessagePopup(message="resetting " + self.name + " database").open() exec(code) MessagePopup(message=self.name + " database successfully reset").open()
def confirm(self): ori_psw_input = self.ids.ori_psw_input ori_psw = ori_psw_input.text new_psw = self.ids.new_psw_input.text msg = Guest.change_psw(ori_psw, new_psw) if msg: # returned error message MessagePopup(message=msg).open() ori_psw_input.focus = True else: MessagePopup(message="Password changed successfully!").open() self.popup.dismiss()
def register(self): details = [] for widget in self.all_input: msg = widget.error if msg: MessagePopup(message=msg).open() return details.append(widget.value) Guest.register(*details) self._to_login() MessagePopup( message="Successfully registered! Please login to continue.").open( )
def book(self, *args): # handle unavailable situations if self.day <= Activity.BOOK_AHEAD: MessagePopup(message="There are no activities available for the first three days.").open() elif self.day < get_day(): MessagePopup(message="You can not book activities for days before!").open() elif self.day < get_day() + Activity.BOOK_AHEAD: MessagePopup(message="You need to book activities at least three days ahead!").open() else: # initiate and open activity picker popup activity_picker = ActivityPicker(day=self.day) activity_picker.refresh_ref = self # save for future update activity_picker.open()
def confirm(self): guest_db = TinyDB("guest.json") query = Query() day = int(self.ids.day_input.text) if day < 1 or day > 14: MessagePopup( message="day must be between 1 and 14 (boundary inclusive)" ).open() else: start_date = datetime.now() - timedelta(days=day - 1) guest_db.update({"start": start_date.strftime("%d%m%y")}, query.journey == "Kimberley Quest") MessagePopup(message="successfully updated start date to " + start_date.strftime("%d/%m/%y")).open()
def book(self, *args): if self.day <= get_day(): MessagePopup(message="You can not book meal for today or days before!").open() else: popup = MealPicker(day=self.day) popup.refresh_ref = self popup.open()
def update_profile(self): # save profile to data base if self.changed: for widget in self.all_input: widget.update() MessagePopup(message="Changes saved!").open() self.manager.current = "menu"
def check(self): if not self.text: return msg = self.error if msg: MessagePopup(message=msg).open() self.background_color = self.bg_color_invalid else: self.background_color = self.bg_color_valid
def login(self): usr_input = self.ids.usr_input psw_input = self.ids.psw_input msg = Guest.login(usr_input.text, psw_input.text) if msg: MessagePopup(message=msg).open() usr_input.focus = True else: usr_input.text = '' psw_input.text = '' root = App.get_running_app().root # main screen manager root.transition = CardTransition(direction="up", mode="pop") root.current = "menu"
def refresh(self): layout = self.ids.receipt_blocks layout.clear_widgets() receipt, total = Guest.costs() if receipt: for activity in receipt: # instantiate rows using activity objects layout.add_widget( ReceiptBlock(name=activity.name, day=activity.day, price=activity.price)) else: MessagePopup(message="You haven't booked any activity yet.").open() self.total = total
def _cancel(self): Guest.book_activity("activities", self.day, Activity.no_activity().name) self.parent.remove_widget(self) ReceiptLayout.single.total -= self.price MessagePopup(message="This activity is cancelled!")
def on_release(self): if self.unavailable: MessagePopup(message="You can not cancel this activity!").open() else: self.parent.parent.cancel()
def _update(self, *args): # update activity booking database Guest.book_activity("activities", self.day, self.name) MessagePopup(message="Booking saved!").open()
def undo(cls): cls.last[0].state = "down" # note the index is 0 next line because cls.last is updated last line cls.last[0].state = "normal" MessagePopup(message="Booking abandoned!").open()
def update(self, instance, value): if value == "down": Guest.book_activity("meals", self.day, self.name) MessagePopup(message="Meal booking saved!").open()