def get_display(my): sobject = my.get_current_sobject() column = my.kwargs.get('column') if column: name = column else: name = my.get_name() value = my.get_value(name=name) if sobject: data_type = SearchType.get_column_type(sobject.get_search_type(), name) else: data_type = 'text' if type(value) in types.StringTypes: wiki = WikiUtil() value = wiki.convert(value) if name == 'id' and value == -1: value = '' elif data_type == "timestamp" or name == "timestamp": if value == 'now': value = '' elif value: # This date is assumed to be GMT date = parser.parse(value) # convert to local if not SObject.is_day_column(name): date = SPTDate.convert_to_local(date) try: encoding = locale.getlocale()[1] value = date.strftime("%b %d, %Y - %H:%M").decode(encoding) except: value = date.strftime("%b %d, %Y - %H:%M") else: value = '' else: if isinstance(value, Widget): return value elif not isinstance(value, basestring): try: value + 1 except TypeError: value = str(value) else: value_wdg = DivWdg() value_wdg.add_style("float: right") value_wdg.add_style("padding-right: 3px") value_wdg.add(str(value)) return value_wdg return value
def get_display(my): sobject = my.get_current_sobject() column = my.kwargs.get('column') if column: name = column else: name = my.get_name() value = my.get_value(name=name) if sobject: data_type = SearchType.get_column_type(sobject.get_search_type(), name) else: data_type = 'text' if type(value) in types.StringTypes: wiki = WikiUtil() value = wiki.convert(value) if name == 'id' and value == -1: value = '' elif data_type == "timestamp" or name == "timestamp": if value == 'now': value = '' elif value: # This date is assumed to be GMT date = parser.parse(value) # convert to local if not SObject.is_day_column(name): date = SPTDate.convert_to_local(date) try: encoding = locale.getlocale()[1] value = date.strftime("%b %d, %Y - %H:%M").decode(encoding) except: value = date.strftime("%b %d, %Y - %H:%M") else: value = '' else: if isinstance(value, Widget): return value elif not isinstance(value, basestring): try: value + 1 except TypeError: value = str(value) else: value_wdg = DivWdg() value_wdg.add_style("float: right") value_wdg.add_style("padding-right: 3px") value_wdg.add( str(value) ) return value_wdg return value
def get_display(my): sobject = my.get_current_sobject() my.value = my._get_result(sobject) my.set_value(my.value) #print "setting: ", my.get_value() div = DivWdg() display_value = WikiUtil().convert(my.value) div.add(my.value) return div
def get_display(self): sobject = self.get_current_sobject() self.value = self._get_result(sobject) self.set_value(self.value) #print "setting: ", self.get_value() div = DivWdg() display_value = WikiUtil().convert(self.value) div.add(self.value) return div
def get_display(my): value = my.get_value() name = my.get_name() type = my.get_option("type") if not type: type = my.get_type() # FIXME: this needs to be handled outside of this class to centralize # the type of an element!!! if type in ["timestamp"]: # make a guess here if name.endswith('time'): type = 'time' elif name.endswith('date'): type = 'date' if type == "text": wiki = WikiUtil() display = wiki.convert(value) elif type in ["time"]: if value: display = Date(value).get_display_time() else: display = '' elif type in ["datetime"]: if value: display = Date(value).get_display_datetime() else: display = '' elif type in ["timestamp", 'date']: if value == '{now}': display = Date() elif value: display = Date(value).get_display_date() else: display = '' elif type == "timecode": display = "00:00:00:00" elif type == "currency": display = "$%s" % value elif type == "color": display = DivWdg() color = DivWdg(" ") color.add_style("height: 15px") color.add_style("width: 15px") color.add_style("float: left") color.add_style("margin: 0 5px 0 5px") color.add_style("background: %s" % value) display.add(color) display.add(value) display.add_style("width: 100%") display.add_style("height: 100%") elif type == "boolean": display = DivWdg() display.add_style("text-align: center") display.add_style("width: 100%") display.add_style("height: 100%") if value == True: from pyasm.widget import IconWdg icon = IconWdg("True", IconWdg.CHECK) display.add(icon) elif value == False: from pyasm.widget import IconWdg icon = IconWdg("False", IconWdg.INVALID) display.add(icon) else: display.add(" ") else: if not isinstance(value, basestring): display = DivWdg() display.add_style("float: right") display.add_style("padding-right: 3px") display.add(str(value)) else: display = value return display
def get_action_wdg(my, name): '''get the action widget for ui option of note entry''' note_wdg = DivWdg() note_wdg.add_style("padding-top: 3px") # note options option = DivWdg(css='spt_uber_note_option') cb = CheckboxWdg('is_private') #cb.set_default_checked() checkbox_name = 'note_master_private_cb' master_cb = CheckboxWdg(checkbox_name) if master_cb.is_checked(): cb.set_default_checked() option.add_style('margin-right', '5px') option.add_style('float', 'right') option.add(cb) option.add('private') #commit = TextBtnWdg(label='save', size='small') commit = ActionButtonWdg(title='save', tip="Save Changes") commit.add_style('margin-top: -5px') commit.add_style('margin-bottom: 5px') commit.add_style('float: right') commit.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var td = bvr.src_el.getParent(".spt_table_td"); var text = td.getElement(".spt_note_text"); text.blur(); spt.dg_table.update_row(evt, bvr); td.setStyle('background-color',''); ''', 'cell_only': True }) #commit.set_scale("0.75") # do some gynastics to handle a refresh. if my.parent_wdg: info = my.parent_wdg.get_aux_info() sobject_dict = info.get('sobjects') sobject = sobject_dict.get(my.get_name()) parent = info.get('parent') else: sobject = None parent = None if not sobject: if my.parent_key: parent = SearchKey.get_by_search_key(my.parent_key) # get the latest note #search_key = my.kwargs.get("search_key") #if search_key: # sobject = SearchKey.get_by_search_key(search_key) search = Search('sthpw/note') search.add_parent_filter(parent) search.add_filter('context', name) # Make the assumption that the last one entered is by timestamp search.add_order_by('timestamp desc') sobject = search.get_sobject() # Show a history of notes if sobject: history = ActionButtonWdg(title='history', tip="Show note history") #history = TextBtnWdg(label='history', size='small') #history.get_top_el().add_style("margin-left: 4px") #history.get_top_el().add_style('float: left') history.add_style("float: left") history.add_style("margin-top: -5px") history.add_style("margin-bottom: 5px") note_wdg.add(history) my.parent_key = SearchKey.get_by_sobject(parent) context = name filter = '[{"prefix":"main_body","main_body_enabled":"on","main_body_column":"context","main_body_relation":"is","main_body_value":"%s"}]' % context history.add_behavior({ 'type': 'click_up', 'cbjs_action': "spt.popup.get_widget(evt, bvr)", 'options': { 'class_name': 'tactic.ui.panel.ViewPanelWdg', 'title': 'Notes History', 'popup_id': 'Notes_History_%s' % context }, 'args': { 'search_type': 'sthpw/note', 'view': 'summary', 'parent_key': my.parent_key, 'filter': filter, } }) note_wdg.add(commit) note_wdg.add(option) note_wdg.add("<br clear='all'/>") from pyasm.biz import PrefSetting quick_text = PrefSetting.get_value_by_key('quick_text') if quick_text: quick_sel = SelectWdg('quick_text', label='quick: ') quick_sel.set_option('values', quick_text) quick_sel.add_empty_option('-- text --', '') quick_sel.add_behavior({ 'type': 'change', 'cbjs_action': '''var val = bvr.src_el.value; var text=bvr.src_el.getParent('.spt_note_top').getElement('.spt_note_text') text.value = text.value + val; ''' }) note_wdg.add(SpanWdg(quick_sel, css='small')) note_wdg.add(HtmlElement.br(2)) # Show the last note note_wdg.add("<i>Last note</i> ") if sobject: timestamp = sobject.get_value("timestamp") timestamp = parser.parse(timestamp) timestamp = timestamp.strftime("%m/%d %H:%M") timestamp_div = SpanWdg() timestamp_div.add("(%s)" % timestamp) note_wdg.add(timestamp_div) timestamp_div.add_style("font-size: 11px") timestamp_div.add_style("font-style: italic") # add a private tag access = sobject.get_value("access") if access == 'private': private = SpanWdg() #private.add_style('float: right') private.add(" <i>-- private --</i>") note_wdg.add(private) hr = DivWdg("<hr/>") hr.add_style("height: 1px") hr.add_style("margin-top: -5px") note_wdg.add(hr) div = DivWdg() note_wdg.add(div) div.add_style("max-height", "50px") div.add_style("overflow", "auto") div.add_style("padding: 3px") if sobject: value = sobject.get_value('note') from pyasm.web import WikiUtil value = WikiUtil().convert(value) div.add(value) else: no_notes = DivWdg() div.add(no_notes) no_notes.add('<i> -- No Notes --</i>') no_notes.add_style("font-size: 11px") no_notes.add_style("opacity: 0.7") return note_wdg
def get_display(self): sobject = self.get_current_sobject() column = self.kwargs.get('column') if column: name = column else: name = self.get_name() value = self.get_value(name=name) empty = self.get_option("empty") if empty and self.is_editable() and not value: from pyasm.web import SpanWdg div = DivWdg() div.add_style("text-align: center") div.add_style("width: 100%") div.add_style("white-space: nowrap") if empty in [True, 'true']: div.add("--Select--") div.add_style("opacity: 0.5") return div if sobject: data_type = SearchType.get_column_type(sobject.get_search_type(), name) else: data_type = 'text' if type(value) in types.StringTypes: wiki = WikiUtil() value = wiki.convert(value) if name == 'id' and value == -1: value = '' elif data_type in ["timestamp", "time"] or name == "timestamp": if value == 'now': value = '' elif value: # This date is assumed to be GMT date = parser.parse(value) # convert to user timezone if not SObject.is_day_column(name): date = self.get_timezone_value(date) try: encoding = locale.getlocale()[1] value = date.strftime("%b %d, %Y - %H:%M").decode(encoding) except: value = date.strftime("%b %d, %Y - %H:%M") else: value = '' else: if isinstance(value, Widget): return value elif not isinstance(value, basestring): try: value + 1 except TypeError: value = str(value) #else: # value_wdg.add_style("float: right") # value_wdg.add_style("padding-right: 3px") if sobject and SearchType.column_exists(sobject.get_search_type(), name): value_wdg = DivWdg() self.add_value_update(value_wdg, sobject, name) # don't call str() to prevent utf-8 encode error value_wdg.add(value) value_wdg.add_style("overflow-x: hidden") value_wdg.add_style("text-overflow: ellipsis") # sompe properties min_height = 25 value_wdg.add_style("min-height: %spx" % min_height) single_line = self.get_option("single_line") or False if single_line in ["true", True]: value_wdg.add_style("line-height: %spx" % min_height) value_wdg.add_style("white-space: nowrap") #value_wdg.add_style("overflow-y: hidden") #value_wdg.add_class("spt_scrollable") #value_wdg.add_attr("title", value) link_expression = self.get_option("link_expression") if link_expression: value_wdg.add_class("tactic_new_tab") value_wdg.add_style("display: inline-block") value_wdg.add_attr("search_key", sobject.get_search_key()) value_wdg.add_style("text-decoration: underline") #value_wdg.add_attr("spt_class_name", "tactic.ui.tools.SObjectDetailWdg") value_wdg.add_class("hand") return value_wdg return value
def get_display(my): sobject = my.get_current_sobject() column = my.kwargs.get('column') if column: name = column else: name = my.get_name() value = my.get_value(name=name) if sobject: data_type = SearchType.get_column_type(sobject.get_search_type(), name) else: data_type = 'text' if type(value) in types.StringTypes: wiki = WikiUtil() value = wiki.convert(value) if name == 'id' and value == -1: value = '' elif data_type in ["timestamp","time"] or name == "timestamp": if value == 'now': value = '' elif value: # This date is assumed to be GMT date = parser.parse(value) # convert to user timezone if not SObject.is_day_column(name): date = my.get_timezone_value(date) try: encoding = locale.getlocale()[1] value = date.strftime("%b %d, %Y - %H:%M").decode(encoding) except: value = date.strftime("%b %d, %Y - %H:%M") else: value = '' else: if isinstance(value, Widget): return value elif not isinstance(value, basestring): try: value + 1 except TypeError: value = str(value) #else: # value_wdg.add_style("float: right") # value_wdg.add_style("padding-right: 3px") if sobject and SearchType.column_exists(sobject.get_search_type(), name): value_wdg = DivWdg() value_wdg.add_update( { 'search_key': sobject.get_search_key(), 'column': name } ) # don't call str() to prevent utf-8 encode error value_wdg.add(value) return value_wdg return value
def init(self): search_type = "prod/shot" widget = Widget() search = Search(search_type) div = DivWdg(css="filter_box") filter = SequenceFilterWdg() div.add(filter) #context_filter = ContextFilterWdg(label="Context: ", search_type=) #context_filter.set_search_type(search_type) #div.add(context_filter) context_wdg = TextWdg("context") context_wdg.set_persistence() span = SpanWdg(css="med") span.add("Context: ") span.add(context_wdg) div.add(span) self.context = context_wdg.get_value() if not self.context: self.context = None mode = "latest" filter.alter_search(search) sobjects = search.get_sobjects() widget.add(div) table = Table(css="table") table.add_style("width: 100%") for sobject in sobjects: table.add_row() thumb = ThumbWdg() thumb.set_sobject(sobject) table.add_cell(thumb) table.add_cell(sobject.get_code()) td = table.add_cell(WikiUtil().convert( sobject.get_value("description"))) td.add_style("width: 300px") if mode == "latest": snapshot = Snapshot.get_latest_by_sobject( sobject, self.context) else: snapshot = Snapshot.get_current_by_sobject( sobject, self.context) if not snapshot: table.add_cell("<i>No snapshot found</i>") continue dependency = DependencyWdg() dependency.set_show_title(False) dependency.set_sobject(snapshot) table.add_cell(dependency) widget.add(table) self.add(widget)
def get_display(my): sobject = my.get_current_sobject() if isinstance(sobject, Shot): frame_range = sobject.get_frame_range() frame_in, frame_out = sobject.get_frame_handles() frame_notes = sobject.get_frame_notes() else: from pyasm.prod.biz import FrameRange frame_start = my._get_frame_num(sobject, "tc_frame_start") frame_end = my._get_frame_num(sobject, "tc_frame_end") frame_range = FrameRange(frame_start, frame_end, 1) frame_in, frame_out = my._get_frame_handles(sobject) frame_notes = sobject.get_value("frame_note", no_exception=True) frame_notes = WikiUtil().convert(frame_notes) if frame_range.frame_end == frame_range.frame_start == 0: return 'n/a' widget = SpanWdg() widget.set_attr("nowrap", "1") offset = 2 label_width = 16 if frame_range.frame_start > 99: label_width = 20 # start / end frame duration_color = '#969353' div = DivWdg() div.add_tip('START -- END (TOTAL)') wdg_width = 100 div.add_style('width', wdg_width) total = frame_range.frame_end - frame_range.frame_start + 1 start_frame = SpanWdg(str(frame_range.frame_start)) end_frame = SpanWdg(str(frame_range.frame_end)) end_div = FloatDivWdg(end_frame) duration_width = wdg_width * 0.2 - offset spacer_width = float('%.2f' %((duration_width + offset) * (frame_range.frame_start -1 ) /\ frame_range.frame_end)) start_div = FloatDivWdg(start_frame, width=label_width + spacer_width) start_div.add_class('right_content') duration = FloatDivWdg(width=duration_width) duration.add_style("border: 1px dotted %s" % duration_color) duration.add_style("margin-top: 3px") duration.add_style("margin-left: 5px") duration.add_style("margin-right: 5px") duration.add_style("height: 3px") duration.add_style("line-height: 3px") div.add(start_div) div.add(duration) div.add(end_div) dur_text = FloatDivWdg('(%s)' % total) dur_text.add_style("opacity", "0.5") div.add(dur_text) widget.add(div) widget.add(HtmlElement.br()) if frame_in: # in / out frame duration_color = '#b8b365' div = DivWdg() div.add_tip('IN -- OUT') div.add_style('width', wdg_width) handle_total = frame_out - frame_in + 1 in_frame = SpanWdg(str(frame_in)) out_frame = SpanWdg(str(frame_out)) if frame_range.frame_start == 0: frame_range.frame_start = 0.001 spacer_width = float('%.2f' % ((spacer_width) * \ float(frame_in) /frame_range.frame_start )) in_div = FloatDivWdg(in_frame, width=label_width + spacer_width) in_div.add_class('right_content') out_div = FloatDivWdg(out_frame) factor = float(handle_total) / total if factor > 1: factor = 1 duration_width = (duration_width + offset) * factor - offset duration = FloatDivWdg(width=duration_width) duration.add_style("border: 1px solid %s" % duration_color) duration.add_style("background", duration_color) duration.add_style("margin-top: 5px") duration.add_style("margin-left: 5px") duration.add_style("margin-right: 5px") duration.add_style("line-height: 1px") duration.add(' ') # IE needs that to draw a 1px wide div bar = FloatDivWdg('<!-- -->', width=1) bar.add_style("margin-top: 1px") bar.add_style("height: 10px") bar.add_style("line-height: 10px") bar.add_style("background", duration_color) div.add(in_div) div.add(bar) div.add(duration) div.add(bar) div.add(out_div) dur_text = SpanWdg('(%s)' % handle_total) div.add(dur_text) widget.add(div) if frame_notes: widget.add(HtmlElement.br()) widget.add(frame_notes) return widget
def get_display(self): sobject = self.get_current_sobject() column = self.kwargs.get('column') if column: name = column else: name = self.get_name() value = self.get_value(name=name) empty = self.get_option("empty") if empty and self.is_editable() and not value: from pyasm.web import SpanWdg div = DivWdg() div.add_style("text-align: center") div.add_style("width: 100%") div.add_style("white-space: nowrap" ) if empty in [True, 'true']: div.add("--Select--") div.add_style("opacity: 0.5") return div if sobject: data_type = SearchType.get_column_type(sobject.get_search_type(), name) else: data_type = 'text' if type(value) in types.StringTypes: wiki = WikiUtil() value = wiki.convert(value) if name == 'id' and value == -1: value = '' elif data_type in ["timestamp","time"] or name == "timestamp": if value == 'now': value = '' elif value: # This date is assumed to be GMT date = parser.parse(value) # convert to user timezone if not SObject.is_day_column(name): date = self.get_timezone_value(date) try: encoding = locale.getlocale()[1] value = date.strftime("%b %d, %Y - %H:%M").decode(encoding) except: value = date.strftime("%b %d, %Y - %H:%M") else: value = '' else: if isinstance(value, Widget): return value elif not isinstance(value, basestring): try: value + 1 except TypeError: value = str(value) #else: # value_wdg.add_style("float: right") # value_wdg.add_style("padding-right: 3px") if sobject and SearchType.column_exists(sobject.get_search_type(), name): value_wdg = DivWdg() self.add_value_update(value_wdg, sobject, name) # don't call str() to prevent utf-8 encode error value_wdg.add(value) value_wdg.add_style("overflow-x: hidden") value_wdg.add_style("text-overflow: ellipsis") # sompe properties min_height = 25 value_wdg.add_style("min-height: %spx" % min_height) single_line = self.get_option("single_line") or False if single_line in ["true", True]: value_wdg.add_style("line-height: %spx" % min_height) value_wdg.add_style("white-space: nowrap") #value_wdg.add_style("overflow-y: hidden") #value_wdg.add_class("spt_scrollable") #value_wdg.add_attr("title", value) link_expression = self.get_option("link_expression") if link_expression: value_wdg.add_class("tactic_new_tab") value_wdg.add_style("display: inline-block") value_wdg.add_attr("search_key", sobject.get_search_key()) value_wdg.add_style("text-decoration: underline") #value_wdg.add_attr("spt_class_name", "tactic.ui.tools.SObjectDetailWdg") value_wdg.add_class("hand") return value_wdg return value