def get_display(self): sobject = self.get_current_sobject() sobject = sobject.get_parent() if not sobject: return Widget() # get all of the sobject_logs search = Search("sthpw/sobject_log") search.add_sobject_filter(sobject) logs = search.get_sobjects() search = Search("sthpw/transaction_log") search.add_filters("id", [x.get_value("transaction_log_id") for x in logs]) search.set_limit(200) logs = search.get_sobjects() from layout_wdg import TableWdg widget = Widget() table = TableWdg("sthpw/transaction_log") table.add_class("minimal") table.set_header_flag(False) table.set_show_property(False) table.set_no_results_wdg(" ") table.set_sobjects(logs) widget.add(table) return widget
def init_widget(my, widget, title=None): ''' instantiate the widget if selected. This can be called externally to instantiate any widgets added to a TabWdg''' try: # if a method was passed in, then execute it if my.mode == "check": from base_tab_wdg import BaseTabWdg try: if not issubclass(widget, BaseTabWdg): return Widget() except: return Widget() if type(widget) == types.MethodType: widget = widget() elif isinstance(widget, basestring): widget = Common.create_from_class_path(widget) elif not isinstance(widget, Widget): widget = widget() # handle docs for the help widget """ from header_wdg import DocMapping from web_wdg import HelpItemWdg help_url = ProdSetting.get_value_by_key("project_doc_url") if help_url: widget.add(HelpItemWdg('SOOT Docs', help_url)) # add the help item automatically doc = DocMapping() widget.add(HelpItemWdg('%s Tab' % title, doc.get_mapping(title))) """ # catch all exceptions and log them except Exception, e: my.handle_exception(e)
def get_display(self): web = WebContainer.get_web() response = web.get_response() # get info from url site_obj = Site.get() path = web.get_request_path() path_info = site_obj.break_up_request_path(path) site = path_info.get("site") project_code = path_info.get("project_code") # find the relative path hash = self.kwargs.get("hash") parts = hash[1:] rel_path = "/".join(parts) #rel_path = "asset/Fantasy/Castle/54d45150c61251f65687d716cc3951f1_v001.jpg" # construct all of the paths asset_dir = web.get_asset_dir() base_dir = "%s/%s" % (asset_dir, project_code) path = "%s/%s" % (base_dir, rel_path) filename = os.path.basename(rel_path) print "path: ", path # determine the mimetype automatically import mimetypes base, ext = os.path.splitext(path) ext = ext.lower() mimetype = mimetypes.types_map[ext] headers = response.headers response.headers['Content-Type'] = mimetype response.headers[ 'Content-Disposition'] = 'inline; filename={0}'.format(filename) use_xsendfile = True if use_xsendfile: response.headers['X-Sendfile'] = path return Widget(path) else: response.headers['Content-Transfer-Encoding'] = 'BINARY' widget = Widget() f = open(path, 'rb') data = f.read() f.close() widget.add(data) return widget
def init(self): div_main = DivWdg(css='module') if self.width != None: widthstr = "width: %sem" % (self.width) div_main.add_style(widthstr) # reset self.name, create the content widget if not self.shad_name: self.shad_name = "ShadowBox%s" % (self.generate_unique_id()) div_main.set_id(self.shad_name) div_main.center() div_head = DivWdg(css='boxhead') # HACK to compensate for IE weird handling of CSS if WebContainer.get_web().is_IE() and 'password' in self.shad_name: div_head.add_style('left', '-242px') div_head.add_style('padding-bottom: 2px') empty_header = Widget(name=self.HEADER) div_head.add(empty_header, empty_header.get_name()) div_head.add(self.title_wdg, self.title_wdg.get_name()) div_control = DivWdg(css='control') empty_control = Widget(name=self.CONTROL) div_control.add(empty_header, empty_control.get_name()) div_container = DivWdg(css='container') ie_rect = HtmlElement('v:roundrect') ie_rect.set_attr("arcsize", "1966f") ie_rect.set_attr("fillcolor", "white") ie_rect.set_attr("strokecolor", "#555") ie_rect.set_attr("strokeweight", "2pt") div_body = DivWdg(css='content') div_body.set_id("%s_cont" % self.shad_name) div_body.center() div_body.add(div_head) div_body.add(div_control) self.content = div_main self.head = div_head self.control = div_control self.body = div_body div_container.add(ie_rect) ie_rect.add(div_body) #div_main.add(div_head) div_main.add(div_container)
def get_css_wdg(my): widget = Widget() web = WebContainer.get_web() context_url = web.get_context_url().to_string() skin = web.get_skin() # first load context css Container.append_seq("Page:css", "%s/style/layout.css" % context_url) # add the color wheel css Container.append_seq("Page:css", "%s/spt_js/mooRainbow/Assets/mooRainbow.css" % context_url) Container.append_seq("Page:css", "%s/spt_js/mooDialog/css/MooDialog.css" % context_url) Container.append_seq("Page:css", "%s/spt_js/mooScrollable/Scrollable.css" % context_url) # TEST Container.append_seq("Page:css", "%s/spt_js/video/video-js.css" % context_url) # get all of the registered css file css_files = Container.get_seq("Page:css") for css_file in css_files: widget.add('<link rel="stylesheet" href="%s" type="text/css" />\n' % css_file ) return widget
def get_display(my): widget = DivWdg(id='link_view_select') widget.add_class("link_view_select") if my.refresh: widget = Widget() else: my.set_as_panel(widget) views = [] if my.search_type: from pyasm.search import WidgetDbConfig search = Search(WidgetDbConfig.SEARCH_TYPE) search.add_filter("search_type", my.search_type) search.add_regex_filter("view", "link_search:|saved_search:", op="NEQI") search.add_order_by('view') widget_dbs = search.get_sobjects() views = SObject.get_values(widget_dbs, 'view') labels = [view for view in views] views.insert(0, 'table') labels.insert(0, 'table (Default)') st_select = SelectWdg('new_link_view', label='View: ') st_select.set_option('values', views) st_select.set_option('labels', labels) widget.add(st_select) return widget
def get_display(self): search_type = self.search_type related_search_type = self.related_search_type_wdg.get_value() if related_search_type: search_type = related_search_type hier_sel = self.get_hier_sel(search_type) selected_related_search_type = hier_sel.get_value() process_wdg = self.get_process_wdg(search_type) context_wdg = self.get_context_wdg(search_type) widget = self.main_div if self.is_from_ajax(True): widget = Widget() else: self.set_ajax_top(widget) hidden = HiddenWdg("search_type" ,search_type) widget.add(hidden) hier_sel.add_event('onchange', self.get_refresh_script(show_progress=False)) widget.add(hier_sel) #Tooltip doesn't work too well #hint = HintWdg('Related search type you can optionally select to drive the process') widget.add(HtmlElement.br(2)) widget.add(process_wdg) widget.add(context_wdg) return widget
def get_checkin(my): '''the button which initiates the checkin''' # create the button with the javascript function widget = Widget() #button = TextBtnWdg(label=my.PUBLISH_BUTTON, size='large', width='100', side_padding='20', vert_offset='-5') #button.get_top_el().add_class('smaller') button = ActionButtonWdg(title=my.PUBLISH_BUTTON, tip='Publish the selected assets') button.add_style('margin-bottom: 10px') #button.add_color("background", "background") hidden = HiddenWdg(my.PUBLISH_BUTTON, '') button.add(hidden) ''' status_sel = SelectWdg('checkin_status', label='Status: ') status_sel.set_option('setting', 'checkin_status') status_sel.set_persist_on_submit() status_sel.add_empty_option('-- Checkin Status --') widget.add(status_sel) ''' widget.add(button) # custom defined server_cbk = "pyasm.prod.web.AssetCheckinCbk" #TODO: make other Publish Buttons call their own handle_input function exec(Common.get_import_from_class_path(server_cbk)) exec( "%s.handle_input(button, my.search_type, my.texture_search_type)" % server_cbk) return widget
def get_storyboard_wdg(my): widget = Widget() help = HelpItemWdg( 'Storyboards', 'Storyboards tab lets the user organize storyboards. You are only required to [Insert] once per shot. Subsequent versions of the storyboard should be published via the [Publish] button.' ) my.add(help) div = DivWdg(css="filter_box") sequence_filter = SequenceFilterWdg() epi_code, sequence_code = sequence_filter.get_value() div.add(sequence_filter) columns = ['code', 'shot_code'] search_filter = SearchFilterWdg("storyboard_search", columns=columns,\ has_persistence=False) div.add(search_filter) widget.add(div) # create a search search = Search("prod/storyboard") if sequence_code: search.add_where( "shot_code in (select code from shot where sequence_code = '%s')" % sequence_code) table = TableWdg("prod/storyboard") table.set_class("table") table.set_search_limit(25) table.set_search(search) widget.add(table) return widget
def get_camera_wdg(my): widget = Widget() div = DivWdg(css="filter_box") sequence_filter = SequenceFilterWdg() epi_code, sequence_code = sequence_filter.get_value() div.add(sequence_filter) search = Search("prod/camera") columns = ['shot_code', 'description'] search_filter = SearchFilterWdg("camera_search", columns=columns,\ has_persistence=False) search_filter.alter_search(search) div.add(search_filter) widget.add(div) if sequence_code: search.add_where( "shot_code in (select code from shot where sequence_code = '%s')" % sequence_code) table = TableWdg("prod/camera") table.set_search(search) widget.add(table) return widget
def get_display(self): web = WebContainer.get_web() widget = Widget() search_type = web.get_form_value("parent_search_type") search_id = web.get_form_value("parent_search_id") if not search_type: widget.add("RenderSubmitInfo: parent type not found") return widget hidden = HiddenWdg("parent_search_type", search_type) widget.add(hidden) hidden = HiddenWdg("parent_search_id", search_id) widget.add(hidden) sobject = Search.get_by_id(search_type, search_id) table = TableWdg(search_type, css="embed") table.set_show_property(False) table.set_sobject(sobject) table.remove_widget("render") table.remove_widget("description") widget.add(table) return widget
def get_display(my): if my.is_refresh: top = Widget() my.add(top) web = WebContainer.get_web() my.checked_processes = web.get_form_values('process_names') left_checked_processes = web.get_form_values('left_process_names') right_checked_processes = web.get_form_values( 'right_process_names') is_split_view = web.get_form_value('split_view') == 'true' else: top = my.get_viewer() if my.is_refresh: if is_split_view: viewer = my.get_split_viewer() top.add(viewer) else: inner_wdg = SingleNoteViewerWdg( processes_names=my.process_names, parent_key=my.kwargs.get('parent_key'), resize='false', append_context=my.append_context, view=my.view) top.add(inner_wdg) return top
def get_display(my): sobject = my.get_current_sobject() mode = my.get_option('mode') if not mode: mode = 'sandbox' widget = Widget() sobject_dir = '' sobject_lib_dir = '' # find the path to open explorer if sobject.is_insert(): button = IconWdg("No Path Found", IconWdg.CROSS, long=False) else: try: if mode == 'sandbox': sobject_dir = my.get_base_dir(sobject) elif mode in ['client_repo', 'repository']: sobject_dir = my.get_client_repo_dir(sobject) sobject_lib_dir = my.get_lib_dir(sobject) sobject_dir = sobject_dir.strip() sobject_dir = Common.process_unicode_string(sobject_dir) except TacticException, e: print "WARNING: ", str(e) button = IconWdg("No Path Found", IconWdg.CROSS, long=False) else:
def get_display(my): sobject = my.get_current_sobject() title = sobject.get_value("title") widget = Widget() widget.add(sobject.get_description()) if title == 'Debug': pop = PopupWdg("pref_help_%s" % title) hint = 'If set to [true], you can view the Debug Widget at the bottom left corner of your page.' icon_wdg = IconWdg(hint, IconWdg.HELP) widget.add(SpanWdg(icon_wdg, css='small')) widget.add(pop) elif title == 'Filter': pop = PopupWdg("pref_help_%s" % title) hint = 'If set to [multi], It generally applies to filters in the filter box for Artist Tab.' icon_wdg = IconWdg(hint, IconWdg.HELP) widget.add(SpanWdg(icon_wdg, css='small')) widget.add(pop) elif title == 'Quick Text': pop = PopupWdg("pref_help_%s" % title) hint = 'A list of | separated phrases a user can pick from to enter into the note area of Note Sheet.' icon_wdg = IconWdg(hint, IconWdg.HELP) widget.add(SpanWdg(icon_wdg, css='small')) widget.add(pop) return widget
def _get_sobject_history_wdg(self): ''' this method is called thru ajax ''' args = WebContainer.get_web().get_form_args() # get the args in the URL search_type = args['search_type'] search_id = args['search_id'] #sobject = Search.get_by_id(search_type, search_id) div = Widget() search = Search("sthpw/sobject_log") search.add_filter("search_type", search_type) search.add_filter("search_id", search_id) sobjects = search.get_sobjects() search = Search("sthpw/transaction_log") search.add_filters( "id", [x.get_value("transaction_log_id") for x in sobjects]) sobjects = search.get_sobjects() table = TableWdg("sthpw/transaction_log", "table", css='table') table.set_show_property(False) table.set_sobjects(sobjects) div.add(table) div.add(HtmlElement.br(2)) return div div.add(assigned_shot_wdg) div.add(HtmlElement.br(2)) return div
def get_pipeline_wdg(my): search = Search("sthpw/pipeline") widget = Widget() widget.set_search(search) table = TableWdg("sthpw/pipeline", "manage") widget.add(table) return widget
def get_tool_bar(my): widget = Widget() trash_div = SpanWdg() trash_div.set_id('trash_me') trash_div.add(IconWdg('Trash', IconWdg.TRASH)) trash_div.add("TRASH!") trash_div.add_class("hand") trash_div.add_class("spt_side_bar_trash") trash_div.set_attr("SPT_ACCEPT_DROP", "manageSideBar") bvr = { "type": "click_up",\ 'cbjs_action': "alert('Drag and drop element name here to remove it.')"} trash_div.add_behavior(bvr) widget.add(trash_div) save_div = SpanWdg(css='med hand spt_side_bar_trash') save_div.add(IconWdg('Save', IconWdg.SAVE)) bvr = { "type": "click_up",\ 'cbjs_action': "spt.custom_project.manage_action_cbk({'value':'save'},'%s');" % my.view} save_div.add_behavior(bvr) widget.add(save_div) return widget
def get_display(my): widget = Widget() thumb = super(ThumbPublishWdg, my).get_display() widget.add(thumb) sobject = my.get_current_sobject() search_type = sobject.get_search_type() search_id = sobject.get_id() publish_link = PublishLinkWdg(search_type, search_id) div = DivWdg(publish_link) div.set_style('clear: left; padding-top: 6px') widget.add(div) # build an iframe to show publish browsing browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS) iframe = WebContainer.get_iframe() iframe.set_width(100) url = WebContainer.get_web().get_widget_url() url.set_option("widget", "pyasm.prod.web.PublishBrowserWdg") url.set_option("search_type", search_type) url.set_option("search_id", search_id) script = iframe.get_on_script(url.to_string()) browse_link.add_event("onclick", script) div.add(browse_link) div.set_style('padding-top: 6px') return widget
def get_notes_wdg(my): widget = Widget() div = DivWdg(css="filter_box") columns = ['code', 'description'] search_filter = SearchFilterWdg("note_search", columns=columns,\ has_persistence=False) div.add(search_filter) sequence_filter = SequenceFilterWdg() div.add(sequence_filter) context_select = FilterSelectWdg("discussion_context") context_select.set_option("setting", "notes_preprod_context") context_select.add_empty_option("-- Any Context --") span = SpanWdg(css="med") span.add("Notes Context: ") span.add(context_select) hint = HintWdg('Submission notes for each shot are also included here') span.add(hint) div.add(span) widget.add(div) # create a search search = Search("prod/shot") sequence_filter.alter_search(search) search_filter.alter_search(search) table = TableWdg("prod/shot", "preprod_notes") table.set_search(search) widget.add(table) return widget
def get_display(self): widget = Widget() if not self.select: return widget if not self.schema: Environment.add_warning("No schema defined") widget.add("No schema defined") return widget if not self.search_type: Environment.add_warning("HierarchicalFilterWdg: Cannot find current search_type") widget.add("Cannot find current search_type") return widget span = SpanWdg(css="med") parent_type = self.get_parent_type() if parent_type: parent_type_obj = SearchType.get(parent_type) span.add("%s: " % parent_type_obj.get_value("title")) # assume that there is a code in the parent self.select.add_empty_option("-- Select --") self.select.set_option("query", "%s|code|code" % self.parent_type) span.add(self.select) widget.add(span) return widget
def get_display(my): my.view = my.kwargs.get('view') if not my.view: my.view = 'publish' widget = Widget() sobject = my.get_current_sobject() search_type = sobject.get_search_type() search_id = sobject.get_id() if my.get_option('preview') != 'false': my.thumb.set_current_index(my.get_current_index()) widget.add(my.thumb) publish_link = PublishLinkWdg(search_type,search_id, config_base=my.view) div = DivWdg(publish_link) div.set_style('clear: left; padding-top: 6px') widget.add(div) # build a popup link to show publish browsing browse_link = IconButtonWdg("Publish Browser", IconWdg.CONTENTS) browse_link.add_behavior({'type': 'click_up', 'cbjs_action': 'spt.popup.get_widget(evt, bvr)', 'options': {'popup_id' : 'publish_browser', 'class_name' : 'pyasm.prod.web.PublishBrowserWdg' , 'title': 'Publish Browser'}, 'args' : { 'search_type': search_type, 'search_id' : search_id } }) div.add(browse_link) div.set_style('padding-top: 6px') return widget
def get_tool_bar(my): widget = Widget() trash_div = SpanWdg() # reset some global variables on load trash_div.add_behavior({ 'type': 'load', 'cbjs_action': 'spt.side_bar.trashed_items=[]; spt.side_bar.changed_views={}' }) trash_div.set_id('trash_me') trash_div.add(IconWdg('Trash', IconWdg.TRASH)) trash_div.add("TRASH!") trash_div.add_class("hand") trash_div.add_class("spt_side_bar_trash") trash_div.set_attr("SPT_ACCEPT_DROP", "manageSideBar") bvr = { "type": "click_up",\ 'cbjs_action': "alert('Drag and drop link or folder here to remove it.')"} trash_div.add_behavior(bvr) widget.add(trash_div) save_div = SpanWdg(css='med hand spt_side_bar_trash') save_div.add(IconWdg('Save Ordering', IconWdg.SAVE)) # FIXME: is_personal??? is_personal = 'false' bvr = { "type": "click_up",\ 'cbjs_action': "spt.side_bar.manage_section_action_cbk({'value':'save'},'%s',%s);" % (my.view, is_personal)} save_div.add_behavior(bvr) widget.add(save_div) return widget
def get_display(my): #parent_class = "TabWdg" my.parent_class = my.parent_wdg.__class__.__name__ if my.parent_class == "TbodyWdg": my.parent_class = "TableWdg" elif my.parent_class == "MayaTabWdgImpl": my.parent_class = "TabWdg" # get the key if my.parent_class == "TabWdg": key = my.parent_wdg.get_tab_path() elif my.parent_class == "TableWdg": key = "%s|%s" % (my.search_type, my.parent_wdg.get_view()) else: key = my.parent_wdg.get_name() # set sobjects from the parent, if there are any my.sobjects = my.parent_wdg.get_sobjects() # search for these from pyasm.search import Search search = Search("sthpw/widget_extend") search.add_project_filter() search.add_filter("type", my.parent_class) search.add_filter("key", key) extends = search.get_sobjects() for extend in extends: xml = extend.get_xml_value("data") index = xml.get_value("widget/@index") if index: index = int(index) else: index = None title = xml.get_value("widget/@name") nodes = xml.get_nodes("widget/widget") if nodes: widget = Widget() for node in nodes: node_string = Xml.get_node_xml(node) child_widget = CustomXmlWdg(node_string) if not child_widget: continue if my.sobjects: child_widget.set_sobjects(my.sobjects) widget.add(child_widget) else: widget = CustomXmlWdg(xml.to_string()) if my.sobjects: widget.set_sobjects(my.sobjects) if my.parent_class == 'TableWdg': table_element = widget.get_display_widget() table_element.set_parent_wdg(my.parent_wdg) my.parent_wdg.add(widget, title, index=index)
def get_title(self): widget = Widget() if not Container.get('GeneralAppletWdg'): widget.add(GeneralAppletWdg()) Container.put('GeneralAppletWdg', True) widget.add(super(LayerTableElementWdg, self).get_title()) return widget
def handle_exception(my, e): '''The tab widget is a special widget concerning exceptions because it usually represents the outer skin of the content of the web page. The titles of the tab must be displayed in order for the site to remain functional in the case of an exception''' from web_wdg import ExceptionWdg widget = ExceptionWdg(e) my.error_wdg = Widget() my.error_wdg.add(widget)
def get_display(my): my.run_init() name = my.get_name() if not name: name = my.kwargs.get("name") if my.is_refresh: widget = Widget() else: widget = DivWdg() my.set_as_panel(widget) widget.add_class("spt_note_top") widget.set_attr("spt_name", name) widget.set_attr("spt_parent_key", my.parent_key) web = WebContainer.get_web() value = web.get_form_value(name) text = TextAreaWdg(name) widget.add(text) if value: text.set_value(value) text.add_style("width: 100%") text.add_style("min-width: 200") text.add_attr("rows", "5") text.add_class('spt_note_text') color = text.get_color("background", -10) text.add_behavior({ 'type': 'blur', 'cbjs_action': ''' //spt.dg_table._toggle_commit_btn($(this), false); var el = bvr.src_el; var td = el.getParent(".spt_table_td"); var tbody = el.getParent(".spt_table_tbody"); td.setStyle('background-color','#909977'); td.addClass('spt_value_changed'); tbody.addClass('spt_value_changed'); td.setAttribute('spt_input_value', el.value); ''' }) #text.add_event("onblur", "spt.dg_table._toggle_commit_btn($(this), false);$(this).getParent('.spt_table_td').setStyle('background-color','#030');$(this).getParent('.spt_table_td').addClass('spt_value_changed');$(this).getParent('.spt_table_tbody').addClass('spt_value_changed');$(this).getParent('.spt_table_td').setAttribute('spt_input_value',this.value)") #text.add_event("onclick", "spt.dg_table.edit_cell_cbk( this, spt.kbd.special_keys_map.ENTER)" ); #behavior = { # 'type': 'keyboard', # 'kbd_handler_name': 'DgTableMultiLineTextEdit' #} #text.add_behavior(behavior) action_wdg = my.get_action_wdg(name) widget.add(action_wdg) return widget
def get_display(my): sobject = my.get_current_sobject() bins = sobject.get_bins() widget = Widget() bins_str = ", ".join(["%s" % bin.get_label() for bin in bins]) widget.add(bins_str) return widget
def get_copyright_wdg(my): widget = Widget() # add the copyright information widget.add( "<!-- -->\n") widget.add( "<!-- Copyright (c) 2005-2013, Southpaw Technology - All Rights Reserved -->\n") widget.add( "<!-- -->\n") return widget
def get_display(my): top = Widget() from tactic.ui.panel import CustomLayoutWdg #widget = CustomLayoutWdg(view="bootstrap.basic.test_mootools", is_top=True) widget = CustomLayoutWdg(view="bootstrap.themes.jumbotron.main2", is_top=True) #widget = CustomLayoutWdg(view="bootstrap.basic.test2", is_top=True) top.add(widget) return top
def get_milestone_wdg(my): widget = Widget() search = Search("sthpw/milestone") table = TableWdg("sthpw/milestone") table.set_search(search) widget.add(table) return widget