def SaveSettings(self): # Register folders # Get gallery connection gallery_conn = database.get_current_gallery("connection") cursor = gallery_conn.cursor() location = self.tc_directory.GetValue() name = self.tc_name.GetValue() if self.cb_automatic.GetValue(): add_new_tag = 1 else: add_new_tag = 0 if self.rb_softlinks.GetValue(): use_softlink = 1 else: use_softlink = 0 if not os.path.isdir(location): wx.MessageBox("Location does not exist!", "Error") return if name == "": wx.MessageBox("Must define a name.", "Error") return if os.path.isdir(os.path.join(location, name)): wx.MessageBox( ("Target folder already exists, " "remove it first."), "Error", ) return checked_tags = self.lb.GetCheckedStrings() tags = [] for tag in checked_tags: tags.append(tagging.tag_name_to_id(tag.replace(" ", "_"))) cursor.execute( ( "INSERT INTO gallery_folder " "(name, location, add_new_tag, use_softlink) " "VALUES (:name, :location, :add_new_tag, :use_softlink)" ), { "name": name, "location": location, "add_new_tag": add_new_tag, "use_softlink": use_softlink } ) gallery_conn.commit() cursor.execute( ( "SELECT pk_id FROM gallery_folder " "WHERE name = :name " "AND location = :location " ), { "name": name, "location": location, } ) folder_id = cursor.fetchone()[0] output.create_gallery(folder_id) for tag in tags: output.change_gallery(folder_id, tag, True)
def SaveSettings(self): # FIXME: Change name not working (under windows)? # Register folders # Get gallery connection gallery_conn = database.get_current_gallery("connection") cursor = gallery_conn.cursor() location = self.tc_directory.GetValue() name = self.tc_name.GetValue() if self.cb_automatic.GetValue(): add_new_tag = 1 else: add_new_tag = 0 if self.rb_softlinks.GetValue(): use_softlink = True else: use_softlink = False if not os.path.isdir(location): wx.MessageBox("Location does not exist!", "Error") return if name == "": wx.MessageBox("Must define a name.", "Error") return output.change_link_type(self.folder_id, False, use_softlink) new_checked_tags = self.lb.GetCheckedStrings() for tag in new_checked_tags: if tag not in self.checked_tags: tag_id = tagging.tag_name_to_id(tag.replace(" ", "_")) output.change_gallery(self.folder_id, tag_id, True) for tag in self.checked_tags: if tag not in new_checked_tags: tag_id = tagging.tag_name_to_id(tag.replace(" ", "_")) output.change_gallery(self.folder_id, tag_id, False) if name != self.name or location != self.location: if os.path.isdir(os.path.join(location, name)): print "koko made NI" wx.MessageBox( ("Location or target folder already exists, " "remove it first."), "Error", ) return if name != self.name: output.rename(self.folder_id, False, name) if location != self.location: output.move(self.folder_id, False, location) query_save = ("UPDATE gallery_folder SET " "add_new_tag = %d " "WHERE pk_id = %d" % (add_new_tag, self.folder_id)) cursor.execute(query_save) gallery_conn.commit() self.Close()
def SaveSettings(self): # FIXME: Change name not working (under windows)? # Register folders # Get gallery connection gallery_conn = database.get_current_gallery("connection") cursor = gallery_conn.cursor() location = self.tc_directory.GetValue() name = self.tc_name.GetValue() if self.cb_automatic.GetValue(): add_new_tag = 1 else: add_new_tag = 0 if self.rb_softlinks.GetValue(): use_softlink = True else: use_softlink = False if not os.path.isdir(location): wx.MessageBox("Location does not exist!", "Error") return if name == "": wx.MessageBox("Must define a name.", "Error") return output.change_link_type(self.folder_id, False, use_softlink) new_checked_tags = self.lb.GetCheckedStrings() for tag in new_checked_tags: if tag not in self.checked_tags: tag_id = tagging.tag_name_to_id(tag.replace(" ", "_")) output.change_gallery(self.folder_id, tag_id, True) for tag in self.checked_tags: if tag not in new_checked_tags: tag_id = tagging.tag_name_to_id(tag.replace(" ", "_")) output.change_gallery(self.folder_id, tag_id, False) if name != self.name or location != self.location: if os.path.isdir(os.path.join(location, name)): print "koko made NI" wx.MessageBox( ("Location or target folder already exists, " "remove it first."), "Error", ) return if name != self.name: output.rename(self.folder_id, False, name) if location != self.location: output.move(self.folder_id, False, location) query_save = ( "UPDATE gallery_folder SET " "add_new_tag = %d " "WHERE pk_id = %d" % (add_new_tag, self.folder_id) ) cursor.execute(query_save) gallery_conn.commit() self.Close()