def clone_movie(self): treeselection = self.widgets['treeview'].get_selection() (tmp_model, tmp_iter) = treeselection.get_selected() if tmp_iter is None: return False number = tmp_model.get_value(tmp_iter, 0) movie = self.db.Movie.get_by(number=number) if movie is None: return False next_number = gutils.find_next_available(self.db) if movie.image is not None: new_image = str(movie.image) + '_' + str(next_number) else: new_image = None # integer problem workaround if int(movie.seen)==1: seen = True else: seen = False new_movie = self.db.Movie() new_movie.cast = movie.cast new_movie.classification = movie.classification new_movie.vcodec_id = movie.vcodec_id new_movie.collection_id = movie.collection_id new_movie.volume_id = movie.volume_id new_movie.color = movie.color new_movie.cond = movie.cond new_movie.country = movie.country new_movie.director = movie.director new_movie.genre = movie.genre new_movie.image = new_image new_movie.site = movie.site new_movie.loaned = movie.loaned new_movie.layers = movie.layers new_movie.medium_id = movie.medium_id new_movie.number = next_number new_movie.media_num = movie.media_num new_movie.notes = movie.notes new_movie.o_title = movie.o_title new_movie.plot = movie.plot new_movie.rating = movie.rating new_movie.region = movie.region new_movie.runtime = movie.runtime new_movie.seen = seen new_movie.o_site = movie.o_site new_movie.studio = movie.studio new_movie.title = movie.title new_movie.trailer = movie.trailer new_movie.year = movie.year new_movie.tags = movie.tags new_movie.languages = movie.languages new_movie.loans = movie.loans # save new_movie.save() new_movie.flush() # WARNING: loan problems (don't copy volume/collection data until resolved) tmp_dest = self.locations['posters'] if movie.image is not None: image_path = os.path.join(tmp_dest, str(movie.image)+".jpg") clone_path = os.path.join(tmp_dest, new_image+".jpg") # clone image # catch IOError otherwise you would not see the cloned entry in # the list before the next start of griffith or another refresh # of the list try: shutil.copyfile(image_path, clone_path) image_path = clone_path gutils.make_thumbnail(self, "%s.jpg" % new_image) gutils.make_medium_image(self, "%s.jpg" % new_image) except IOError: image_path = os.path.join(self.locations['images'], "default.png") else: image_path = os.path.join(self.locations['images'], "default.png") handler = self.Image.set_from_file(image_path) # change_filter calls populate_treeview which updates the status bar quick_filter.change_filter(self)
def clone_movie(self): treeselection = self.widgets['treeview'].get_selection() (tmp_model, tmp_iter) = treeselection.get_selected() if tmp_iter is None: log.warn("cannot clone movie: no item selected") return False number = tmp_model.get_value(tmp_iter, 0) movie = self.db.session.query(db.Movie).filter_by(number=number).first() if movie is None: log.warn("cannot clone movie: Movie(%s) not found", number) return False next_number = gutils.find_next_available(self.db) # integer problem workaround if int(movie.seen)==1: seen = True else: seen = False new_movie = db.Movie() # TODO: WARNING: loan problems (don't copy volume/collection data until resolved) new_movie.cast = movie.cast new_movie.classification = movie.classification new_movie.vcodec_id = movie.vcodec_id new_movie.cameraman = movie.cameraman new_movie.collection_id = movie.collection_id new_movie.volume_id = movie.volume_id new_movie.color = movie.color new_movie.cond = movie.cond new_movie.country = movie.country new_movie.director = movie.director new_movie.genre = movie.genre new_movie.site = movie.site new_movie.loaned = movie.loaned new_movie.layers = movie.layers new_movie.medium_id = movie.medium_id new_movie.number = next_number new_movie.media_num = movie.media_num new_movie.notes = movie.notes new_movie.o_title = movie.o_title new_movie.plot = movie.plot new_movie.poster_md5 = movie.poster_md5 new_movie.ratio_id = movie.ratio_id new_movie.rating = movie.rating new_movie.region = movie.region new_movie.runtime = movie.runtime new_movie.screenplay = movie.screenplay new_movie.seen = seen new_movie.o_site = movie.o_site new_movie.studio = movie.studio new_movie.title = movie.title new_movie.trailer = movie.trailer new_movie.year = movie.year new_movie.tags = movie.tags new_movie.languages = movie.languages new_movie.loans = movie.loans # save self.db.session.add(new_movie) if not commit(self, self.db.session): return False image_path = gutils.get_image_fname(movie.poster_md5, self.db) if not image_path or not os.path.isfile(image_path): image_path = os.path.join(self.locations['images'], 'default.png') handler = self.Image.set_from_file(image_path) # change_filter calls populate_treeview which updates the status bar quick_filter.change_filter(self)
def OnChangeCriteria(self, event): # wxGlade: MainFrame.<event_handler> selected_criteria = self.cb_criteria.GetValue() self.config.set('criteria', selected_criteria, section='mainlist') quick_filter.change_filter(self)
def clone_movie(self): session = self.db.Session() if self.selected_iter[0] is None: log.warn("cannot clone movie: no item selected") return False movie = session.query(db.Movie).filter_by(number=self.selected[0]).first() if movie is None: log.warn("cannot clone movie: Movie(%s) not found", number) return False next_number = gutils.find_next_available(self.db) # integer problem workaround if int(movie.seen) == 1: seen = True else: seen = False new_movie = db.Movie() # TODO: WARNING: loan problems (don't copy volume/collection data until resolved) new_movie.cast = movie.cast new_movie.classification = movie.classification new_movie.vcodec_id = movie.vcodec_id new_movie.barcode = movie.barcode new_movie.cameraman = movie.cameraman new_movie.collection_id = movie.collection_id new_movie.volume_id = movie.volume_id new_movie.color = movie.color new_movie.cond = movie.cond new_movie.country = movie.country new_movie.director = movie.director new_movie.genre = movie.genre new_movie.site = movie.site new_movie.loaned = movie.loaned new_movie.layers = movie.layers new_movie.medium_id = movie.medium_id new_movie.number = next_number new_movie.media_num = movie.media_num new_movie.notes = movie.notes new_movie.o_title = movie.o_title new_movie.plot = movie.plot new_movie.poster_md5 = movie.poster_md5 new_movie.ratio_id = movie.ratio_id new_movie.rating = movie.rating new_movie.region = movie.region new_movie.runtime = movie.runtime new_movie.resolution = movie.resolution new_movie.screenplay = movie.screenplay new_movie.seen = seen new_movie.o_site = movie.o_site new_movie.studio = movie.studio new_movie.title = movie.title new_movie.trailer = movie.trailer new_movie.year = movie.year new_movie.tags = movie.tags new_movie.languages = movie.languages new_movie.loans = movie.loans # save session.add(new_movie) if not commit(session): return False if movie.poster_md5: image_path = gutils.get_image_fname(movie.poster_md5, self.db) if not image_path or not os.path.isfile(image_path): image_path = gutils.get_defaultimage_fname(self) handler = self.Image.set_from_file(image_path) # change_filter calls populate_treeview which updates the status bar quick_filter.change_filter(self)
def OnFilterChange(self, event): # wxGlade: MainFrame.<event_handler> quick_filter.change_filter(self)