def set_time(self, start, end): if self.is_before(start, end): if self.max_one_month(start, end): self.holday['begin'] = start self.holday['end'] = end return True else: Popup("Non puoi fare piu di un mese di vacanza!", ALERT).exec_() else: Popup("Date invertite!", ALERT).exec_() return False
def set_time(self, start, end): if self.is_same_day(start, end): if self.is_before(start, end): duration = self.get_duration(start, end) if duration >= 30: self.activity['date'] = start self.activity['duration'] = self.get_duration(start, end) return True else: Popup("Durata di almeno 30 minuti!", ALERT).exec_() else: Popup("Attenzione agli orari!", ALERT).exec_() else: Popup("Deve iniziare e finire nello stesso giorno!", ALERT).exec_() return False
def insert(self): self.activity = dict() self.activity['name'] = self.set_name() start = self.get_date(self.dtm_start) end = self.get_date(self.dtm_end) if not (self.activity['name'] and self.set_time(start, end) and self.set_description()): return False self.activity['location'] = int( self.data['locations'][self.index_location].keys()[0]) self.activity['group'] = 0 self.activity['participants'] = [int(self.data['creator'].keys()[0])] self.activity['creator'] = int(self.data['creator'].keys()[0]) self.activity['type'] = self.data['type'] self.activity['project'] = self.data['informations']['activity'][ 'project'] if self.data['type'] != "single" and not self.set_group_project(): return False if self.data['functions'].insert_activity(self.activity): self.data['functions'].change_day(self.dtm_start.date()) self.close() else: Popup( "Ricontrolla se la tua nuova attivita' non collide con delle altre!", ALERT).exec_()
def set_description(self): description = str(self.txt_description.toPlainText()).strip() if description != "": self.activity['description'] = description return True else: Popup("Inserire descrizione!", ALERT).exec_() return False
def set_group_project(self): if self.data['type'] == "group": self.activity['group'] = int( self.data['groups'][self.index_group].keys()[0]) else: self.activity['group'] = self.data['project_group'] participants = self.get_checked() if len(participants) < 2: Popup("Almeno 2 partecipanti!", ALERT).exec_() return False self.activity['participants'] = participants return True
def insert(self): self.holday = dict() self.holday['name'] = self.set_name() if not self.holday['name']: return False start = self.get_date(self.dtm_start) end = self.get_date(self.dtm_end) if not self.set_time(start, end): return False if self.data['functions'].insert_holiday(self.holday): self.data['functions'].change_day(self.dtm_start.date()) self.close() else: Popup("Ricontrolla se la tua vacanza non collide con delle tue attivita'!", ALERT).exec_()
def delete(): Popup("Work in progess!!!! Stiamo lavorando per voi", NOTIFICATION).exec_()
def notify(notifications): if not notifications: return Popup("Sono presenti nuove notifiche!", NOTIFICATION).exec_()