def on_dialog_change(self, widget): """call get_dialog_fields, call db.session_try_commit, response gtk.RESPONSE_OK""" self.get_dialog_fields() db.session_try_commit() self.dialog.obj.response(gtk.RESPONSE_OK)
def on_valid_password_clicked(self, widget): """check the user's password, check if both new password are identicals, change the change_pass_status in error case""" passwd = self.old_password.get_text() login = app.user.login md5passwd = md5.new(passwd) def query(db, login): return db.session.query(User).filter(User.login == login).first() user = db.session_query( query, login, "auth : query(User).filter(User.login==login(" + str(login) + ").first()") if app.user.password != md5passwd.hexdigest(): self.change_pass_status.set_markup( "Erreure: ancien mot de passe invalide") self.dialog_password.response(gtk.RESPONSE_OK) else: passwd1 = self.new_password1.get_text() passwd2 = self.new_password2.get_text() if passwd1 == passwd2: md5passwd = md5.new(passwd1) app.user.password = md5passwd.hexdigest() db.session_try_commit() self.dialog_password.response(gtk.RESPONSE_OK) else: self.change_pass_status.set_markup( "Erreure: les nouveaux mots de passe ne sont pas identiques" )
def query(db, obj): """callback for db.session_query, this query add obj to session and call db.session_try_commit""" db.session.add(obj.settings) db.session.add(obj.planning) db.session.add(obj) db.session_try_commit()
def on_add_event_clicked(self, widget): """call get_dialog_fields, add the object in session and call db.session_try_commit, return gtk.RESPONSE_OK""" self.get_dialog_fields() db.session.add(self) db.session_try_commit() self.dialog.obj.response(gtk.RESPONSE_OK)
def query(db, obj): """callback for db.session_query, this query add obj to session and call db.session_try_commit""" from Planning import Planning obj.planning = Planning() db.session.add(obj) db.session_try_commit()
def on_planning_theme_changed(self, widget, data=None): """when user change this setting, parse the selected theme in fullcalendar theme corresponding, call db.session_try_commit() and app.contentmgr.tabs_execute for change the theme""" app.settings.planning_theme = planning_themes['db_inv'][planning_themes['disp'][widget.get_active_text()]] db.session_try_commit() app.contentmgr.tabs_execute('change_theme', app.settings.planning_theme)
def on_dialog_add(self, widget): """call get_dialog_fields, add the object to the session and call db.session_try_commit, response gtk.RESPONSE_OK""" self.get_dialog_fields() db.session.add(self) db.session_try_commit() self.dialog.obj.response(gtk.RESPONSE_OK)
def on_menu_delete(self, widget): obj = self.current_obj self.dialog_confirmation.set_markup("Etes vous sûre de vouloir supprimer l'utilisateur " + obj.name + " " + obj.firstname + " ?") if self.dialog_confirmation.run() == gtk.RESPONSE_OK: db.session.delete(obj) db.session_try_commit() TreeMgmt.replug_parents(obj) self.dialog_confirmation.hide() self.current_obj = None
def on_planning_theme_changed(self, widget, data=None): """when user change this setting, parse the selected theme in fullcalendar theme corresponding, call db.session_try_commit() and app.contentmgr.tabs_execute for change the theme""" app.settings.planning_theme = planning_themes['db_inv'][ planning_themes['disp'][widget.get_active_text()]] db.session_try_commit() app.contentmgr.tabs_execute('change_theme', app.settings.planning_theme)
def on_menu_remove(self, widget): obj = self.current_obj self.dialog_confirmation.set_markup( "Etes vous sûr de vouloir retirer la période " + obj.name + " ?") if self.dialog_confirmation.run() == gtk.RESPONSE_OK: obj.classes.remove(obj.classe) db.session_try_commit() for id in obj.row: obj.row[id].tree.replug(obj.row[id].obj_parent) self.dialog_confirmation.hide() self.current_obj = None
def on_menu_delete(self, widget): obj = self.current_obj self.dialog_confirmation.set_markup( "Etes vous sûre de vouloir supprimer l'utilisateur " + obj.name + " " + obj.firstname + " ?") if self.dialog_confirmation.run() == gtk.RESPONSE_OK: db.session.delete(obj) db.session_try_commit() TreeMgmt.replug_parents(obj) self.dialog_confirmation.hide() self.current_obj = None
def on_delete_event_clicked(self, widget): """open the dialog_confirmation, if this response is gtk.RESPONSE_OK: delete object in session, call db.session_try_commit else hide dialog_confirmation""" self.dialog_confirmation.set_markup("Etes vous sûre de vouloir supprimer l'événement " + self.name + " ?") if self.dialog_confirmation.run() == gtk.RESPONSE_OK: db.session.delete(self) db.session_try_commit() self.dialog.obj.response(gtk.RESPONSE_OK) self.dialog_confirmation.hide()
def on_menu_reset(self, widget): obj = self.current_obj self.dialog_confirmation.set_markup("Etes vous sûre de " + "vouloir réinitialiser le mot de passe de l'utilisateur " + obj.name + " " + obj.firstname + " ?") if self.dialog_confirmation.run() == gtk.RESPONSE_OK: obj.password = self.password(app.university.password_length) db.session_try_commit() self.mail(obj) self.dialog_confirmation.hide() self.current_obj = None
def on_hour_activate_changed(self, widget, data=None): """when user change this setting, call check_date_display for hide or display date, and call db.session_try_commit() """ hour_activate = widget.get_active_text().lower() if hour_activate == "oui": self.display_date = 1 else: self.display_date = 0 app.contentmgr.status_bar.check_date_display() db.session_try_commit()
def on_menu_reset(self, widget): obj = self.current_obj self.dialog_confirmation.set_markup( "Etes vous sûre de " + "vouloir réinitialiser le mot de passe de l'utilisateur " + obj.name + " " + obj.firstname + " ?") if self.dialog_confirmation.run() == gtk.RESPONSE_OK: obj.password = self.password(app.university.password_length) db.session_try_commit() self.mail(obj) self.dialog_confirmation.hide() self.current_obj = None
def on_delete_event_clicked(self, widget): """open the dialog_confirmation, if this response is gtk.RESPONSE_OK: delete object in session, call db.session_try_commit else hide dialog_confirmation""" self.dialog_confirmation.set_markup( "Etes vous sûre de vouloir supprimer l'événement " + self.name + " ?") if self.dialog_confirmation.run() == gtk.RESPONSE_OK: db.session.delete(self) db.session_try_commit() self.dialog.obj.response(gtk.RESPONSE_OK) self.dialog_confirmation.hide()
def on_menu_delete(self, widget): """call dialog for confirmation, if validate delete object of the session, call db.session_try_commit and call replug for update object entries, and destroy dialog""" dialog = gtk.MessageDialog( None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, "Etes vous sûr de vouloir supprimer le cursus " + self.name + "?") if dialog.run() == gtk.RESPONSE_OK: db.session.delete(self) db.session_try_commit() TreeMgmt.replug_parents(self) dialog.destroy()
def on_menu_delete(self, widget): """call dialog for confirmation, if validate delete object of the session, call db.session_try_commit and call replug for update object entries, and destroy dialog""" dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, "Etes vous sûr de vouloir supprimer le cursus " + self.name + "?") if dialog.run() == gtk.RESPONSE_OK: db.session.delete(self) db.session_try_commit() TreeMgmt.replug_parents(self) dialog.destroy()
def on_menu_delete(self, widget): """call dialog for confirmation, if validate delete object of the session, call db.session_try_commit and call replug for update object entries, and destroy dialog""" obj = self.current_obj self.dialog_confirmation.set_markup( "Etes vous sûr de vouloir supprimer la période " + obj.name + " ?") if self.dialog_confirmation.run() == gtk.RESPONSE_OK: db.session.delete(obj) db.session_try_commit() for id in obj.row: obj.row[id].tree.replug(obj.row[id].obj_parent) self.dialog_confirmation.hide() self.current_obj = None
def cb_delete(self, button): """shortcut for delete event on righ_click on this""" event = self.clicked_event self.dialog_confirmation = gtk.MessageDialog( None, gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT, gtk.MESSAGE_QUESTION, gtk.BUTTONS_OK_CANCEL, None) self.dialog_confirmation.set_markup( "Etes vous sûre de vouloir supprimer l'événement " + event.name + " ?") if self.dialog_confirmation.run() == gtk.RESPONSE_OK: db.session.delete(event) db.session_try_commit() self.refresh_events() self.dialog_confirmation.destroy() self.clicked_event = None
def on_valid_password_clicked(self, widget): """check the user's password, check if both new password are identicals, change the change_pass_status in error case""" passwd = self.old_password.get_text() login = app.user.login md5passwd = md5.new(passwd) def query(db, login): return db.session.query(User).filter(User.login==login).first() user = db.session_query(query, login, "auth : query(User).filter(User.login==login(" + str(login) + ").first()") if app.user.password != md5passwd.hexdigest(): self.change_pass_status.set_markup("Erreure: ancien mot de passe invalide") self.dialog_password.response(gtk.RESPONSE_OK) else: passwd1 = self.new_password1.get_text() passwd2 = self.new_password2.get_text() if passwd1 == passwd2: md5passwd = md5.new(passwd1) app.user.password = md5passwd.hexdigest() db.session_try_commit() self.dialog_password.response(gtk.RESPONSE_OK) else: self.change_pass_status.set_markup("Erreure: les nouveaux mots de passe ne sont pas identiques")
def on_valid(self, widget): self.get_dialog_fields() db.session_try_commit() TreeMgmt.replug_parents(self.current_obj) self.dialog.response(gtk.RESPONSE_OK)
def on_dialog_link_insert(self, widget): obj = self.current_obj period = self.period_combo.get_selected_object() period.classes.append(obj.classe) db.session_try_commit() self.dialog_link.obj.response(gtk.RESPONSE_OK)
def title_changed(self, view, frame, title): """manage action on planning view, resize event, right click, drop and click event... """ from Event import Event def query(db, id): """callback for db.session_query, this query event in terms of this id""" return db.session.query(Event).get(id) print "title change : %s" % title if title == "none": return # list event data = re.search('/signal/events/.*\?.*start=(.*)&end=(.*).*', title) if data: start = data.group(1) end = data.group(2) events = "$('#events').text('%s')" % \ self.events2json(start, end).replace("'", "\\'") self.browser.execute_script(events) # create event data = re.search('/signal/events-create/.*\?.*start=(.*)&end=(.*).*', title) if data: start = data.group(1) end = data.group(2) # XXX create event self.refresh_events() # resize event data = re.search('/signal/event-resize/.*\?.*minutedelta=(.*)&id=(.*)', title) if data: minutedelta = data.group(1) id = data.group(2) event = db.session_query( query, id, "planning : query(Event).get(" + str(id) + ")") event.time_length += int(minutedelta) / 60 db.session_try_commit() # drop event data = re.search( '/signal/event-drop/.*\?.*daydelta=(.*)&minutedelta=(.*)&id=(.*)', title) if data: daydelta = data.group(1) minutedelta = data.group(2) id = data.group(3) event = db.session_query( query, id, "planning : query(Event).get(" + str(id) + ")") delta = relativedelta(days=int(daydelta), minutes=int(minutedelta)) event.datetime += delta db.session_try_commit() # click event data = re.search('/signal/event-click/.*\?.*id=(.*)', title) if data: id = data.group(1) event = db.session_query( query, id, "planning : query(Event).get(" + str(id) + ")") editable_event = False if event.planning.type_user and self.check_rights( "user", event.id_planning) == True: editable_event = True elif event.planning.type_class and self.check_rights( "class", (event.planning.type_class.campus.id, event.planning.type_class.id)) == True: editable_event = True elif event.planning.type_campus and self.check_rights( "campus", event.planning.type_campus.id) == True: editable_event = True elif event.planning.type_period and self.check_rights( "period") == True: editable_event = True elif self.check_rights("univ") == True: editable_event = True if editable_event: if event.change_event() == gtk.RESPONSE_OK: self.refresh_events() # right click event data = re.search('/signal/event-right-click/.*\?.*id=(.*)', title) if data: id = data.group(1) self.clicked_event = db.session_query( query, id, "planning : query(Event).get(" + str(id) + ")") duplicate_event = False if self.clicked_event.planning.type_user and self.check_rights( "user", self.clicked_event.id_planning) == True: duplicate_event = True elif self.clicked_event.planning.type_class and self.check_rights( "class", (self.clicked_event.planning.type_class.campus.id, self.clicked_event.planning.type_class.id)) == True: duplicate_event = True elif self.clicked_event.planning.type_campus and self.check_rights( "campus", self.clicked_event.planning.type_campus.id) == True: duplicate_event = True elif self.clicked_event.planning.type_period and self.check_rights( "period") == True: duplicate_event = True elif self.check_rights("univ") == True: duplicate_event = True print 'right clic event' self.menu_context_popup(self.last_event, duplicate_event) # right click day data = re.search('/signal/day-right-click/.*\?.*date=(.*)', title) if data: date = data.group(1) print 'right clic day' + date self.menu_context_popup(self.last_event)