def init(self): thumb_cache = {} div = DivWdg() # get all of the shots filter_div = DivWdg(css='filter_box') unit = 'an Episode' filter = shot_container = None search_columns = [] # pick the navigator depending on what project type if Project.get().get_type() == 'flash': # these navigators will have their empty option removed # and should have a different name so that if the user # comees from a tab with the same navigator, it won't # use the previous empty value if chosen filter = EpisodeFilterWdg('unique_episode_code') # set a default value which is used if there is nothing # stored in wdg_settings filter.set_option('default', SelectWdg.NONE_MODE) episode_code = filter.get_value() episode = Episode.get_by_code(episode_code) shot_container = episode search_columns = ['code', 'description', 'episode_code'] elif Project.get().get_type() == 'prod': filter = SequenceFilterWdg('unique_sequence_code') filter.set_option('default', SelectWdg.NONE_MODE) epi_code, seq_code = filter.get_value() seq = Sequence.get_by_code(seq_code) shot_container = seq unit = 'a Sequence' search_columns = ['code', 'description', 'sequence_code'] # name the empty option properly at least filter.get_navigator().get_select().add_empty_option(\ '-- Select %s --' % unit) #filter.remove_empty_option() #filter.add_none_option() filter_div.add(filter) search_filter = SearchFilterWdg(columns=search_columns) search_filter_value = search_filter.get_value() filter_div.add(search_filter) div.add(filter_div) self.add(div) if not shot_container and not search_filter_value: return search = Search(Shot.SEARCH_TYPE) if shot_container: key = shot_container.get_foreign_key() code = shot_container.get_code() search.add_filter(key, code) if search_filter_value: search_filter.alter_search(search) shots = search.get_sobjects() table = TableWdg(Shot.SEARCH_TYPE, 'layout_summary') table.set_sobjects(shots) self.add(table)
class Usage(Exception): def __init__(self, msg): self.msg = msg if __name__ == '__main__': my_login = '******' batch = Batch(login_code=my_login) Project.set_project('bar') project_code = Project.get_project_code() args = sys.argv[1:] try: if len(args) != 1: raise Usage("A single sequence code is expected.") seq = Sequence.get_by_code(args[0]) if not seq: raise Usage("The sequence code [%s] has not been registered for "\ "project [%s] in TACTIC. Please Insert it in the Sequences tab first." %(args[0], project_code)) except Usage, e: print e.msg sys.exit(2) command = AddShotCmd(seq.get_code()) Command.execute_cmd(command)
def init(my): thumb_cache = {} div = DivWdg() # get all of the shots filter_div = DivWdg(css='filter_box') unit = 'an Episode' filter = shot_container = None search_columns = [] # pick the navigator depending on what project type if Project.get().get_type() == 'flash': # these navigators will have their empty option removed # and should have a different name so that if the user # comees from a tab with the same navigator, it won't # use the previous empty value if chosen filter = EpisodeFilterWdg('unique_episode_code') # set a default value which is used if there is nothing # stored in wdg_settings filter.set_option('default', SelectWdg.NONE_MODE) episode_code = filter.get_value() episode = Episode.get_by_code(episode_code) shot_container = episode search_columns = ['code', 'description', 'episode_code'] elif Project.get().get_type() == 'prod': filter = SequenceFilterWdg('unique_sequence_code') filter.set_option('default', SelectWdg.NONE_MODE) epi_code, seq_code = filter.get_value() seq = Sequence.get_by_code(seq_code) shot_container = seq unit = 'a Sequence' search_columns = ['code', 'description', 'sequence_code'] # name the empty option properly at least filter.get_navigator().get_select().add_empty_option(\ '-- Select %s --' % unit) #filter.remove_empty_option() #filter.add_none_option() filter_div.add(filter) search_filter = SearchFilterWdg(columns=search_columns) search_filter_value = search_filter.get_value() filter_div.add(search_filter) div.add(filter_div) my.add(div) if not shot_container and not search_filter_value: return search = Search(Shot.SEARCH_TYPE) if shot_container: key = shot_container.get_foreign_key() code = shot_container.get_code() search.add_filter(key,code) if search_filter_value: search_filter.alter_search(search) shots = search.get_sobjects() table = TableWdg(Shot.SEARCH_TYPE, 'layout_summary') table.set_sobjects(shots) my.add(table)