Example #1
0
 def get_display(my):
     widget = DivWdg()
     table = Table()
     table.add_attr('class','scraper')
     table.add_row()
     tb = TextWdg('title_box')
     tb.add_attr('id','title_box')
     multiple_titles = None
     print "MY.TITLE_OF_SHOW = %s" % my.title_of_show
     if my.title_of_show not in [None,'']:
         tb.set_value(my.title_of_show)
         #poster_url_text = my.get_poster_url(my.title_of_show)
         #poster_url = poster_url_text.split('=')[1]
         multiple_titles = my.get_multiple_title_info(my.title_of_show)
     print "MULTIPLE_TITLES = %s" % multiple_titles
     tb.add_behavior(my.get_search())
     table.add_cell(tb)
     if multiple_titles not in [None,''] and len(multiple_titles) > 0:
         for m in multiple_titles:
             table.add_row()
             table.add_cell('<img src="%s"/>' % m['TopLevel']['poster'])
             mkeys = m.keys()
             for k in mkeys: 
                 table.add_row()
                 table.add_cell('<b><u>%s</u></b>' % k)
                 dudes = m[k]
                 dkeys = dudes.keys()
                 for d in dkeys:
                     table.add_row()
                     table.add_cell('%s: %s' % (d, dudes[d])) 
     widget.add(table)
     return widget
Example #2
0
 def get_display(my):   
     from tactic.ui.widget import SObjectCheckinHistoryWdg
     my.code = str(my.kwargs.get('source_code'))
     my.sk = my.server.build_search_key('twog/source',my.code)
     my.movement_code = str(my.kwargs.get('movement_code'))
     ms = MovementScripts(movement_code=my.movement_code)
     clients_expr = "@SOBJECT(twog/client['@ORDER_BY','name desc'])" 
     clients = my.server.eval(clients_expr)
     client_sel = '<select class="REPLACE_ME"><option value="">--Select--</option>'
     for client in clients:
         client_sel = '%s<option value="%s">%s</option>' % (client_sel, client.get('code'), client.get('name'))
     client_sel = '%s</select>' % client_sel
     existing_expr = "@SOBJECT(twog/outside_barcode['source_code','%s'])" % my.code
     existing = my.server.eval(existing_expr)
     count = 0
     table = Table()
     table.add_attr('class','movement_outside_barcodes')
     for obc in existing:
         table.add_row()
         barcode_text_wdg = TextWdg('outside_barcode_insert_%s' % count)
         barcode_text_wdg.set_value(obc.get('barcode'))
         barcode_text_wdg.add_attr('curr_code',obc.get('code'))
         table.add_cell(barcode_text_wdg)
         new_sel = client_sel
         new_sel2 = new_sel.replace('REPLACE_ME','outside_client_%s' % count)
         found = new_sel2.find('"%s"' % obc.get('client_code'))
         if found > 0:
             part1 = new_sel2[:found]
             part2 = new_sel2[found:]
             found2 = part2.find('>')
             if found2 > 0:
                 good2 = part2[found2:]
                 new_sel2 = '%s"%s" selected="selected"%s' % (part1, obc.get('client_code'),good2)
         table.add_cell(new_sel2)
         count = count + 1
     additional_count = [1, 2, 3, 4, 5]
     for n in additional_count:
         table.add_row()
         barcode_text_wdg = TextWdg('outside_barcode_insert_%s' % count)
         barcode_text_wdg.add_attr('curr_code','')
         table.add_cell(barcode_text_wdg)
         new_sel = client_sel
         new_sel = new_sel.replace('REPLACE_ME','outside_client_%s' % count)
         table.add_cell(new_sel)
         count = count + 1
     table.add_row()
     save_tbl = Table()
     save_tbl.add_row()
     s1 = save_tbl.add_cell(' ')
     s1.add_attr('width','100%s' % '%')
     save_cell = table.add_cell('<input type="button" value="Save All"/>')
     save_cell.add_attr('align','center')
     save_cell.add_behavior(ms.get_save_outside_barcodes_behavior(my.code))
     s2 = save_tbl.add_cell(' ')
     s2.add_attr('width','100%s' % '%')
     ss = table.add_cell(save_tbl)
     ss.add_attr('colspan','2')
     ss.add_attr('align','center')
     return table
Example #3
0
 def get_display(my):
     from pyasm.search import Search
     #from tactic_client_lib import TacticServerStub
     barcode = ''
     sources = []
     bad_sources = []
     if 'barcode' in my.kwargs.keys():
         barcode = my.kwargs.get('barcode')
         tracker_s = Search("twog/location_tracker")
         tracker_s.add_filter('location_barcode',barcode)
         trackers = tracker_s.get_sobjects()
         #print "BARCODE = %s" % barcode
         #print "LEN TRACKERS = %s" % len(trackers)
         for t in trackers:
             tdate = t.get('timestamp')
             source_barcode = t.get('source_barcode')
             other_tracks = Search("twog/location_tracker")
             other_tracks.add_filter('source_barcode',source_barcode)
             other_tracks.add_filter('timestamp',tdate, op=">")
             others = other_tracks.get_sobjects()
             if len(others) == 0:
                 source_s = Search("twog/source")
                 source_s.add_filter('barcode',source_barcode)
                 source = source_s.get_sobject()
                 if source:
                     if source.get_value('in_house') in [True,'true','True',1,'1']:
                         sources.append(source)
                 else:
                     bad_sources.append({'barcode': source_barcode, 'title': 'UNKNOWN SOURCE'})
     
     table = Table()
     table.add_attr('class','location_inventory_wdg')
     table.add_row()
     bc = TextWdg('nextbc')
     bc.add_attr('id', 'location_inventory_txtbox')
     bc.add_behavior(my.get_entry_bvr())
     bc.set_value(barcode)
     table.add_cell(bc)
     #print "LEN SOURCES = %s" % len(sources)
     if len(sources) > 0:
         table.add_row()
         table.add_cell("<b>TOTAL: %s (UNKNOWN: %s)</b>" % (len(sources), len(bad_sources)))
     for source in sources:
         table.add_row()
         table.add_cell('Barcode: %s, Code: %s, Name: %s: %s' % (source.get_value('barcode'), source.get_code(), source.get_value('title'), source.get_value('episode')))
     if len(bad_sources) > 0:
         table.add_row()
         table.add_cell("<b>UNKNOWN SOURCES</b>")
         for b in bad_sources:
             table.add_row()
             table.add_cell('Barcode: %s, Name: %s' % (b.get('barcode'), b.get('title')))
     widget = DivWdg()
     widget.add(table)
     return widget
Example #4
0
    def get_display(my):   
        table = Table()
        my.movement_code = my.kwargs.get('movement_code')
        table.add_attr('class', 'movement_add_source')
        table.add_attr('movement_id','')
        table.add_attr('movement_sk','')
        table.add_attr('movement_code','')
        top_row = table.add_row()
        top_row.add_style('background-color: #eaeaea;')
        if my.movement_code not in ['',None]:
            ms = MovementScripts(movement_code=my.movement_code)
            barcode_text_wdg = TextWdg('source_barcode_insert')
            barcode_text_wdg.add_attr('id','source_barcode_insert')
            barcode_text_wdg.add_behavior(ms.get_barcode_insert_behavior())
            table.add_cell('Barcode: ')
            table.add_cell(barcode_text_wdg)

        widget = DivWdg()
        widget.add(table)
        if my.movement_code not in ['',None]:
            widget.add_behavior(my.get_on_load_js())
        return widget
 def txtbox(my, name, val, code, old_val, width='200px', js='no'):
     txt = TextWdg(name)
     txt.add_attr('id', name)
     txt.add_attr('code', code)
     txt.add_attr('old_val', old_val)
     txt.add_style('width: %s;' % width)
     txt.set_value(val)
     if js == 'yes':
         txt.add_behavior(my.get_nums_only())
     return txt
 def txtbox(my, name, val, code, old_val, width='200px', js='no'):
     txt = TextWdg(name)
     txt.add_attr('id', name)
     txt.add_attr('code', code)
     txt.add_attr('old_val', old_val)
     txt.add_style('width: %s;' % width)
     txt.set_value(val)
     if js == 'yes':
         txt.add_behavior(my.get_nums_only())
     return txt
Example #7
0
    def get_display(my):
        from tactic_client_lib import TacticServerStub
        login = Environment.get_login()
        user_name = login.get_login()
        user_name = user_name.replace('.','')
        barcodes = []
        complete = False
        errors = ''
        first_loc_num1 = 5660
        last_loc_num1 = 5991
        first_loc_num2 = 6020
        last_loc_num2 = 6037
        if 'barcodes' in my.kwargs.keys():
            barcodes = my.kwargs.get('barcodes').split(',') 
        if 'complete' in my.kwargs.keys():
            complete = my.kwargs.get('complete')
        if 'errors' in my.kwargs.keys():
            errors = my.kwargs.get('errors')
        table = Table()
        table.add_attr('id','tracker_%s' % user_name) 
        table.add_attr('class','tracker_%s' % user_name) 
        if errors not in [None,'']:
            table.add_row()
            csp1 = table.add_cell(errors)
            csp1.add_attr('colspan','2')
        count = 0
        if complete:
            server = TacticServerStub.get()
            t2 = Table()
            for bc in barcodes:
                if 'EMP' in bc:
                    that_user = server.eval("@SOBJECT(sthpw/login['barcode','%s'])" % bc)
                    if that_user:
                        that_user = that_user[0]
                    else:
                        that_user = {'login': '******'}
                    t2.add_row()
                    t2.add_cell('USER: '******'login'))
                    t2.add_cell('BARCODE: %s' % bc)
            for bc in barcodes:
                bc_num = 555555555
                if '2G' in bc:
                    bc_num = bc.replace('2G','').replace('A','').replace('B','').replace('C','').replace('V','')
                    bc_num = int(bc_num)
                if (bc_num >= first_loc_num1 and bc_num <= last_loc_num1) or (bc_num >= first_loc_num2 and bc_num <= last_loc_num2):
                    that_location = server.eval("@SOBJECT(twog/inhouse_locations['barcode','%s'])" % bc)
                    if that_location:
                        that_location = that_location[0]
                    else:
                        that_location = {'name': 'UNKNOWN LOCATION'}
                    t2.add_row()
                    t2.add_cell('LOCATION: ')
                    t2.add_cell(that_location.get('name'))
                    t2.add_cell('BARCODE: %s' % bc)
            for bc in barcodes:
                bc_num = 555555555
                if '2G' in bc:
                    bc_num = bc.replace('2G','').replace('A','').replace('B','').replace('C','').replace('V','')
                    bc_num = int(bc_num)
                #if 'LOC' not in bc and 'EMP' not in bc:
                if not ((bc_num >= first_loc_num1 and bc_num <= last_loc_num1) or (bc_num >= first_loc_num2 and bc_num <= last_loc_num2)) and 'EMP' not in bc:
                    that_src = server.eval("@SOBJECT(twog/source['barcode','%s'])" % bc)
                    if that_src:
                        that_src = that_src[0]
                    else:
                        that_src = {'title': 'UNKNOWN SOURCE', 'episode': '', 'season': '', 'part': ''}
                    full_name = that_src.get('title')
                    if that_src.get('episode') not in [None,'']:
                        full_name = '%s EPISODE: %s' % (full_name, that_src.get('episode'))
                    if that_src.get('season') not in [None,'']:
                        full_name = '%s SEASON: %s' % (full_name, that_src.get('season'))
                    if that_src.get('part') not in [None,'']: 
                        full_name = '%s PART: %s' % (full_name, that_src.get('part'))
                    t2.add_row()
                    t2.add_cell('SOURCE: ')
                    t2.add_cell(full_name)
                    t2.add_cell('BARCODE: %s' % bc)
            table.add_row()
            csp2 = table.add_cell(t2)
            csp2.add_attr('colspan','2')
        else:                
            for bc in barcodes:
                table.add_row()
                table.add_cell('BARCODE: ')
                oldtxt = TextWdg('oldtxt')
                oldtxt.set_attr('id', 'txt_%s' % count)
                oldtxt.set_value(bc)
                table.add_cell(oldtxt)
                count = count + 1
            
        table.add_row()
        nextbc = TextWdg('nextbc')
        nextbc.add_attr('id', 'txt_%s' % count)
        nextbc.add_behavior(my.get_entry_bvr(user_name))
        table.add_cell('Barcode: ')
        table.add_cell(nextbc)

        widget = DivWdg()
        widget.add(table)
        widget.add_behavior(my.get_on_load_js(count))
        return widget
Example #8
0
    def get_default_display_wdg(cls, element_name, display_options, element_type, kbd_handler=False):

        from pyasm.widget import TextAreaWdg, CheckboxWdg, SelectWdg, TextWdg
        if element_type in ["integer", "smallint", "bigint", "int"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableIntegerTextEdit'
            }
            input = TextWdg("main")
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)

        elif element_type in ["float"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableFloatTextEdit'
            }
            input = TextAreaWdg("main")
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)

        elif element_type in ["string", "link", "varchar", "character", "timecode"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableMultiLineTextEdit'
            }
            input = TextWdg('main')
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)


        elif element_type in ["text"]:
            behavior = {
                'type': 'keyboard',
                'kbd_handler_name': 'DgTableMultiLineTextEdit'
            }
            input = TextAreaWdg('main')
            input.set_options(display_options)
            if kbd_handler:
                input.add_behavior(behavior)

        elif element_type == "boolean":
            input = CheckboxWdg('main')
            input.set_options(display_options)
            input.add_behavior(
             {"type" : "click_up",
                    'propagate_evt': True})

        elif element_type in  ["timestamp", "date", "time", "datetime2"]:
            from tactic.ui.widget import CalendarInputWdg, CalendarWdg, TimeInputWdg
            # FIXME: take wild guess for the time
            if element_name.endswith("_time"):
                #input = TimeInputWdg()
                behavior = {
                    'type': 'keyboard',
                    'kbd_handler_name': 'DgTableMultiLineTextEdit'
                }
                input = TextWdg('main')
                input.set_options(display_options)
                if kbd_handler:
                    input.add_behavior(behavior)

            else:
                #input = CalendarWdg()
                input = CalendarInputWdg()
                input.set_option('show_activator', False)
            #input.set_options(display_options)

        elif element_type == 'datetime':
            from tactic.ui.widget import CalendarInputWdg
            input = CalendarInputWdg()
            input.set_option('show_time', 'true')

        elif element_type == "color":
            from tactic.ui.widget import ColorInputWdg
            input = ColorInputWdg()
            input.set_options(display_options)

        elif element_type =="sqlserver_timestamp":
            # better then set it to None
            input = TextWdg()
            input.add_attr('disabled','disabled')
        else:
            # else try to instantiate it as a class
            print "WARNING: EditWdg handles type [%s] as default TextWdg" %element_type
            input = TextWdg()
            input.add("No input defined")

        return input 
Example #9
0
    def get_display(self):

        top_wdg = DivWdg()
        top_wdg.add_style("color: black")
        top_wdg.add_style("width: 350px")
        top_wdg.add_style("margin-top: 10px")
        top_wdg.add_style("padding: 10px")
        top_wdg.add_border()
        title = DivWdg()
        title.add_style("color: black")
        title.add_style("margin-top: -22px")

        top_wdg.add(title)
        #if not self.name_string:
        #    title.add('No database column')
        #    return top_wdg
        
        title.add("Widget Definition")

        widget_types = {
            'foreign_key': 'tactic.ui.table.ForeignKeyElementWdg',
            'button': 'tactic.ui.table.ButtonElementWdg',
            'expression': 'tactic.ui.table.ExpressionElementWdg'
        }


        web = WebContainer.get_web()
        config_string = web.get_form_value("config_xml")
        if not config_string:
            config_string = '<config/>'
        xml = Xml()
        xml.read_string(config_string)

        #print "config_string: ", config_string

        # get values from the config file
        element_name = xml.get_value('element/@name')

        config = WidgetConfig.get(view='element',xml='<config><element>%s</element></config>' % config_string)
        display_options = config.get_display_options(element_name)


        title = xml.get_value('element/@title')
        display_handler = xml.get_value('element/display/@class')
        if not display_handler:
            display_handler = 'tactic.ui.panel.TypeTableElementWdg'

        widget_name = xml.get_value('element/display/@widget')
        if not widget_name:
            widget_name = 'custom'

 
        custom_table = Table()
        custom_table.add_style("color: black")
        top_wdg.add(custom_table)

        name_text = DivWdg()
        name_text.add_style("color: black")
        name_text.add(element_name)
        custom_table.add_row()
        custom_table.add_cell("Name: ")
        custom_table.add_cell(name_text)



        # add title
        custom_table.add_row()
        title_wdg = TextWdg("custom_title")
        title_wdg.set_value(title)
        title_wdg.add_attr("size", "50")
        custom_table.add_cell( "Title: " )
        custom_table.add_cell( title_wdg )

        # add description
        #custom_table.add_row()
        #description_wdg = TextAreaWdg("custom_description")
        #td = custom_table.add_cell( "Description: " )
        #td.add_style("vertical-align: top")
        #custom_table.add_cell( description_wdg )


        type_select = SelectWdg("custom_type")
        #type_select.add_empty_option("-- Select --")

        type_select.set_option("values", "string|integer|float|boolean|currency|date|foreign_key|link|list|button|custom")
        type_select.set_option("labels", "String(db)|Integer(db)|Float(db)|Boolean(db)|Currency(db)|Date(db)|Foreign Key|Link|List|Button|Custom")
        type_select.set_value(widget_name)

        #type_select.set_option("values", "string|integer|float|boolean|currency|date|link|list|foreign_key|button|empty")
        #type_select.set_option("labels", "String|Integer|Float|Boolean|Currency|Date|Link|List|Foreign Key|Button|Empty")
        custom_table.add_row()
        td = custom_table.add_cell("Widget Type: ")
        td.add_style("vertical-align: top")
        td = custom_table.add_cell(type_select)
        type_select.add_event("onchange", "spt.CustomProject.property_type_select_cbk(this)")


        td.add(HtmlElement.br())
        display_handler_text = TextWdg("display_handler")
        display_handler_text.add_attr("size", "50")
        display_handler_text.set_value(display_handler)
        td.add(display_handler_text)



        # extra info for foreign key
        custom_table.add_row()
        div = DivWdg()
        div.add_class("foreign_key_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")
        div.add("Options")
        div.add(HtmlElement.br())



        # extra info for foreign key
        custom_table.add_row()
        div = DivWdg()
        div.add_class("foreign_key_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")
        div.add("Options")
        div.add(HtmlElement.br())
        # TODO: this class should not be in prod!!
        from pyasm.prod.web import SearchTypeSelectWdg
        div.add("Relate to: ")
        search_type_select = SearchTypeSelectWdg("foreign_key_search_select", mode=SearchTypeSelectWdg.CURRENT_PROJECT)
        div.add(search_type_select)
        td.add(div)



        # extra info for list
        custom_table.add_row()
        div = DivWdg()
        div.add_class("list_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")
        div.add("Options")
        div.add(HtmlElement.br())
        # TODO: this class should not be in prod!!
        from pyasm.prod.web import SearchTypeSelectWdg
        div.add("Values: ")
        search_type_text = TextWdg("list_values")
        div.add(search_type_text)
        td.add(div)




        # extra info for button
        custom_table.add_row()
        div = DivWdg()
        div.add_style("color: black")
        div.add_class("button_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")

        #class_path = "tactic.ui.table.ButtonElementWdg"
        class_path = display_handler
        button = Common.create_from_class_path(class_path)
        args_keys = button.get_args_keys()


        div.add("Options")
        div.add(HtmlElement.br())

        for key in args_keys.keys():
            option_name_text = HiddenWdg("option_name")
            option_name_text.set_value(key)
            div.add(option_name_text)

            div.add("%s: " % key)
            div.add(" &nbsp; &nbsp;")

            input = button.get_input_by_arg_key(key)

            value = display_options.get(key)
            if value:
                input.set_value(value)

            div.add(input)
            div.add(HtmlElement.br())
        td.add(div)






        # is searchable checkbox
        #custom_table.add_row()
        #current_searchable_wdg = CheckboxWdg("is_searchable")
        #current_view_wdg.set_checked()
        #custom_table.add_cell("Searchable? ")
        #td = custom_table.add_cell(current_searchable_wdg)

        custom_table.close_tbody()


        return top_wdg
    def get_display(my):
        widget = DivWdg()
        table = Table()
        table.add_attr('class','client_deliverable_wdg')
        table.add_row()
        table2 = Table()
        table2.add_style('border-spacing: 5px;')
        table2.add_style('border-collapse: separate;')
        table2.add_row()

        c1 = table2.add_cell('Order Code:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('order_code')
        tb1.add_attr('id','order_code')
        tb1.add_attr('disabled','disabled')
        tb1.set_value(my.sob['order_code'])
        table2.add_cell(tb1)

        c1 = table2.add_cell('PO Number:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('po_number')
        tb1.add_attr('id','po_number')
        tb1.add_attr('disabled','disabled')
        tb1.set_value(my.sob['po_number'])
        table2.add_cell(tb1)

        c1 = table2.add_cell('Title Code:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('title_code')
        tb1.add_attr('id','title_code')
        tb1.add_attr('disabled','disabled')
        tb1.set_value(my.sob['title_code'])
        table2.add_cell(tb1)

        c1 = table2.add_cell('Platform:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('platform')
        tb1.add_attr('id','platform')
        tb1.add_attr('disabled','disabled')
        tb1.set_value(my.sob['platform'])
        table2.add_cell(tb1)

        c1 = table2.add_cell('Client:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('client_name')
        tb1.add_attr('id','client_name')
        tb1.add_attr('disabled','disabled')
        tb1.set_value(my.sob['client_name'])
        table2.add_cell(tb1)

        table2.add_row()
        table2.add_cell(table2.hr())
        table2.add_row()

        c1 = table2.add_cell('Title Source(s):')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('original_source_code')
        tb1.add_attr('id','original_source_code')
        tb1.add_attr('disabled','disabled')
        tb1.add_style('width','200px')
        tb1.set_value(my.sob['original_source_code'])
        c2 = table2.add_cell(tb1)
        c2.add_attr('colspan','2')

        c1 = table2.add_cell('Title Source Barcodes(s):')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('original_source_barcode')
        tb1.add_attr('id','original_source_barcode')
        tb1.add_attr('disabled','disabled')
        tb1.add_style('width','200px')
        tb1.set_value(my.sob['original_source_barcode'])
        c2 = table2.add_cell(tb1)
        c2.add_attr('colspan','2')

        c1 = table2.add_cell('Ancestors:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('ancestors')
        tb1.add_attr('id','ancestors')
        tb1.add_attr('disabled','disabled')
        tb1.add_style('width','300px')
        tb1.set_value(my.sob['ancestors'])
        c2 = table2.add_cell(tb1)
        c2.add_attr('colspan','3')

        table2.add_row()
        table2.add_cell(table2.hr())
        table2.add_row()

        c1 = table2.add_cell('Destination:')
        c1.add_attr('nowrap','nowrap')
        destination_sel = SelectWdg('destination')
        destination_sel.add_attr('id','destination')
        destination_sel.append_option('--Select--','')
        for c in my.all_clients:
            destination_sel.append_option(c.get('name'),c.get('name'))
        if my.sob.get('destination') == None:
            my.sob['destination'] = ''
        destination_sel.set_value(my.sob.get('destination'))
        table2.add_cell(destination_sel)


        if my.sob.get('record_id') in [None,'']:
            next_id_sob = my.server.eval("@SOBJECT(twog/global_resource['name','sony_next_unique_id'])")[0]
            next_id = int(next_id_sob.get('description'))
            my.sob['record_id'] = next_id
            my.server.update(next_id_sob.get('__search_key__'), {'description': next_id + 1}, triggers=False)
        c1 = table2.add_cell('Record ID:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('record_id')
        tb1.add_attr('id','record_id')
        tb1.set_value(my.sob['record_id'])
        table2.add_cell(tb1)

        c1 = table2.add_cell('Alpha ID:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('alpha_id')
        tb1.add_attr('id','alpha_id')
        tb1.set_value(my.sob['alpha_id'])
        table2.add_cell(tb1)

        c1 = table2.add_cell('Client Barcode:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('client_barcode')
        tb1.add_attr('id','client_barcode')
        tb1.set_value(my.sob['client_barcode'])
        table2.add_cell(tb1)

        c1 = table2.add_cell('Release Number:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('release_number')
        tb1.add_attr('id','release_number')
        tb1.set_value(my.sob['release_number'])
        table2.add_cell(tb1)

        table2.add_row()

        c1 = table2.add_cell('Title ID:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('title_id')
        tb1.add_attr('id','title_id')
        tb1.set_value(my.sob['title_id'])
        table2.add_cell(tb1)

        c1 = table2.add_cell('Title Name:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('title_name')
        tb1.add_attr('id','title_name')
        tb1.set_value(my.sob['title_name'])
        table2.add_cell(tb1)

        c1 = table2.add_cell('Title Type:')
        c1.add_attr('nowrap','nowrap')
        title_type_sel = SelectWdg('title_type')
        title_type_sel.add_attr('id','title_type')
        title_type_sel.append_option('--Select--','')
        for type in my.title_types:
            title_type_sel.append_option(type,type)
        if my.sob.get('title_type') == None:
            my.sob['title_type'] = ''
        title_type_sel.set_value(my.sob.get('title_type'))
        table2.add_cell(title_type_sel)

        c1 = table2.add_cell('Title Comment:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('title_comment')
        tb1.add_attr('id','title_comment')
        tb1.add_style('width','300px')
        tb1.set_value(my.sob['title_comment'])
        c2 = table2.add_cell(tb1)
        c2.add_attr('colspan','3')

        table2.add_row()

        c1 = table2.add_cell('Clip Id:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('clip_id')
        tb1.add_attr('id','clip_id')
        tb1.set_value(my.sob['clip_id'])
        table2.add_cell(tb1)

        table2.add_row()
        table2.add_cell(table2.hr())
        table2.add_row()

        c1 = table2.add_cell('Trailer Number:')
        c1.add_attr('nowrap','nowrap')
        trailer_number_sel = SelectWdg('trailer_number')
        trailer_number_sel.add_attr('id','trailer_number')
        trailer_number_sel.append_option('--Select--','')
        for number in my.trailer_numbers:
            trailer_number_sel.append_option(number,number)
        if my.sob.get('trailer_number') == None:
            my.sob['trailer_number'] = ''
        trailer_number_sel.set_value(my.sob.get('trailer_number'))
        table2.add_cell(trailer_number_sel)

        c1 = table2.add_cell('Trailer Rev Number:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('trailer_rev_number')
        tb1.add_attr('id','trailer_rev_number')
        tb1.set_value(my.sob['trailer_rev_number'])
        table2.add_cell(tb1)

        c1 = table2.add_cell('Trailer Type:')
        c1.add_attr('nowrap','nowrap')
        trailer_type_sel = SelectWdg('trailer_type')
        trailer_type_sel.add_attr('id','trailer_type')
        trailer_type_sel.append_option('--Select--','')
        for type in my.trailer_types:
            trailer_type_sel.append_option(type,type)
        if my.sob.get('trailer_type') == None:
            my.sob['trailer_type'] = ''
        trailer_type_sel.set_value(my.sob.get('trailer_type'))
        table2.add_cell(trailer_type_sel)

        c1 = table2.add_cell('Trailer Version:')
        c1.add_attr('nowrap','nowrap')
        trailer_version_sel = SelectWdg('trailer_version')
        trailer_version_sel.add_attr('id','trailer_version')
        trailer_version_sel.append_option('--Select--','')
        for version in my.trailer_versions:
            trailer_version_sel.append_option(version,version)
        if my.sob.get('trailer_version') == None:
            my.sob['trailer_version'] = ''
        trailer_version_sel.set_value(my.sob.get('trailer_version'))
        table2.add_cell(trailer_version_sel)

        table2.add_row()
        table2.add_cell(table2.hr())
        table2.add_row()

        c1 = table2.add_cell('Language Audio:')
        c1.add_attr('nowrap','nowrap')
        language_audio_sel = SelectWdg('language_audio')
        language_audio_sel.append_option('--Select--','')
        for language in my.audio_languages:
            language_audio_sel.append_option(language,language)
        if my.sob.get('language_audio') == None:
            my.sob['language_audio'] = ''
        language_audio_sel.set_value(my.sob.get('language_audio'))
        table2.add_cell(language_audio_sel)

        c1 = table2.add_cell('Language Subtitled:')
        c1.add_attr('nowrap','nowrap')
        language_subtitled_sel = SelectWdg('language_subtitled')
        language_subtitled_sel.add_attr('id','language_subtitled')
        language_subtitled_sel.append_option('--Select--','')
        for language in my.subtitle_languages:
            language_subtitled_sel.append_option(language,language)
        if my.sob.get('language_subtitled') == None:
            my.sob['language_subtitled'] = ''
        language_subtitled_sel.set_value(my.sob.get('language_subtitled'))
        table2.add_cell(language_subtitled_sel)

        c1 = table2.add_cell('Language Text:')
        c1.add_attr('nowrap','nowrap')
        language_text_sel = SelectWdg('language_text')
        language_text_sel.add_attr('id','language_text')
        language_text_sel.append_option('--Select--','')
        for language in my.text_languages:
            language_text_sel.append_option(language,language)
        if my.sob.get('language_text') == None:
            my.sob['language_text'] = ''
        language_text_sel.set_value(my.sob.get('language_text'))
        table2.add_cell(language_text_sel)

        c1 = table2.add_cell('Original Language:')
        c1.add_attr('nowrap','nowrap')
        original_language_sel = SelectWdg('original_language')
        original_language_sel.add_attr('id','original_language')
        original_language_sel.append_option('--Select--','')
        for language in my.original_languages:
            original_language_sel.append_option(language,language)
        if my.sob.get('original_language') == None:
            my.sob['original_language'] = ''
        original_language_sel.set_value(my.sob.get('original_language'))
        table2.add_cell(original_language_sel)

        table2.add_row()
        table2.add_cell(table2.hr())
        table2.add_row()

        c1 = table2.add_cell('Source:')
        c1.add_attr('nowrap','nowrap')
        source_sel = SelectWdg('source')
        source_sel.add_attr('id','source')
        source_sel.append_option('--Select--','')
        for s in my.sources:
            source_sel.append_option(s,s)
        if my.sob.get('source') == None:
            my.sob['source'] = ''
        source_sel.set_value(my.sob.get('source'))
        table2.add_cell(source_sel)

        c1 = table2.add_cell('Audio Config:')
        c1.add_attr('nowrap','nowrap')
        audio_config_sel = SelectWdg('audio_config')
        audio_config_sel.add_attr('id','audio_config')
        audio_config_sel.append_option('--Select--','')
        for a in my.audio_configs:
            audio_config_sel.append_option(a,a)
        if my.sob.get('audio_config') == None:
            my.sob['audio_config'] = ''
        audio_config_sel.set_value(my.sob.get('audio_config'))
        table2.add_cell(audio_config_sel)

        c1 = table2.add_cell('Master Audio Config:')
        c1.add_attr('nowrap','nowrap')
        master_audio_config_sel = SelectWdg('master_audio_config')
        master_audio_config_sel.add_attr('id','master_audio_config')
        master_audio_config_sel.append_option('--Select--','')
        for a in my.audio_configs:
            master_audio_config_sel.append_option(a,a)
        if my.sob.get('master_audio_config') == None:
            my.sob['master_audio_config'] = ''
        master_audio_config_sel.set_value(my.sob.get('master_audio_config'))
        table2.add_cell(master_audio_config_sel)
         
        c1 = table2.add_cell('Run Time Calc:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('run_time_calc')
        tb1.add_attr('id','run_time_calc')
        tb1.set_value(my.sob['run_time_calc'])
        #Might want to add the : timestamp js here -- from qc reports
        table2.add_cell(tb1)
   
        table2.add_row()
        table2.add_cell(table2.hr())
        table2.add_row()

        c1 = table2.add_cell('Narrative:')
        c1.add_attr('nowrap','nowrap')
        narrative_sel = SelectWdg('narrative')
        narrative_sel.add_attr('id','narrative')
        narrative_sel.append_option('--Select--','')
        for n in my.narratives:
            narrative_sel.append_option(n,n)
        if my.sob.get('narrative') == None:
            my.sob['narrative'] = ''
        narrative_sel.set_value(my.sob.get('narrative'))
        table2.add_cell(narrative_sel)

        c1 = table2.add_cell('Texted/Textless:')
        c1.add_attr('nowrap','nowrap')
        tt_sel = SelectWdg('texted_textless')
        tt_sel.add_attr('id','texted_textless')
        tt_sel.append_option('--Select--','')
        for t in my.texted_textless:
            tt_sel.append_option(t,t)
        if my.sob.get('texted_textless') == None:
            my.sob['texted_textless'] = ''
        tt_sel.set_value(my.sob.get('texted_textless'))
        table2.add_cell(tt_sel)

        c1 = table2.add_cell('Aspect Ratio:')
        c1.add_attr('nowrap','nowrap')
        aspect_ratio_sel = SelectWdg('aspect_ratio')
        aspect_ratio_sel.add_attr('id','aspect_ratio')
        aspect_ratio_sel.append_option('--Select--','')
        for a in my.aspect_ratios:
            aspect_ratio_sel.append_option(a,a)
        if my.sob.get('aspect_ratio') == None:
            my.sob['aspect_ratio'] = ''
        aspect_ratio_sel.set_value(my.sob.get('aspect_ratio'))
        table2.add_cell(aspect_ratio_sel)

        c1 = table2.add_cell('Standard:')
        c1.add_attr('nowrap','nowrap')
        standard_sel = SelectWdg('standard')
        standard_sel.add_attr('id','standard')
        standard_sel.append_option('--Select--','')
        for s in my.standards:
            standard_sel.append_option(s,s)
        if my.sob.get('standard') == None:
            my.sob['standard'] = ''
        standard_sel.set_value(my.sob.get('standard'))
        table2.add_cell(standard_sel)

        table2.add_row()
        table2.add_cell(table2.hr())
        table2.add_row()

        c1 = table2.add_cell('HD:')
        c1.add_attr('nowrap','nowrap')
        hd_sel = SelectWdg('hd')
        hd_sel.add_attr('id','hd')
        hd_sel.append_option('--Select--','')
        for s in my.hd:
            hd_sel.append_option(s,s)
        if my.sob.get('hd') == None:
            my.sob['hd'] = ''
        hd_sel.set_value(my.sob.get('hd'))
        table2.add_cell(hd_sel)

#        c1 = table2.add_cell('Genre:')
#        c1.add_attr('nowrap','nowrap')
#        tb1 = TextWdg('genre')
#        tb1.add_attr('id','genre')
#        tb1.set_value(my.sob['genre'])
#        table2.add_cell(tb1)

        c1 = table2.add_cell('MPAA:')
        c1.add_attr('nowrap','nowrap')
        mpaa_sel = SelectWdg('mpaa')
        mpaa_sel.add_attr('id','mpaa')
        mpaa_sel.append_option('--Select--','')
        for s in my.mpaa:
            mpaa_sel.append_option(s,s)
        if my.sob.get('mpaa') == None:
            my.sob['mpaa'] = ''
        mpaa_sel.set_value(my.sob.get('mpaa'))
        table2.add_cell(mpaa_sel)

        c1 = table2.add_cell('MPAA Ratings:')
        c1.add_attr('nowrap','nowrap')
        mpaa_ratings_sel = SelectWdg('mpaa_ratings')
        mpaa_ratings_sel.add_attr('id','mpaa_ratings')
        mpaa_ratings_sel.append_option('--Select--','')
        for s in my.mpaa_ratings:
            mpaa_ratings_sel.append_option(s,s)
        if my.sob.get('mpaa_ratings') == None:
            my.sob['mpaa_ratings'] = ''
        mpaa_ratings_sel.set_value(my.sob.get('mpaa_ratings'))
        table2.add_cell(mpaa_ratings_sel)

        table2.add_row()
        table2.add_cell(table2.hr())
#        table2.add_row()
#
#        c1 = table2.add_cell('UK Ratings:')
#        c1.add_attr('nowrap','nowrap')
#        uk_ratings_sel = SelectWdg('uk_ratings')
#        uk_ratings_sel.add_attr('id','uk_ratings')
#        uk_ratings_sel.append_option('--Select--','')
#        for s in my.uk_ratings:
#            uk_ratings_sel.append_option(s,s)
#        if my.sob.get('uk_ratings') == None:
#            my.sob['uk_ratings'] = ''
#        uk_ratings_sel.set_value(my.sob.get('uk_ratings'))
#        table2.add_cell(uk_ratings_sel)
#
#        c1 = table2.add_cell('Australia Ratings:')
#        c1.add_attr('nowrap','nowrap')
#        australia_ratings_sel = SelectWdg('australia_ratings')
#        australia_ratings_sel.add_attr('id','australia_ratings')
#        australia_ratings_sel.append_option('--Select--','')
#        for s in my.australia_ratings:
#            australia_ratings_sel.append_option(s,s)
#        if my.sob.get('australia_ratings') == None:
#            my.sob['australia_ratings'] = ''
#        australia_ratings_sel.set_value(my.sob.get('australia_ratings'))
#        table2.add_cell(australia_ratings_sel)
#
#        c1 = table2.add_cell('Germany Ratings:')
#        c1.add_attr('nowrap','nowrap')
#        germany_ratings_sel = SelectWdg('germany_ratings')
#        germany_ratings_sel.add_attr('id','germany_ratings')
#        germany_ratings_sel.append_option('--Select--','')
#        for s in my.germany_ratings:
#            germany_ratings_sel.append_option(s,s)
#        if my.sob.get('germany_ratings') == None:
#            my.sob['germany_ratings'] = ''
#        germany_ratings_sel.set_value(my.sob.get('germany_ratings'))
#        table2.add_cell(germany_ratings_sel)
#
#        table2.add_row()
#        table2.add_cell(table2.hr())
        table2.add_row()

        c1 = table2.add_cell('Legal Rights:')
        c1.add_attr('nowrap','nowrap')
        legal_rights_sel = SelectWdg('legal_right')
        legal_rights_sel.add_attr('id','legal_right')
        legal_rights_sel.append_option('--Select--','')
        for s in my.legal_rights:
            legal_rights_sel.append_option(s,s)
        if my.sob.get('legal_right') == None:
            my.sob['legal_right'] = ''
        legal_rights_sel.set_value(my.sob.get('legal_right'))
        table2.add_cell(legal_rights_sel)
        

        from tactic.ui.widget import CalendarInputWdg, ActionButtonWdg
        ld = table2.add_cell('Legal Date: ')
        ld.add_attr('nowrap','nowrap')
        legal_date = CalendarInputWdg("legal_date")
        if my.sob.get('legal_date') not in [None,'']:
            legal_date.set_option('default', my.fix_date(my.sob.get('legal_date')))
        legal_date.set_option('show_activator', True)
        legal_date.set_option('show_confirm', False)
        #legal_date.set_option('show_text', True)
        legal_date.set_option('show_today', False)
        #legal_date.set_option('read_only', False)    
        legal_date.add_attr('id','legal_date')
        table2.add_cell(legal_date)

        c1 = table2.add_cell('Legal Comment:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('legal_comment')
        tb1.add_attr('id','legal_comment')
        tb1.add_style('width','300px')
        tb1.set_value(my.sob['legal_comment'])
        c2 = table2.add_cell(tb1)
        c2.add_attr('colspan','3')

        table2.add_row()
        table2.add_cell(table2.hr())
        table2.add_row()

        c1 = table2.add_cell('HE Creative Comment:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('he_creative_comment')
        tb1.add_attr('id','he_creative_comment')
        tb1.add_style('width','300px')
        tb1.set_value(my.sob['he_creative_comment'])
        c2 = table2.add_cell(tb1)
        c2.add_attr('colspan','3')

        table2.add_row()
        table2.add_cell(table2.hr())
        table2.add_row()

        c1 = table2.add_cell('URL:')
        c1.add_attr('nowrap','nowrap')
        tb1 = TextWdg('url')
        tb1.add_attr('id','url')
        tb1.add_style('width','300px')
        tb1.set_value(my.sob['url'])
        c2 = table2.add_cell(tb1)
        c2.add_attr('colspan','3')

        table2.add_row()
        table2.add_cell(table2.hr())
        table2.add_row()
        
        #ta1 = table2.add_cell('Cast Info:')
        #table2.add_row() 
        #ta1 = table2.add_cell('<textarea cols="90" rows="10" class="spt_input" name="cast_info" id="cast_info">%s</textarea>' % my.sob.get('cast_info'))

        #table2.add_row()
        submit = table2.add_cell('<input type="button" value="Submit"/>')
        sk = ''
        if not my.is_insert:
            sk = my.sob.get('__search_key__')
        submit.add_behavior(my.get_submit(sk))
        if not my.is_insert:
            xml = table2.add_cell('<input type="button" value="Generate XML"/>')
            xml.add_behavior(my.get_xml(sk))

         


        table.add_cell(table2)
        widget.add(table)
        return widget
Example #11
0
    def get_display(my):
        top = my.top
        top.add_class("spt_script_editor_top")
        """
        top.add_class("SPT_CHANGE")
        top.add_behavior( {
            'type': 'load',
            'cbjs_action': '''
            register_change = function(bvr) {
                var change_top = bvr.src_el.getParent(".SPT_CHANGE"); 
                change_top.addClass("SPT_HAS_CHANGES");
                change_top.update_change(change_top, bvr);
            }

            has_changes = function(bvr) {
                var change_top = bvr.src_el.getParent(".SPT_CHANGE"); 
                return change_top.hasClass("SPT_HAS_CHANGES");
            }

            bvr.src_el.update_change = function(top, bvr) {
                change_el = top.getElement(".spt_change_element");
                change_el.setStyle("display", "");
            }
            '''
        } )
        """

        change_div = DivWdg()
        top.add(change_div)
        #change_div.add("CHANGES!!!")
        change_div.add_style("display: none")
        change_div.add_class("spt_change_element")

        top.add_class("spt_panel")
        top.add_class("spt_js_editor")
        top.add_attr("spt_class_name", Common.get_full_class_name(my))
        top.add_color("background", "background")
        top.add_style("padding", "10px")

        div = DivWdg()
        top.add(div)

        # if script_path
        script_path = my.kwargs.get("script_path")
        search_key = my.kwargs.get("search_key")
        if script_path:
            search = Search("config/custom_script")
            dirname = os.path.dirname(script_path)
            basename = os.path.basename(script_path)

            search.add_filter("folder", dirname)
            search.add_filter("title", basename)
            script_sobj = search.get_sobject()
        elif search_key:
            script_sobj = Search.get_by_search_key(search_key)
        else:
            script_sobj = None

        if script_sobj:
            script_code = script_sobj.get_value("code")
            script_folder = script_sobj.get_value("folder")
            script_name = script_sobj.get_value("title")
            script_value = script_sobj.get_value("script")
            script_language = script_sobj.get_value("langauge")
        else:
            script_code = ''
            script_folder = ''
            script_name = ''
            script_value = ''

        editor = AceEditorWdg(custom_script=script_sobj)
        my.editor_id = editor.get_editor_id()

        if not Container.get_dict("JSLibraries", "spt_script_editor"):
            div.add_behavior({
                'type': 'load',
                'cbjs_action': my.get_onload_js()
            })

        # create the insert button
        help_button_wdg = DivWdg()
        div.add(help_button_wdg)
        help_button_wdg.add_style("float: right")
        help_button = ActionButtonWdg(title="?",
                                      tip="Script Editor Help",
                                      size='s')
        help_button_wdg.add(help_button)

        help_button.add_behavior({
            'type':
            'click_up',
            'cbjs_action':
            '''spt.help.load_alias("tactic-script-editor")'''
        })

        # create the insert button
        add_button_wdg = DivWdg()
        add_button_wdg.add_style("float: right")
        add_button = ActionButtonWdg(title="Manage")
        add_button.add_behavior({
            'type': 'click_up',
            'cbfn_action': 'spt.popup.get_widget',
            'options': {
                'class_name': 'tactic.ui.panel.ViewPanelWdg',
                'title': 'Manage: [%s]' % my.search_type
            },
            'args': {
                'search_type': my.search_type,
                'view': 'table'
            },
        })

        add_button_wdg.add(add_button)
        div.add(add_button_wdg)

        button_div = editor.get_buttons_wdg()
        div.add(button_div)
        """
        button_div = DivWdg()
        #div.add(button_div)

        button_div.add_style("text-align: left")

        button = ActionButtonWdg(title="Run")
        button.add_style("float: left")
        button.add_style("margin: 0 10 3")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            //var editor = $('shelf_script');
            var value = editAreaLoader.getValue('shelf_script')
            eval( value )
            '''
        } )
        button_div.add(button)


        button = ActionButtonWdg(title="Save")
        button.add_style("float: left")
        button.add_style("margin: 0 10 3")
        #button = ProdIconButtonWdg("Save")
        #button.add_style("margin: 5 10")
        behavior = {
            'type': 'click_up',
            'cbfn_action': 'spt.script_editor.save_script_cbk'
        }
        button.add_behavior(behavior)
        button_div.add(button)


        button = ActionButtonWdg(title="Clear")
        button.add_style("float: left")
        button.add_style("margin: 0 10 3")
        #button = ProdIconButtonWdg("Clear")
        #button.add_style("margin: 5 10")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.api.Utility.clear_inputs( bvr.src_el.getParent('.spt_js_editor') );
            editAreaLoader.setValue('shelf_script', '');

            '''
        } )

        button_div.add(button)
        """

        div.add(HtmlElement.br(clear='all'))

        div.add(HtmlElement.hr())

        save_wdg = DivWdg()
        save_wdg.add_style("padding: 2px 5px 6px 5px")
        save_wdg.add_color("background", "background", -5)

        # script code
        save_span = SpanWdg()
        save_span.add("<b>Code: </b>")
        save_wdg.add(save_span)
        save_text = TextWdg("shelf_code")
        save_text.set_value(script_code)
        save_text.add_attr("readonly", "true")
        save_text.set_id("shelf_code")
        save_text.add_class("spt_code")
        save_wdg.add(save_text)

        save_wdg.add("&nbsp;&nbsp;")

        # script name (path??)
        save_span = SpanWdg()
        save_span.add("<b>Script Path: </b>")
        save_wdg.add(save_span)
        save_text = TextWdg("shelf_folder")
        save_text.add_attr("size", "40")
        save_text.set_id("shelf_folder")
        save_text.add_class("spt_folder")
        save_text.set_value(script_folder)
        save_wdg.add(save_text)
        save_wdg.add(" / ")
        save_text = TextWdg("shelf_title")
        save_text.add_attr("size", "40")
        save_text.set_id("shelf_title")
        save_text.add_class("spt_title")
        save_text.set_value(script_name)
        save_wdg.add(save_text)
        div.add(save_wdg)

        from tactic.ui.container import ResizableTableWdg
        table = ResizableTableWdg()
        table.add_row()

        td = table.add_cell(resize=False)
        td.add_style("vertical-align: top")

        td.add(editor)

        text = TextAreaWdg("shelf_script")

        #text.add_behavior( {
        #    'type': 'double_click',
        #    'cbjs_action': '''
        #    var text = $('shelf_script');
        #    editor(text)
        #    '''
        #    } )
        """
        text.set_id("shelf_script")
        text.add_style("width: 550px")
        text.add_style("height: 300px")
        text.add_class("codepress")
        text.add_class("html")
        text.add_behavior( {
        'type': 'load',
        'cbjs_action': '''
            editAreaLoader.init({
                id: "shelf_script", // id of the textarea to transform      
                start_highlight: true,  // if start with highlight
                allow_resize: "both",
                allow_toggle: true,
                word_wrap: true,
                language: "en",
                syntax: "js",   // need to make this setable
                replace_tab_by_spaces: "4",
                font_size: "8",
                toolbar: "search, go_to_line, fullscreen, |, undo, redo, |, select_font, |, syntax_selection, |, highlight",
                syntax_selection_allow: "js,python"

        });

        '''
        } )

        text.add_style("margin-top: 5px")
        text.add_style("font-family: courier new")
        text.add_style("font-size: 11px")
        text.set_id("shelf_script")
        #text.add_attr("cols", "80")
        #text.add_attr("rows", "20")
        text.add_style("min-height", "400px")
        text.add_style("height", "400px")
        text.add_style("width", "600px")
        text.set_value(script_value)

        td.add(text)
        """

        td = table.add_cell()
        td.add_style('vertical-align: top')
        td.add(my.get_script_wdg())

        table.add_row(resize=False)

        div.add(table)

        if my.kwargs.get("is_refresh"):
            return div
        else:
            return top
Example #12
0
    def get_display(my):   
        widget = DivWdg()
        widget.add_attr('id','whole_fb_container_%s' % my.custom_top_name)
        if 'dir' in my.kwargs.keys():
            my.dir = my.kwargs.get('dir')
        if 'old_dir' in my.kwargs.keys():
            my.old_dir = my.kwargs.get('old_dir')
        else:
            my.old_dir = my.dir
        if 'mode' in my.kwargs.keys():
            my.mode = my.kwargs.get('mode')
            if my.mode in [None,'']:
                my.mode = 'classic'
        #print "DIR = %s, OLD DIR = %s" % (my.dir, my.old_dir)
        
        err_msg = ''
        if not os.path.isdir(my.dir):
            err_msg = '%s is not a valid directory' % my.dir 
            my.dir = my.old_dir
       
        trimmed_dir = my.dir
        if trimmed_dir[len(trimmed_dir) - 1] == '/' and len(trimmed_dir) > 1:
            trimmed_dir = trimmed_dir[:-1]
        
        prev_dir_s = trimmed_dir.split('/')
        prev_dir_s = prev_dir_s[:-1]
        prev_dir = ''
        
        for ct in range(0,len(prev_dir_s)):
            if prev_dir_s[ct] not in [None,'']:
                if prev_dir == '':
                    prev_dir = '/%s' % prev_dir_s[ct]
                else:   
                    prev_dir = '%s/%s' % (prev_dir, prev_dir_s[ct])
        if prev_dir in [None,'','//']:
            prev_dir = '/'
        #print "PREV DIR = %s" % prev_dir
        
        files_list = []
        dir_list = []
        
        files_dict = {}
        dirs_dict = {}
        
        longest_name_len = 0
        
        for f in os.listdir(my.dir):
            joined = join(my.dir,f)
            if os.path.isfile(joined):
                files_list.append(joined)
                last_modified = 'N/A'
                created = 'N/A'
                size = 'N/A'
                if joined.count('/') > 3:
                    last_modified =  datetime.fromtimestamp(os.path.getmtime(joined)).strftime('%Y-%m-%d %H:%M:%S')
                    created =  datetime.fromtimestamp(os.path.getctime(joined)).strftime('%Y-%m-%d %H:%M:%S')
                    size = my.convertSize(os.path.getsize(joined),'file')
                file_name_s = joined.split('/')
                file_name = file_name_s[len(file_name_s) - 1]
                file_path = joined
                files_dict[joined] = {'last_modified': last_modified, 'created': created, 'size': size, 'name': file_name, 'path': joined}
                if len(file_name) > longest_name_len:
                    longest_name_len = len(file_name)
            
            elif os.path.isdir(joined):
                dir_name_s = joined.split('/')
                dir_name = dir_name_s[len(dir_name_s) - 1]
                if dir_name[0] != '.':
                    dir_list.append(joined)
                    size = 'N/A'
                    created = 'N/A'
                    last_modified = 'N/A'
                   
                    #This is to keep us from calculating the size of the huge base directories
                    #Probably want a way to turn directory sizes on and off
                    if joined.count('/') > 5:
                        last_modified =  datetime.fromtimestamp(os.path.getmtime(joined)).strftime('%Y-%m-%d %H:%M:%S')
                        created =  datetime.fromtimestamp(os.path.getctime(joined)).strftime('%Y-%m-%d %H:%M:%S')
                        prepresize = commands.getoutput('du -s %s' % joined).split()[0]
                        try:
                            presize = float(prepresize)
                            if not math.isnan(presize):
                                size = my.convertSize(float(presize),'dir')
                        except ValueError:
                            print "GOT AN ERROR FOR %s" % joined
                            pass
                    dir_path = joined
                    dirs_dict[joined] = {'size': size, 'created': created, 'last_modified': last_modified, 'name': dir_name, 'path' : dir_path}
                    if len(dir_name) > longest_name_len:
                        longest_name_len = len(dir_name)
        
        #print "LONGEST NAME LEN = %s" % longest_name_len
        name_len = longest_name_len * 10
        
        # Displaying the table of the folders and files 
        top_tbl = Table()
        if err_msg != '':
            top_tbl.add_row()
            top_tbl.add_cell('<b><font color="#FF0000">%s</font></b>' % err_msg)
        top_tbl.add_row()
        dir_path_txt = TextWdg('dir_path')
        dir_path_txt.add_attr('id','dir_path')
        dir_path_txt.set_value(my.dir)
        dir_path_txt.set_option('size','100')
        dir_path_txt.add_behavior(my.change_location(my.old_dir))
        top_tbl.add_cell('Location: ')
        top_tbl.add_cell(dir_path_txt)
        
        div = DivWdg()
        
        back_tbl = Table()
        back_dir = back_tbl.add_cell("<-Back...")
        back_dir.add_attr('dir',prev_dir)
        back_dir.add_style('cursor: pointer;')
        back_dir.add_style('width: %spx;' % name_len)
        back_dir.add_behavior(my.dir_click())
        back_size = back_tbl.add_cell('Size')
        back_size.add_style('width: 100px;')
        back_created = back_tbl.add_cell('Created')
        back_created.add_style('width: 150px;')
        back_modified = back_tbl.add_cell('Last Modified')
        back_modified.add_style('width: 150px;')
        div.add(back_tbl)
    
        content_counter = 0
        dir_list.sort()
        files_list.sort()
        mult_dirs = DivWdg()
        mult_dirs.add_attr('class','DragContainer')
        mult_dirs.add_attr('id','DragContainer1')

        # Getting all the directories displayed, adding drag and drop attributes to each folder 
        for dr in dir_list:
         
            tbl = Table()
            tbl.add_row()
            dir_name = dirs_dict[dr]['name']
            dir_path = dirs_dict[dr]['path']
            FOLDER_ICON = my.folder_icon.replace("TITLE",dir_name)
            lil_tbl = Table()
            lil_tbl.add_row()
            lil_tbl.add_cell(FOLDER_ICON)
            
            directory_div = lil_tbl.add_cell('<b>%s</b>' % dir_name)
            
            if my.mode not in ['select']:
                directory_div.add_behavior(my.drag_controller())
                directory_div.add_style("-khtml-user-drag: element;")
                directory_div.add_attr("draggable", "true")
                directory_div.add_attr("ondragstart", "spt.drag.ondragstart(event, this, {path_name : '%s'}) "% dir_path)
                directory_div.add_attr("ondragover", "spt.drag.allowDrop(event, this)")
                directory_div.add_attr("ondrop", "spt.drag.ondrop(event, this, {destination_location: '%s'})" % dir_path)

            lil_cell = tbl.add_cell(lil_tbl)
            lil_cell.add_attr('name','clickable')
            lil_cell.add_attr('dir',dr)
            lil_cell.add_attr('type','dir')
            lil_cell.add_attr('path_name',dr)
            lil_cell.add_attr('highlight','off')
            #lil_cell.add_attr('class','biotches')
            lil_cell.add_style('cursor: pointer;')
            lil_cell.add_style('width: %spx;' % name_len)
            lil_cell.add_behavior(my.dir_click())
            lil_cell.add_behavior(my.highlighter_ctrl());
            lil_cell.add_behavior(my.hover_highlighter());
            if my.mode in ['select']:
                lil_cell.add_behavior(my.select_fp(my.custom_top_name))
            
            sc = tbl.add_cell('<i>%s</i>' % dirs_dict[dr]['size'])
            sc.add_attr('nowrap','nowrap')
            sc.add_attr('title','Size of Contents')
            sc.add_attr('name','Size of Contents')
            sc.add_style('width: 100px;')
           
            cc = tbl.add_cell(dirs_dict[dr]['created'])
            cc.add_attr('nowrap','nowrap')
            cc.add_attr('title','Created')
            cc.add_attr('name','Created')
            cc.add_style('width: 150px;')
         
            mc = tbl.add_cell(dirs_dict[dr]['last_modified'])
            mc.add_attr('nowrap','nowrap')
            mc.add_attr('title','Last Modified')
            mc.add_attr('name','Last Modified')
            mc.add_style('width: 150px;')
            div_dir = DivWdg()
            div_dir.add(tbl)
            mult_dirs.add(div_dir)
            content_counter = content_counter + 1
        div.add(mult_dirs)
        mult_files = DivWdg()
        mult_files.add_attr('class','DragContainer')
        mult_files.add_attr('id','DragContainer2')
        
        for fl in files_list:
            tbl = Table()
            tbl.add_row()

            file_name = files_dict[fl]['name']
            path_name = files_dict[fl]['path']

            text_wdg_file_name = DivWdg(file_name)
            if my.mode not in ['select']:
                text_wdg_file_name.add_behavior(my.drag_controller())
                text_wdg_file_name.add_style("-khtml-user-drag: element;")
                text_wdg_file_name.add_attr("draggable", "true")
                text_wdg_file_name.add_attr("ondragstart", "spt.drag.ondragstart(event, this, {path_name : '%s'}) "% path_name)
            
            FILE_ICON = my.file_icon.replace("TITLE",file_name)
            lil_tbl = Table()
            lil_tbl.add_row()
            lil_tbl.add_cell(FILE_ICON)
            file_div = lil_tbl.add_cell(text_wdg_file_name)
            lil_cell = tbl.add_cell(lil_tbl)
            lil_cell.add_attr('name','clickable')
            lil_cell.add_attr('file',fl)
            lil_cell.add_attr('type','file')
            lil_cell.add_attr('file_name',file_name)
            lil_cell.add_attr('path_name',path_name)
            lil_cell.add_attr('highlight','off')
            #lil_cell.add_attr('class','biotches')
            lil_cell.add_style('cursor: pointer;')
            lil_cell.add_style('width: %spx;' % name_len)
            lil_cell.add_behavior(my.highlighter_ctrl())
            lil_cell.add_behavior(my.hover_highlighter());
            if my.mode in ['select']:
                lil_cell.add_behavior(my.select_fp(my.custom_top_name))
            else:
                lil_cell.add_behavior(my.select_fp(my.custom_top_name))
             
            sc = tbl.add_cell('<i>%s</i>' % files_dict[fl]['size'])
            sc.add_attr('nowrap','nowrap')
            sc.add_attr('title','Size')
            sc.add_attr('name','Size')
            sc.add_style('width: 100px;')
            cc = tbl.add_cell(files_dict[fl]['created'])
            cc.add_attr('nowrap','nowrap')
            cc.add_attr('title','Created')
            cc.add_attr('name','Created')
            cc.add_style('width: 150px;')
            mc = tbl.add_cell(files_dict[fl]['last_modified'])
            mc.add_attr('nowrap','nowrap')
            mc.add_attr('title','Last Modified')
            mc.add_attr('name','Last Modified')
            mc.add_style('width: 150px;')
            div_fl = DivWdg()
            div_fl.add(tbl)
            mult_files.add(div_fl)
            content_counter = content_counter + 1
        div.add(mult_files)
        widget.add(top_tbl)
        widget.add(div)
        widget.add_behavior(my.click_anywhere())
        return widget 
Example #13
0
    def get_display(my):
        top = DivWdg()

        element_name = my.kwargs.get('element_name')

        config_view = my.kwargs.get("config_view")
        display_class = config_view.get_display_handler(element_name)
        display_options = config_view.get_display_options(element_name)
        element_attr = config_view.get_element_attributes(element_name)

        name = element_attr.get('name')
        edit = element_attr.get('edit')
        title = element_attr.get('title')
        width = element_attr.get('width')


        # add the name
        from pyasm.web import Table
        table = Table()
        top.add(table)

        table.add_row()
        td = table.add_cell("Name: ")
        td.add_style("padding: 5px")
        name_text = SpanWdg(name)
        name_text.add_style('font-weight: bold')
        name_text.add_attr("size", "50")
        table.add_cell(name_text)


        table.add_row_cell("<br/>Element Attributes:<br/>")

        # add the title
        table.add_row()
        td = table.add_cell("Title: ")
        td.add_style("padding: 5px")
        title_text = TextWdg("title")
        title_text.add_attr("size", "50")
        if title:
            title_text.set_value(title)
        table.add_cell(title_text)



        # add the width
        table.add_row()
        td = table.add_cell("Width: ")
        td.add_style("padding: 5px")
        width_text = TextWdg("width")
        if width:
            width_text.set_value(width)
        width_text.add_attr("size", "50")
        table.add_cell(width_text)

        # add the editable
        table.add_row()
        td = table.add_cell("Editable: ")
        td.add_style("padding: 5px")
        editable_text = CheckboxWdg("editable")
        editable_text.add_attr("size", "50")
        table.add_cell(editable_text)




        table.add_row_cell("<br/>Display:<br/>")

        # add the widget
        table.add_row()
        td = table.add_cell("Widget: ")
        td.add_style("padding: 5px")
        widget_select = SelectWdg("widget")
        options = ['Expression']
        widget_select.set_option("values", options)
        widget_select.add_empty_option("-- Select --")
        #widget_select.set_value(display_class)
        table.add_cell(widget_select)

        table.add_row_cell("&nbsp;&nbsp;&nbsp;&nbsp;- or -")

        # add the class
        table.add_row()
        td = table.add_cell("Class Name: ")
        td.add_style("padding: 5px")
        class_text = TextWdg("class_name")
        class_text.set_value(display_class)
        class_text.add_attr("size", "50")
        table.add_cell(class_text)


        # introspect the widget
        if not display_class:
            display_class = "pyasm.widget.SimpleTableElementWdg"
        #display_class = "tactic.ui.panel.ViewPanelWdg"

        from pyasm.common import Common
        import_stmt = Common.get_import_from_class_path(display_class)
        if import_stmt:
            exec(import_stmt)
        else:
            exec("from pyasm.widget import %s" % display_class)
        try:
            options = eval("%s.get_args_options()" % display_class)
        except AttributeError:
            try:
                info = eval("%s.get_args_keys()" % display_class)
            except AttributeError:
                return top
                
            options = []
            for key, description in info.items():
                option = {
                    'name': key,
                    'type': 'TextWdg',
                    'description': description
                }
                options.append(option)


        '''
        options = [
        {
            'name': 'expression',
            'type': 'TextWdg',
            'size': '50'
        },
        ]
        '''

        if options:
            top.add("<br/>Widget Options:<br/>")

        table = Table()
        top.add(table)

        for option in options:
            table.add_row()

            name = option.get('name') 
            title = name
            type = option.get('type')

            td = table.add_cell( "%s: " % title )
            td.add_style("padding: 5px")

            value = display_options.get(name)

            if type == 'SelectWdg':
                edit_wdg = SelectWdg("%s|value" % name)
                edit_wdg.add_style("width: 250px")
                edit_wdg.add_empty_option('-- Select --')
                values = option.get('values')
                edit_wdg.set_option('values', values)
                if value:
                    edit_wdg.set_value(value)
            elif type == 'TextAreaWdg':
                edit_wdg = TextAreaWdg("%s|value" % name)
                if value:
                    edit_wdg.set_value(value)
                edit_wdg.add_attr("cols", "60")
                edit_wdg.add_attr("rows", "3")
            else:
                edit_wdg = TextWdg("%s|value" % name)
                if value:
                    edit_wdg.set_value(value)
                edit_wdg.add_style("width: 250px")

            table.add_cell(edit_wdg)

        return top
Example #14
0
    def handle_widget_mode(self, custom_table, mode):

        tbody = custom_table.add_tbody()
        tbody.add_class("spt_custom_widget")
        if mode != 'widget':
            tbody.add_style('display: none')

        # add the name
        name_text = TextWdg("custom_name")
        name_text.add_class("spt_input")
        custom_table.add_row()
        custom_table.add_cell("Name: ")
        custom_table.add_cell(name_text)

        # add title
        custom_table.add_row()
        title_wdg = TextWdg("custom_title")
        title_wdg.add_attr("size", "50")
        custom_table.add_cell("Title: ")
        custom_table.add_cell(title_wdg)

        # add description
        custom_table.add_row()
        description_wdg = TextAreaWdg("custom_description")
        custom_table.add_cell("Description: ")
        custom_table.add_cell(description_wdg)

        # add widget class
        custom_table.add_row()
        class_wdg = TextWdg("custom_class")
        class_wdg.add_attr("size", "50")
        custom_table.add_cell("Widget Class: ")
        custom_table.add_cell(class_wdg)

        # add options
        custom_table.add_row()
        td = custom_table.add_cell()
        td.add("Options")
        td = custom_table.add_cell()

        div = DivWdg()
        div.set_id("another_list_options")
        div.add_style("display: block")
        div.add_style("margin-top: 10px")
        # TODO: this class should not be in prod!!
        from pyasm.prod.web import SearchTypeSelectWdg

        div.add("Name: ")
        option_name_text = TextWdg("option_name")
        div.add(option_name_text)

        div.add(" &nbsp; ")

        div.add("Value: ")
        option_value_text = TextWdg("option_value")
        div.add(option_value_text)

        td.add(div)
        td.add(div)
        td.add(div)

        custom_table.close_tbody()
Example #15
0
    def handle_widget_mode(my, custom_table, mode):

        tbody = custom_table.add_tbody()
        tbody.add_class("spt_custom_widget")
        if mode != 'widget':
            tbody.add_style('display: none')

        # add the name
        name_text = TextWdg("custom_name")
        name_text.add_class("spt_input")
        custom_table.add_row()
        custom_table.add_cell("Name: ")
        custom_table.add_cell(name_text)

        # add title
        custom_table.add_row()
        title_wdg = TextWdg("custom_title")
        title_wdg.add_attr("size", "50")
        custom_table.add_cell( "Title: " )
        custom_table.add_cell( title_wdg )

        # add description
        custom_table.add_row()
        description_wdg = TextAreaWdg("custom_description")
        custom_table.add_cell( "Description: " )
        custom_table.add_cell( description_wdg )


        # add widget class
        custom_table.add_row()
        class_wdg = TextWdg("custom_class")
        class_wdg.add_attr("size", "50")
        custom_table.add_cell( "Widget Class: " )
        custom_table.add_cell( class_wdg )


        # add options
        custom_table.add_row()
        td = custom_table.add_cell()
        td.add("Options")
        td = custom_table.add_cell()

        div = DivWdg()
        div.set_id("another_list_options")
        div.add_style("display: block")
        div.add_style("margin-top: 10px")
        # TODO: this class should not be in prod!!
        from pyasm.prod.web import SearchTypeSelectWdg

        div.add("Name: ")
        option_name_text = TextWdg("option_name")
        div.add(option_name_text)

        div.add(" &nbsp; ")

        div.add("Value: ")
        option_value_text = TextWdg("option_value")
        div.add(option_value_text)

        td.add(div)
        td.add(div)
        td.add(div)

        custom_table.close_tbody()
    def get_display(my):

        top_wdg = DivWdg()
        top_wdg.add_style("color: black")
        top_wdg.add_style("width: 350px")
        top_wdg.add_style("margin-top: 10px")
        top_wdg.add_style("padding: 10px")
        top_wdg.add_border()
        title = DivWdg()
        title.add_style("color: black")
        title.add_style("margin-top: -22px")

        top_wdg.add(title)
        #if not my.name_string:
        #    title.add('No database column')
        #    return top_wdg

        title.add("Widget Definition")

        widget_types = {
            'foreign_key': 'tactic.ui.table.ForeignKeyElementWdg',
            'button': 'tactic.ui.table.ButtonElementWdg',
            'expression': 'tactic.ui.table.ExpressionElementWdg'
        }

        web = WebContainer.get_web()
        config_string = web.get_form_value("config_xml")
        if not config_string:
            config_string = '<config/>'
        xml = Xml()
        xml.read_string(config_string)

        #print "config_string: ", config_string

        # get values from the config file
        element_name = xml.get_value('element/@name')

        config = WidgetConfig.get(
            view='element',
            xml='<config><element>%s</element></config>' % config_string)
        display_options = config.get_display_options(element_name)

        title = xml.get_value('element/@title')
        display_handler = xml.get_value('element/display/@class')
        if not display_handler:
            display_handler = 'tactic.ui.panel.TypeTableElementWdg'

        widget_name = xml.get_value('element/display/@widget')
        if not widget_name:
            widget_name = 'custom'

        custom_table = Table()
        custom_table.add_style("color: black")
        top_wdg.add(custom_table)

        name_text = DivWdg()
        name_text.add_style("color: black")
        name_text.add(element_name)
        custom_table.add_row()
        custom_table.add_cell("Name: ")
        custom_table.add_cell(name_text)

        # add title
        custom_table.add_row()
        title_wdg = TextWdg("custom_title")
        title_wdg.set_value(title)
        title_wdg.add_attr("size", "50")
        custom_table.add_cell("Title: ")
        custom_table.add_cell(title_wdg)

        # add description
        #custom_table.add_row()
        #description_wdg = TextAreaWdg("custom_description")
        #td = custom_table.add_cell( "Description: " )
        #td.add_style("vertical-align: top")
        #custom_table.add_cell( description_wdg )

        type_select = SelectWdg("custom_type")
        #type_select.add_empty_option("-- Select --")

        type_select.set_option(
            "values",
            "string|integer|float|boolean|currency|date|foreign_key|link|list|button|custom"
        )
        type_select.set_option(
            "labels",
            "String(db)|Integer(db)|Float(db)|Boolean(db)|Currency(db)|Date(db)|Foreign Key|Link|List|Button|Custom"
        )
        type_select.set_value(widget_name)

        #type_select.set_option("values", "string|integer|float|boolean|currency|date|link|list|foreign_key|button|empty")
        #type_select.set_option("labels", "String|Integer|Float|Boolean|Currency|Date|Link|List|Foreign Key|Button|Empty")
        custom_table.add_row()
        td = custom_table.add_cell("Widget Type: ")
        td.add_style("vertical-align: top")
        td = custom_table.add_cell(type_select)
        type_select.add_event(
            "onchange", "spt.CustomProject.property_type_select_cbk(this)")

        td.add(HtmlElement.br())
        display_handler_text = TextWdg("display_handler")
        display_handler_text.add_attr("size", "50")
        display_handler_text.set_value(display_handler)
        td.add(display_handler_text)

        # extra info for foreign key
        custom_table.add_row()
        div = DivWdg()
        div.add_class("foreign_key_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")
        div.add("Options")
        div.add(HtmlElement.br())

        # extra info for foreign key
        custom_table.add_row()
        div = DivWdg()
        div.add_class("foreign_key_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")
        div.add("Options")
        div.add(HtmlElement.br())
        # TODO: this class should not be in prod!!
        from pyasm.prod.web import SearchTypeSelectWdg
        div.add("Relate to: ")
        search_type_select = SearchTypeSelectWdg(
            "foreign_key_search_select",
            mode=SearchTypeSelectWdg.CURRENT_PROJECT)
        div.add(search_type_select)
        td.add(div)

        # extra info for list
        custom_table.add_row()
        div = DivWdg()
        div.add_class("list_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")
        div.add("Options")
        div.add(HtmlElement.br())
        # TODO: this class should not be in prod!!
        from pyasm.prod.web import SearchTypeSelectWdg
        div.add("Values: ")
        search_type_text = TextWdg("list_values")
        div.add(search_type_text)
        td.add(div)

        # extra info for button
        custom_table.add_row()
        div = DivWdg()
        div.add_style("color: black")
        div.add_class("button_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")

        #class_path = "tactic.ui.table.ButtonElementWdg"
        class_path = display_handler
        button = Common.create_from_class_path(class_path)
        args_keys = button.get_args_keys()

        div.add("Options")
        div.add(HtmlElement.br())

        for key in args_keys.keys():
            option_name_text = HiddenWdg("option_name")
            option_name_text.set_value(key)
            div.add(option_name_text)

            div.add("%s: " % key)
            div.add(" &nbsp; &nbsp;")

            input = button.get_input_by_arg_key(key)

            value = display_options.get(key)
            if value:
                input.set_value(value)

            div.add(input)
            div.add(HtmlElement.br())
        td.add(div)

        # is searchable checkbox
        #custom_table.add_row()
        #current_searchable_wdg = CheckboxWdg("is_searchable")
        #current_view_wdg.set_checked()
        #custom_table.add_cell("Searchable? ")
        #td = custom_table.add_cell(current_searchable_wdg)

        custom_table.close_tbody()

        return top_wdg
Example #17
0
    def get_display(my):
        top = my.top
        top.add_class("spt_script_editor_top")

        """
        top.add_class("SPT_CHANGE")
        top.add_behavior( {
            'type': 'load',
            'cbjs_action': '''
            register_change = function(bvr) {
                var change_top = bvr.src_el.getParent(".SPT_CHANGE"); 
                change_top.addClass("SPT_HAS_CHANGES");
                change_top.update_change(change_top, bvr);
            }

            has_changes = function(bvr) {
                var change_top = bvr.src_el.getParent(".SPT_CHANGE"); 
                return change_top.hasClass("SPT_HAS_CHANGES");
            }

            bvr.src_el.update_change = function(top, bvr) {
                change_el = top.getElement(".spt_change_element");
                change_el.setStyle("display", "");
            }
            '''
        } )
        """

        change_div = DivWdg()
        top.add(change_div)
        #change_div.add("CHANGES!!!")
        change_div.add_style("display: none")
        change_div.add_class("spt_change_element");





        top.add_class("spt_panel")
        top.add_class("spt_js_editor")
        top.add_attr("spt_class_name", Common.get_full_class_name(my) )
        top.add_color("background", "background")
        top.add_style("padding", "10px")
       


        div = DivWdg()
        top.add(div)


        # if script_path
        script_path = my.kwargs.get("script_path")
        search_key = my.kwargs.get("search_key")
        if script_path:
            search = Search("config/custom_script")
            dirname = os.path.dirname(script_path)
            basename = os.path.basename(script_path)

            search.add_filter("folder", dirname)
            search.add_filter("title", basename)
            script_sobj = search.get_sobject()
        elif search_key:
            script_sobj = Search.get_by_search_key(search_key)
        else:
            script_sobj = None


        if script_sobj:
            script_code = script_sobj.get_value("code")
            script_folder = script_sobj.get_value("folder")
            script_name = script_sobj.get_value("title")
            script_value = script_sobj.get_value("script")
            script_language = script_sobj.get_value("langauge")
        else:
            script_code = ''
            script_folder = ''
            script_name = ''
            script_value = ''




        editor = AceEditorWdg(custom_script=script_sobj)
        my.editor_id = editor.get_editor_id()


        if not Container.get_dict("JSLibraries", "spt_script_editor"):
            div.add_behavior( {
                'type': 'load',
                'cbjs_action': my.get_onload_js()
            } )


        # create the insert button
        help_button_wdg = DivWdg()
        div.add(help_button_wdg)
        help_button_wdg.add_style("float: right")
        help_button = ActionButtonWdg(title="?", tip="Script Editor Help", size='s')
        help_button_wdg.add(help_button)

        help_button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''spt.help.load_alias("tactic-script-editor")'''
        } )


        # create the insert button
        add_button_wdg = DivWdg()
        add_button_wdg.add_style("float: right")
        add_button = ActionButtonWdg(title="Manage")
        add_button.add_behavior( {
            'type': 'click_up',
            'cbfn_action': 'spt.popup.get_widget',
            'options': {
                'class_name': 'tactic.ui.panel.ViewPanelWdg',
                'title': 'Manage: [%s]' % my.search_type
            },
            'args': {
                'search_type': my.search_type,
                'view': 'table'
            },
        } )
        
        add_button_wdg.add(add_button)
        div.add(add_button_wdg)


        button_div = editor.get_buttons_wdg()
        div.add(button_div)
            
        """
        button_div = DivWdg()
        #div.add(button_div)

        button_div.add_style("text-align: left")

        button = ActionButtonWdg(title="Run")
        button.add_style("float: left")
        button.add_style("margin: 0 10 3")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            //var editor = $('shelf_script');
            var value = editAreaLoader.getValue('shelf_script')
            eval( value )
            '''
        } )
        button_div.add(button)


        button = ActionButtonWdg(title="Save")
        button.add_style("float: left")
        button.add_style("margin: 0 10 3")
        #button = ProdIconButtonWdg("Save")
        #button.add_style("margin: 5 10")
        behavior = {
            'type': 'click_up',
            'cbfn_action': 'spt.script_editor.save_script_cbk'
        }
        button.add_behavior(behavior)
        button_div.add(button)


        button = ActionButtonWdg(title="Clear")
        button.add_style("float: left")
        button.add_style("margin: 0 10 3")
        #button = ProdIconButtonWdg("Clear")
        #button.add_style("margin: 5 10")
        button.add_behavior( {
            'type': 'click_up',
            'cbjs_action': '''
            spt.api.Utility.clear_inputs( bvr.src_el.getParent('.spt_js_editor') );
            editAreaLoader.setValue('shelf_script', '');

            '''
        } )

        button_div.add(button)
        """

        div.add( HtmlElement.br(clear='all') )

        div.add( HtmlElement.hr() )


        save_wdg = DivWdg()
        save_wdg.add_style("padding: 2px 5px 6px 5px")
        save_wdg.add_color("background", "background", -5)

        # script code
        save_span = SpanWdg()
        save_span.add("<b>Code: </b>")
        save_wdg.add(save_span)
        save_text = TextWdg("shelf_code")
        save_text.set_value(script_code)
        save_text.add_attr("readonly", "true")
        save_text.set_id("shelf_code")
        save_text.add_class("spt_code")
        save_wdg.add(save_text)

        save_wdg.add("&nbsp;&nbsp;")

        # script name (path??)
        save_span = SpanWdg()
        save_span.add("<b>Script Path: </b>")
        save_wdg.add(save_span)
        save_text = TextWdg("shelf_folder")
        save_text.add_attr("size", "40")
        save_text.set_id("shelf_folder")
        save_text.add_class("spt_folder")
        save_text.set_value(script_folder)
        save_wdg.add(save_text)
        save_wdg.add(" / ")
        save_text = TextWdg("shelf_title")
        save_text.add_attr("size", "40")
        save_text.set_id("shelf_title")
        save_text.add_class("spt_title")
        save_text.set_value(script_name)
        save_wdg.add(save_text)
        div.add(save_wdg)

        from tactic.ui.container import ResizableTableWdg
        table = ResizableTableWdg()
        table.add_row()

        td = table.add_cell(resize=False)
        td.add_style("vertical-align: top")

        td.add(editor)


        text = TextAreaWdg("shelf_script")

        #text.add_behavior( {
        #    'type': 'double_click',
        #    'cbjs_action': '''
        #    var text = $('shelf_script');
        #    editor(text)
        #    '''
        #    } )


        """
        text.set_id("shelf_script")
        text.add_style("width: 550px")
        text.add_style("height: 300px")
        text.add_class("codepress")
        text.add_class("html")
        text.add_behavior( {
        'type': 'load',
        'cbjs_action': '''
            editAreaLoader.init({
                id: "shelf_script", // id of the textarea to transform      
                start_highlight: true,  // if start with highlight
                allow_resize: "both",
                allow_toggle: true,
                word_wrap: true,
                language: "en",
                syntax: "js",   // need to make this setable
                replace_tab_by_spaces: "4",
                font_size: "8",
                toolbar: "search, go_to_line, fullscreen, |, undo, redo, |, select_font, |, syntax_selection, |, highlight",
                syntax_selection_allow: "js,python"

        });

        '''
        } )

        text.add_style("margin-top: 5px")
        text.add_style("font-family: courier new")
        text.add_style("font-size: 11px")
        text.set_id("shelf_script")
        #text.add_attr("cols", "80")
        #text.add_attr("rows", "20")
        text.add_style("min-height", "400px")
        text.add_style("height", "400px")
        text.add_style("width", "600px")
        text.set_value(script_value)

        td.add(text)
        """


        td = table.add_cell()
        td.add_style('vertical-align: top')
        td.add(my.get_script_wdg())


        table.add_row(resize=False)


        div.add(table)

        if my.kwargs.get("is_refresh"):
            return div
        else:
            return top
Example #18
0
    def get_display(self):
        top = DivWdg()

        element_name = self.kwargs.get('element_name')

        config_view = self.kwargs.get("config_view")
        display_class = config_view.get_display_handler(element_name)
        display_options = config_view.get_display_options(element_name)
        element_attr = config_view.get_element_attributes(element_name)

        name = element_attr.get('name')
        edit = element_attr.get('edit')
        title = element_attr.get('title')
        width = element_attr.get('width')

        # add the name
        from pyasm.web import Table
        table = Table()
        top.add(table)

        table.add_row()
        td = table.add_cell("Name: ")
        td.add_style("padding: 5px")
        name_text = SpanWdg(name)
        name_text.add_style('font-weight: bold')
        name_text.add_attr("size", "50")
        table.add_cell(name_text)

        table.add_row_cell("<br/>Element Attributes:<br/>")

        # add the title
        table.add_row()
        td = table.add_cell("Title: ")
        td.add_style("padding: 5px")
        title_text = TextWdg("title")
        title_text.add_attr("size", "50")
        if title:
            title_text.set_value(title)
        table.add_cell(title_text)

        # add the width
        table.add_row()
        td = table.add_cell("Width: ")
        td.add_style("padding: 5px")
        width_text = TextWdg("width")
        if width:
            width_text.set_value(width)
        width_text.add_attr("size", "50")
        table.add_cell(width_text)

        # add the editable
        table.add_row()
        td = table.add_cell("Editable: ")
        td.add_style("padding: 5px")
        editable_text = CheckboxWdg("editable")
        editable_text.add_attr("size", "50")
        table.add_cell(editable_text)

        table.add_row_cell("<br/>Display:<br/>")

        # add the widget
        table.add_row()
        td = table.add_cell("Widget: ")
        td.add_style("padding: 5px")
        widget_select = SelectWdg("widget")
        options = ['Expression']
        widget_select.set_option("values", options)
        widget_select.add_empty_option("-- Select --")
        #widget_select.set_value(display_class)
        table.add_cell(widget_select)

        table.add_row_cell("&nbsp;&nbsp;&nbsp;&nbsp;- or -")

        # add the class
        table.add_row()
        td = table.add_cell("Class Name: ")
        td.add_style("padding: 5px")
        class_text = TextWdg("class_name")
        class_text.set_value(display_class)
        class_text.add_attr("size", "50")
        table.add_cell(class_text)

        # introspect the widget
        if not display_class:
            display_class = "pyasm.widget.SimpleTableElementWdg"
        #display_class = "tactic.ui.panel.ViewPanelWdg"

        from pyasm.common import Common
        import_stmt = Common.get_import_from_class_path(display_class)
        if import_stmt:
            exec(import_stmt)
        else:
            exec("from pyasm.widget import %s" % display_class)
        try:
            options = eval("%s.get_args_options()" % display_class)
        except AttributeError:
            try:
                info = eval("%s.get_args_keys()" % display_class)
            except AttributeError:
                return top

            options = []
            for key, description in info.items():
                option = {
                    'name': key,
                    'type': 'TextWdg',
                    'description': description
                }
                options.append(option)
        '''
        options = [
        {
            'name': 'expression',
            'type': 'TextWdg',
            'size': '50'
        },
        ]
        '''

        if options:
            top.add("<br/>Widget Options:<br/>")

        table = Table()
        top.add(table)

        for option in options:
            table.add_row()

            name = option.get('name')
            title = name
            type = option.get('type')

            td = table.add_cell("%s: " % title)
            td.add_style("padding: 5px")

            value = display_options.get(name)

            if type == 'SelectWdg':
                edit_wdg = SelectWdg("%s|value" % name)
                edit_wdg.add_style("width: 250px")
                edit_wdg.add_empty_option('-- Select --')
                values = option.get('values')
                edit_wdg.set_option('values', values)
                if value:
                    edit_wdg.set_value(value)
            elif type == 'TextAreaWdg':
                edit_wdg = TextAreaWdg("%s|value" % name)
                if value:
                    edit_wdg.set_value(value)
                edit_wdg.add_attr("cols", "60")
                edit_wdg.add_attr("rows", "3")
            else:
                edit_wdg = TextWdg("%s|value" % name)
                if value:
                    edit_wdg.set_value(value)
                edit_wdg.add_style("width: 250px")

            table.add_cell(edit_wdg)

        return top
Example #19
0
    def get_display(my):
        my.sk = str(my.kwargs.get('sk'))
        my.code = my.sk.split('code=')[1]
        my.parent_sk = str(my.kwargs.get('parent_sk'))
        my.order_sk = str(my.kwargs.get('order_sk'))
        order_code = my.order_sk.split('code=')[1]
        my.parent_sid = str(my.kwargs.get('parent_sid'))
        if 'user' in my.kwargs.keys():
            my.user = my.kwargs.get('user')
        else:
            my.user = Environment.get_user_name()
        if 'groups_str' in my.kwargs.keys():
            my.groups_str = my.kwargs.get('groups_str')
        if my.groups_str in [None,'']:
            user_group_names = Environment.get_group_names()
            for mg in user_group_names:
                if my.groups_str == '':
                    my.groups_str = mg
                else:
                    my.groups_str = '%s,%s' % (my.groups_str, mg)

        user_is_scheduler = False
        if 'scheduling' in my.groups_str or 'onboarding' in my.groups_str:
            user_is_scheduler = True

        if 'display_mode' in my.kwargs.keys():
            my.disp_mode = str(my.kwargs.get('display_mode'))
        if my.disp_mode == 'Small':
            my.small = True
        if 'is_master' in my.kwargs.keys():
            my.is_master_str = my.kwargs.get('is_master')
            if my.is_master_str == 'true':
                my.is_master = True
        else:
            order_search = Search("twog/order")
            order_search.add_filter('code',order_code)
            order = order_search.get_sobject()
            order_classification = order.get_value('classification')
            if order_classification in ['master', 'Master']:
                my.is_master = True
                my.is_master_str = 'true'
        open_bottom = False
        if 'open_bottom' in my.kwargs.keys():
            ob_text = my.kwargs.get('open_bottom')
            if ob_text in [True, 'true', 't', '1', 1]:
                open_bottom = True

        main_obj = None
        if 'main_obj' in my.kwargs.keys():
            main_obj = my.kwargs.get('main_obj')
        else:
            main_search = Search("twog/proj")
            main_search.add_filter('code', my.code)
            main_obj = main_search.get_sobject()
        pipe_disp = main_obj.get_value('pipeline_code')
        if pipe_disp in [None, '', 'twog/proj', 'NOTHINGXsXNOTHING']:
            pipe_disp = "Not Assigned"
            tp_search = Search("twog/title")
            tp_search.add_filter('code', main_obj.get_value('title_code'))
            titl = tp_search.get_sobject()
            title_pipe = titl.get_value('pipeline_code')
            cp_search = Search("twog/client_pipes")
            cp_search.add_filter('process_name', main_obj.get_value('process'))
            cp_search.add_filter('pipeline_code', title_pipe)
            client_pipes = cp_search.get_sobjects()
            if len(client_pipes) > 0:
                client_pipe = client_pipes[0]
                my.server.update(main_obj.get_search_key(), {'pipeline_code': client_pipe.get_value('pipe_to_assign')})
                pipe_disp = client_pipe.get_value('pipe_to_assign')
        my.search_id = main_obj.get_value('id')
        due_date = ''
        task_search = Search("sthpw/task")
        task_search.add_filter('code', main_obj.get_value('task_code'))
        task = task_search.get_sobjects()
        task_sk = ''
        status = ''
        active_status = ''
        if len(task) > 0:
            due_date = task[0].get_value('bid_end_date')
            status = task[0].get_value('status')
            task_sk = task[0].get_search_key()
            active_bool = task[0].get_value('active')
            if active_bool in [True, 'true', 't', 1, '1']:
                active_status = '<font color="#0ff000">Active</font>'
            else:
                active_status = '<font color="#ff0000">Inactive</font>'
        wo_search = Search("twog/work_order")
        wo_search.add_filter('proj_code', my.code)
        wo_search.add_order_by('order_in_pipe')
        wos = wo_search.get_sobjects()
        table = Table()
        table.add_attr('class', 'ProjRow_%s' % my.code)
        table.add_attr('id', main_obj.get_value('code'))
        table.add_attr('cellpadding', '0')
        table.add_attr('cellspacing', '0')
        table.add_style('border-collapse', 'separate')
        table.add_style('border-spacing', '25px 0px')
        table.add_style('color: #1d216a;')
        table.add_style('background-color: %s;' % my.off_color)
        table.add_style('width', '100%')
        table.add_style('border-bottom-right-radius', '10px')
        table.add_style('border-bottom-left-radius', '10px')
        table.add_style('border-top-right-radius', '10px')
        table.add_style('border-top-left-radius', '10px')
        table.add_row()
        proj_cell = table.add_cell('<b><u>Project: %s</u></b>' % main_obj.get_value('process'))
        proj_cell.add_attr('nowrap','nowrap')
        proj_cell.add_style('cursor: pointer;')
        proj_cell.add_behavior(get_panel_change_behavior('twog/proj', my.code, my.sk, my.order_sk, my.title,
                                                         main_obj.get_value('proj_templ_code'),
                                                             'builder/refresh_from_save',
                                                         main_obj.get_value('task_code'),
                                                         my.parent_sk, main_obj.get_value('process'),
                                                         user_is_scheduler))
        stat_tbl = Table()
        stat_tbl.add_row()
        stat_cell = stat_tbl.add_cell('Status: %s' % status)
        stat_cell.add_attr('nowrap','nowrap')
        if status not in [None,'']:
            stat_cell.add_style('background-color: %s;' % my.stat_colors[status])
        s2 = stat_tbl.add_cell(' ')
        s2.add_attr('width', '100%')
        table.add_cell(stat_tbl)
        due_cell = table.add_cell('Due: %s' % fix_date(due_date).split(' ')[0])
        due_cell.add_attr('nowrap', 'nowrap')
        top_buttons = Table()
        top_buttons.add_row()
        if my.small:
            select_check = CustomCheckboxWdg(name='select_%s' % my.code, value_field=my.code, checked='false',
                                             dom_class='ob_selector', parent_table="ProjRow_%s" % my.code,
                                             normal_color=my.off_color, selected_color=my.on_color, code=my.code,
                                             ntype='proj', search_key=my.sk, task_sk=task_sk,
                                             additional_js=get_selected_color_behavior(my.code, 'ProjRow',
                                                                                       my.on_color, my.off_color))
            cb = top_buttons.add_cell(select_check)
        elif user_is_scheduler or 'onboarding' in my.groups_str:
            xb = top_buttons.add_cell(my.x_butt)
            xb.add_attr('align', 'right')
            xb.add_style('cursor: pointer;')
            xb.add_behavior(get_killer_behavior(my.sk, my.parent_sk, 'TitleRow', main_obj.get_value('process'),
                                                my.order_sk, my.is_master))
        long_cell1 = table.add_cell(top_buttons)
        long_cell1.add_attr('align', 'right')
        long_cell1.add_style('width', '100%')
        table.add_row()
        code_cell = table.add_cell('Code: %s' % my.code)
        active_cell = table.add_cell(active_status)
        active_cell.add_attr('align', 'right')
        active_cell.add_attr('colspan', '3')
        active_cell.add_style('width', '100%')
        table.add_row()

        title_fullname = main_obj.get_value('title')
        if main_obj.get_value('episode') not in [None,'']:
            title_fullname = '%s: %s' % (title_fullname, main_obj.get_value('episode'))

        pipe_cell = table.add_cell('Pipeline: %s&nbsp;&nbsp;&nbsp;&nbsp;Title: %s' % (pipe_disp, title_fullname))
        pipe_cell.add_attr('nowrap', 'nowrap')
        long_cell2 = table.add_cell('Priority: ')
        long_cell2.add_attr('align', 'right')
        long_cell2.add_style('width', '100%')
        prio_wdg = TextWdg('barcode_switcher')
        prio_wdg.add_attr('old_prio',main_obj.get_value('priority'))
        prio_wdg.set_value(main_obj.get_value('priority'))
        if user_is_scheduler:
            prio_wdg.add_behavior(get_alter_prio_behavior(main_obj.get_search_key()))
        else:
            prio_wdg.add_attr('disabled', 'disabled')
            prio_wdg.add_attr('readonly', 'readonly')
        long_cell21 = table.add_cell(prio_wdg)
        long_cell21.add_attr('align', 'left')
        long_cell21.add_style('width', '100%')
        if my.small:
            proj_cell.add_style('font-size: 8px;')
            stat_cell.add_style('font-size: 8px;')
            due_cell.add_style('font-size: 8px;')
            long_cell1.add_style('font-size: 8px;')
            code_cell.add_style('font-size: 8px;')
            pipe_cell.add_style('font-size: 8px;')
            long_cell2.add_style('font-size: 8px;')
            long_cell21.add_style('font-size: 8px;')
        else:
            bottom_buttons = Table()
            bottom_buttons.add_row()
            lynk = my.get_parent_context_file_link(my.parent_sid, main_obj.get_value('process'),
                                                   'twog/title?project=twog')
            bottom_buttons.add_cell(lynk)

            if not my.is_master:
                if main_obj.get_value('creation_type') == 'hackup': # and my.user in ['admin','philip.rowe']:
                    hack_edit = ButtonSmallNewWdg(title="Edit Connections", icon=CustomIconWdg.icons.get('HACKUP'))
                    hack_edit.add_behavior(get_edit_hackup_connections(my.code, main_obj.get_value('process')))
                    he = bottom_buttons.add_cell(hack_edit)
                    he.add_attr('align', 'right')
                    he.add_attr('valign', 'bottom')
                if user_is_scheduler:
                    adder = ButtonSmallNewWdg(title="Add A Work Order", icon=CustomIconWdg.icons.get('ADD'))
                    adder.add_behavior(get_multi_add_wos_behavior(my.sk, my.order_sk))
                    add = bottom_buttons.add_cell(adder)
                    add.add_attr('align', 'right')
                    priority = ButtonSmallNewWdg(title="Change Priority", icon=CustomIconWdg.icons.get('PRIORITY'))
                    priority.add_behavior(get_change_priority_behavior(main_obj.get_value('code'),
                                                                       main_obj.get_value('process'),
                                                                       my.order_sk,
                                                                       my.is_master_str))
                    prio = bottom_buttons.add_cell(priority)
                    prio.add_attr('align', 'right')
                    duedate = ButtonSmallNewWdg(title="Change Due Date", icon=CustomIconWdg.icons.get('CALENDAR'))
                    duedate.add_behavior(get_change_due_date_behavior(main_obj.get_value('code'),
                                                                      main_obj.get_value('process'),
                                                                      my.order_sk))
                    due = bottom_buttons.add_cell(duedate)
                    due.add_attr('align', 'right')

            upload = ButtonSmallNewWdg(title="Upload", icon=CustomIconWdg.icons.get('PUBLISH'))
            upload.add_behavior(get_upload_behavior(my.sk))
            up = bottom_buttons.add_cell(upload)
            up.add_attr('align', 'right')

            note_adder = ButtonSmallNewWdg(title="Add Note", icon=CustomIconWdg.icons.get('NOTE_ADD'))
            note_adder.add_behavior(get_launch_note_behavior(my.sk, main_obj.get_value('process')))
            nadd = bottom_buttons.add_cell(note_adder)
            nadd.add_attr('align', 'right')
            nadd.add_style('cursor: pointer;')

            if user_is_scheduler or 'onboarding' in my.groups_str:
                pipe_button = ButtonSmallNewWdg(title="Assign Pipeline", icon=CustomIconWdg.icons.get('PIPELINE'))
                pipe_button.add_behavior(get_scratch_pipe_behavior('twog/proj', my.search_id, my.parent_sid,
                                                                   my.width, my.height,
                                                                   main_obj.get_value('pipeline_code'),
                                                                   main_obj.get_search_key(), 'ProjRow',
                                                                   main_obj.get_value('process'), my.order_sk))
                scratch = bottom_buttons.add_cell(pipe_button)

            if my.is_master:
                if main_obj.get_value('templ_me') == True:
                    templ_icon = CustomIconWdg.icons.get('CHECK')
                else:
                    templ_icon = CustomIconWdg.icons.get('TEMPLATE')
                templ_button = ButtonSmallNewWdg(title="Template Me", icon=templ_icon)
                if main_obj.get_value('templ_me') == False:
                    templ_button.add_behavior(get_templ_proj_behavior(main_obj.get_value('templ_me'),
                                                                      main_obj.get_value('proj_templ_code'),
                                                                      main_obj.get_search_key(),
                                                                      my.order_sk))
                templ_butt = bottom_buttons.add_cell(templ_button)
                templ_butt.add_attr('class', 'templ_butt_%s' % my.sk)

            long_cell3 = table.add_cell(bottom_buttons)
            long_cell3.add_attr('align', 'right')
            long_cell3.add_attr('valign', 'bottom')
            long_cell3.add_style('width', '100%')
        bottom = Table()
        bottom.add_attr('width', '100%')
        bottom.add_attr('cellpadding', '0')
        bottom.add_attr('cellspacing', '0')
        for wo in wos:
            wo_sk = wo.get_search_key()
            wo_row = bottom.add_row()
            wo_row.add_attr('class', 'row_%s' % wo_sk)
            wo_obj = WorkOrderRow(sk=wo_sk, parent_sk=my.sk, order_sk=my.order_sk, parent_sid=my.search_id,
                                  groups_str=my.groups_str, user=my.user, display_mode=my.disp_mode,
                                  is_master=my.is_master_str, main_obj=wo, parent_obj=main_obj)
            wo_cell = bottom.add_cell(wo_obj)
            wo_cell.add_attr('width', '100%')
            wo_cell.add_attr('sk', wo_sk)
            wo_cell.add_attr('order_sk', my.order_sk)
            wo_cell.add_attr('parent_sk', my.sk)
            wo_cell.add_attr('parent_sid', my.search_id)
            wo_cell.add_attr('display_mode', my.disp_mode)
            wo_cell.add_attr('groups_str', my.groups_str)
            wo_cell.add_attr('user', my.user)
            wo_cell.add_attr('call_me', wo.get_value('process'))
            wo_cell.add_attr('my_class', 'WorkOrderRow')
            wo_cell.add_attr('class', 'cell_%s' % wo_sk)
        tab2ret = Table()
        top_row = tab2ret.add_row()
        top_row.add_attr('class', 'top_%s' % my.sk)
        tab2ret.add_attr('width', '100%')
        tab2ret.add_cell(table)
        bot_row = tab2ret.add_row()
        bot_row.add_attr('class', 'bot_%s' % my.sk)
        if not open_bottom:
            bot_row.add_style('display: none;')
        else:
            bot_row.add_style('display: table-row;')
        bot = tab2ret.add_cell(bottom)
        bot.add_style('padding-left: 40px;')

        return tab2ret
Example #20
0
    def handle_simple_mode(my, custom_table, mode):

        tbody = custom_table.add_tbody()
        tbody.add_class("spt_custom_simple")
        if mode != 'simple':
            tbody.add_style('display: none')


        name_text = TextWdg("custom_name")
        name_text.add_class("spt_input")
        tr = custom_table.add_row()
        tr.add_color("background", "background", -7)
        td = custom_table.add_cell("Name: ")
        td.add_style("min-width: 150px")
        custom_table.add_cell(name_text)


        # add title
        custom_table.add_row()
        title_wdg = TextWdg("custom_title")
        title_wdg.add_attr("size", "50")
        custom_table.add_cell( "Title: " )
        custom_table.add_cell( title_wdg )

        # add description
        tr = custom_table.add_row()
        tr.add_color("background", "background", -7)
        description_wdg = TextAreaWdg("custom_description")
        custom_table.add_cell( "Description: " )
        custom_table.add_cell( description_wdg )


        type_select = SelectWdg("custom_type")
        type_select.add_class("spt_input")
        #type_select.add_empty_option("-- Select --")
        type_select.set_option("values", "string|text|integer|float|boolean|currency|date|foreign_key|list|button|empty")
        type_select.set_option("labels", "String(db)|Text(db)|Integer(db)|Float(db)|Boolean(db)|Currency(db)|Date(db)|Foreign Key(db)|List(db)|Button|Empty")
        #type_select.set_option("labels", "String|Integer|Boolean|Currency|Timestamp|Link|Foreign Key|List|Checkbox|Text|Number|Date|Date Range")
        tr = custom_table.add_row()
        custom_table.add_cell("Property Type: ")
        td = custom_table.add_cell(type_select)
        type_select.add_event("onchange", "spt.custom_property_adder.property_type_select_cbk(this)")



        # extra info for foreign key
        custom_table.add_row()
        div = DivWdg()
        div.add_class("foreign_key_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")
        div.add("Options")
        div.add(HtmlElement.br())
        # TODO: this class should not be in prod!!
        from pyasm.prod.web import SearchTypeSelectWdg
        div.add("Relate to: ")
        search_type_select = SearchTypeSelectWdg("foreign_key_search_select", mode=SearchTypeSelectWdg.CURRENT_PROJECT)
        div.add(search_type_select)
        td.add(div)



        # extra info for list
        custom_table.add_row()
        div = DivWdg()
        div.add_class("list_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")
        div.add("Options")
        div.add(HtmlElement.br())
        # TODO: this class should not be in prod!!
        from pyasm.prod.web import SearchTypeSelectWdg
        div.add("Values: ")
        search_type_text = TextWdg("list_values")
        div.add(search_type_text)
        td.add(div)




        # extra info for button
        custom_table.add_row()
        div = DivWdg()
        div.add_class("button_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")

        class_path = "tactic.ui.table.ButtonElementWdg"
        button = Common.create_from_class_path(class_path)
        args_keys = button.get_args_keys()


        div.add("Options")
        div.add(HtmlElement.br())

        for key in args_keys.keys():
            div.add("Name: ")
            option_name_text = TextWdg("option_name")
            option_name_text.add_attr("readonly", "true")
            option_name_text.set_value(key)
            div.add(option_name_text)

            div.add(" &nbsp; ")

            div.add("Value: ")
            input = button.get_input_by_arg_key(key)
            div.add(input)

            #option_value_text = TextWdg("option_value")
            #div.add(option_value_text)
            div.add(HtmlElement.br())
        td.add(div)






        # is searchable checkbox
        tr = custom_table.add_row()
        tr.add_color("background", "background", -7)
        current_searchable_wdg = CheckboxWdg("is_searchable")
        #current_view_wdg.set_checked()
        custom_table.add_cell("Is Searchable? ")
        td = custom_table.add_cell(current_searchable_wdg)

        custom_table.close_tbody()
Example #21
0
 def txtbox(my, name, val, width='200px'):
     txt = TextWdg(name)
     txt.add_attr('id',name)
     txt.add_style('width: %s;' % width)
     txt.set_value(val)
     return txt
Example #22
0
    def get_display(my):
        widget = DivWdg()
        table = Table()
        table.add_attr('class', 'scraper')
        table.add_style('background-color: #FFFFFF;')
        table.add_style('height: 1000px;')
        table.add_row()
        tb = TextWdg('title_box')
        tb.add_attr('id', 'title_box')
        tb.add_attr('size', '45')
        multiple_titles = None
        searched_imdb = False
        orders = []

        # TODO: Remove hard-coded URL
        no_img = 'http://tactic.2gdigital.com/imdb_images/no_image.png'
        if 'code' in my.kwargs.keys() and my.title_of_show in [None, '']:
            server = TacticServerStub.get()
            this_order = server.eval("@SOBJECT(twog/order['code','%s'])" % my.kwargs.get('code'))[0]
            my.title_of_show = this_order.get('name')

        if my.title_of_show not in [None, '']:
            tb.set_value(my.title_of_show)
            if my.search_when_loaded:
                # poster_url_text = my.get_poster_url(my.title_of_show)
                # poster_url = poster_url_text.split('=')[1]
                server = TacticServerStub.get()
                orders = server.eval("@SOBJECT(twog/order['name','~','%s']['classification','not in','Master|Cancelled'])" % my.title_of_show)
                # order_s = Search("twog/order")
                # order_s.add_where("\"name\" like '%s%s%s'" %  ('%', my.title_of_show.lower(), '%'))
                # statement = order_s.get_statement()
                # print "STATEMENT = %s" % statement
                # orders = order_s.get_sobjects()
                # print "ORDER LEN = %s" % len(orders)
                if len(orders) > 0:
                    multiple_titles = get_multiple_title_info(my.title_of_show)
                    # print "MULTIPLE TITLES = %s" % multiple_titles
                    searched_imdb = True
        tb.add_behavior(my.get_search())
        top_tbl = Table()
        top_tbl.add_attr('width', '400px')
        top_tbl.add_attr('height', '50px')
        top_tbl.add_attr('cellpadding', '20')
        top_tbl.add_attr('cellspacing', '20')
        top_tbl.add_style('background-color: #417e97;')
        top_tbl.add_row()

        if len(orders) > 0:
            butt = top_tbl.add_cell('<input type="button" value="Associate All Selected"/>')
            butt.add_behavior(my.get_associate_em())

        sn = top_tbl.add_cell('<font color="#d9af1f"><b>Search Name:</b></font>&nbsp;&nbsp;&nbsp;&nbsp;')
        sn.add_attr('align', 'right')
        sn.add_attr('nowrap', 'nowrap')
        tb_cell1 = top_tbl.add_cell(tb)
        tb_cell = table.add_cell(top_tbl)
        tb_cell.add_attr('colspan', '2')
        tb_cell.add_attr('align', 'center')
        order_table = Table()
        order_table.add_attr('border', '1')
        order_table.add_attr('cellpadding', '10')
        order_table.add_row()

        if len(orders) > 0:
            toggler = CustomCheckboxWdg(name='chk_toggler', additional_js=my.get_toggler(), value_field='toggler',
                                        id='selection_toggler', checked='false', text='<b><- Select/Deselect ALL</b>',
                                        text_spot='right', text_align='left', nowrap='nowrap')
            order_table.add_cell(toggler)
            order_table.add_row()
            order_table.add_cell('Selector')
            order_table.add_cell('Poster')
            order_table.add_cell('Order Builder')
            order_table.add_cell('Code')
            order_table.add_cell('Name')
            order_table.add_cell('Client')
            order_table.add_cell('PO Number')
            order_table.add_cell('Classification')
            order_table.add_cell('Platform')
            order_table.add_cell('Due Date')
            order_table.add_cell('Completion Ratio')
            order_table.add_cell('Scheduler')
        elif my.title_of_show not in [None, ''] and my.search_when_loaded:
            description_box = order_table.add_cell('<b>No Tactic Orders Were Found With "%s" In The Name</b>' % my.title_of_show)
            description_box.add_style('font-size: 14px;')
        else:
            description_box = order_table.add_cell('<b>Please type the name of the show in the box above</b>')
            description_box.add_style('font-size: 14px;')
        for order in orders:
            checkbox = CustomCheckboxWdg(name='associate_order_%s' % order.get('code'),
                                         additional_js=my.highlight_order_row(order.get('code')),
                                         alert_name=order.get('name'),
                                         value_field=order.get('code'),
                                         checked='false',
                                         dom_class='associated_orders')
            imarow = order_table.add_row()
            imarow.add_attr('id', 'row_%s' % order.get('code'))
            chk = order_table.add_cell(checkbox)
            chk.add_attr('align', 'center')
            poster_cell = order_table.add_cell(OrderImageWdg(code=order.get('code')))
            poster_cell.add_attr('id', 'img_%s' % order.get('code'))
            ob = OrderBuilderLauncherWdg(code=order.get('code'))
            obc = order_table.add_cell(ob)
            obc.add_attr('align', 'center')
            order_table.add_cell(order.get('code'))
            order_table.add_cell(order.get('name'))
            order_table.add_cell(order.get('client_name'))
            order_table.add_cell(order.get('po_number'))
            order_table.add_cell(order.get('classification'))
            order_table.add_cell(order.get('platform'))
            order_table.add_cell(order.get('due_date'))
            order_table.add_cell('%s/%s' % (order.get('titles_completed'), order.get('titles_total')))
            order_table.add_cell(order.get('login'))
        imdb_table = Table()
        imdb_table.add_attr('border', '1')
        imdb_table.add_attr('cellpadding', '10')
        if multiple_titles not in [None, ''] and len(multiple_titles) > 0:
            mcount = 0
            seen_titles = []
            for m in multiple_titles:
                title_id = m['TopLevel']['title_id']
                if title_id not in seen_titles:
                    seen_titles.append(title_id)
                    imarow = imdb_table.add_row()
                    imarow.add_attr('id', 'row_%s' % m['TopLevel']['title_id'])
                    this_img = no_img

                    # TODO: Download the image and save in a temp folder
                    if m['TopLevel']['poster'] not in [None, '']:
                        this_img = m['TopLevel']['poster']
                        imdb_image_url = m['TopLevel']['poster']
                    checkbox = CustomCheckboxWdg(name='associate_imdb_%s' % m['TopLevel']['title_id'],
                                                 additional_js=my.act_like_radio(m['TopLevel']['title_id']),
                                                 alert_name=m['TopLevel']['title'],
                                                 value_field=m['TopLevel']['title_id'],
                                                 checked='false',
                                                 dom_class='associated_imdb',
                                                 extra1=m['TopLevel']['title_id'],
                                                 extra2=m['TopLevel']['title'],
                                                 extra3=m['TopLevel']['runtime'],
                                                 extra4=m['TopLevel']['release_date'],
                                                 extra5=m['TopLevel']['imdb_url'],
                                                 extra6=this_img)
                    chk = imdb_table.add_cell(checkbox)
                    chk.add_attr('align', 'center')
                    imdb_table.add_cell('<img src="%s"/>' % this_img)
                    info_tbl = Table()
                    info_tbl.add_row()
                    title_cell = info_tbl.add_cell('<b>Title: %s</b>' % m['TopLevel']['title'])
                    title_cell.add_style('cursor: pointer;')
                    title_cell.add_behavior(my.get_more_info(mcount))
                    info_tbl.add_row()
                    info_tbl.add_cell('<i>Original Title: %s</i>' % m['TopLevel']['original_title'])
                    info_tbl.add_row()
                    info_tbl.add_cell('<i>Run Time: %s</i>' % m['TopLevel']['runtime'])
                    info_tbl.add_row()
                    info_tbl.add_cell('<i>Release Date: %s</i>' % m['TopLevel']['release_date'])
                    info_tbl.add_row()
                    info_tbl.add_cell('<i>Rating: %s</i>' % m['TopLevel']['rating'])
                    info_tbl.add_row()
                    info_tbl.add_cell('<i>IMDb URL: %s</i>' % m['TopLevel']['imdb_url'])
                    info_tbl.add_row()
                    info_tbl.add_cell('<i>Plot: %s</i>' % m['TopLevel']['plot'])
                    info2 = Table()
                    mkeys = m.keys()
                    for k in mkeys: 
                        if k not in ['media_images', 'recommended_titles', 'videos', 'cinematographers', 'editors',
                                     'producers', 'cast', 'directors', 'writers', 'stars', 'plot_keywords', 'musicians',
                                     'TopLevel']:
                            info2.add_row()
                            info2.add_cell('<b><u>%s</u></b>' % k)
                            dudes = m[k]
                            dkeys = dudes.keys()
                            for d in dkeys:
                                info2.add_row()
                                info2.add_cell('%s: %s' % (d, dudes[d]))
                    intable = imdb_table.add_cell(info_tbl)
                    intable.add_attr('valign', 'top')
                    intable.add_attr('align', 'left')
                    # intable.add_behavior(my.get_hover_behavior(mcount))
                    hidrow = imdb_table.add_row()
                    hidrow.add_attr('hidden_id', mcount)
                    hidrow.add_attr('class', 'hidden_info')
                    hidrow.add_style('display: none;')
                    intable2 = imdb_table.add_cell(info2)
                    intable2.add_attr('valign', 'top')
                    intable2.add_attr('align', 'left')
                    mcount += 1
        elif my.title_of_show not in [None, ''] and searched_imdb:
            imdb_table.add_row()
            description_box = imdb_table.add_cell('<b>No IMDb Titles Were Found With "%s" In The Name</b>' % my.title_of_show)
            description_box.add_style('font-size: 14px;')
            imarow = imdb_table.add_row()
            imarow.add_attr('id', 'row_%s' % 'none')
            checkbox = CustomCheckboxWdg(name='associate_imdb_%s' % 'none', additional_js=my.act_like_radio('none'),
                                         alert_name='No IMDb Link', value_field='none', checked='false',
                                         dom_class='associated_imdb', extra1='none', extra2='No IMDb Link', extra3='',
                                         extra4='', extra5='none', extra6=no_img)
            chk = imdb_table.add_cell(checkbox)
            chk.add_attr('align', 'center')
            imdb_table.add_cell('<img src="%s"/>' % no_img)
            info_tbl = Table()
            info_tbl.add_row()
            title_cell = info_tbl.add_cell('<b>Title: %s</b>' % 'No IMDb Link')
            title_cell.add_style('cursor: pointer;')
            intable = imdb_table.add_cell(info_tbl)
            intable.add_attr('valign', 'top')
            intable.add_attr('align', 'left')
            hidrow = imdb_table.add_row()
            hidrow.add_attr('class', 'hidden_info')
            hidrow.add_style('display: none;')
        elif my.title_of_show not in [None, '']:
            imdb_table.add_row()
            description_box = imdb_table.add_cell("<b>No Tactic Orders Found, Didn't Query IMDb</b>")
            description_box.add_style('font-size: 14px;')
        table.add_row()
        order_div = DivWdg()
        order_div.add_style('overflow-y: scroll;')
        order_div.add_style('height: 1000px;')
        order_div.add_style('width: 750px;')
        order_div.add('<font size=7><b>Tactic Orders</b></font>')
        order_div.add(order_table)
        ot = table.add_cell(order_div)
        ot.add_attr('valign', 'top')
        imdb_div = DivWdg()
        imdb_div.add_style('overflow-y: scroll;')
        imdb_div.add_style('height: 1000px;')
        imdb_div.add_style('width: 750px;')
        imdb_div.add('<font size=7><b>IMDb</b></font>')
        imdb_div.add(imdb_table)
        it = table.add_cell(imdb_div)
        it.add_attr('valign', 'top')
        widget.add(table)
        return widget
Example #23
0
    def handle_simple_mode(self, custom_table, mode):

        tbody = custom_table.add_tbody()
        tbody.add_class("spt_custom_simple")
        if mode != 'simple':
            tbody.add_style('display: none')

        name_text = TextWdg("custom_name")
        name_text.add_class("spt_input")
        tr = custom_table.add_row()
        tr.add_color("background", "background", -7)
        td = custom_table.add_cell("Name: ")
        td.add_style("min-width: 150px")
        custom_table.add_cell(name_text)

        # add title
        custom_table.add_row()
        title_wdg = TextWdg("custom_title")
        title_wdg.add_attr("size", "50")
        custom_table.add_cell("Title: ")
        custom_table.add_cell(title_wdg)

        # add description
        tr = custom_table.add_row()
        tr.add_color("background", "background", -7)
        description_wdg = TextAreaWdg("custom_description")
        custom_table.add_cell("Description: ")
        custom_table.add_cell(description_wdg)

        type_select = SelectWdg("custom_type")
        type_select.add_class("spt_input")
        #type_select.add_empty_option("-- Select --")
        type_select.set_option(
            "values",
            "string|text|integer|float|boolean|currency|date|foreign_key|list|button|empty"
        )
        type_select.set_option(
            "labels",
            "String(db)|Text(db)|Integer(db)|Float(db)|Boolean(db)|Currency(db)|Date(db)|Foreign Key(db)|List(db)|Button|Empty"
        )
        #type_select.set_option("labels", "String|Integer|Boolean|Currency|Timestamp|Link|Foreign Key|List|Checkbox|Text|Number|Date|Date Range")
        tr = custom_table.add_row()
        custom_table.add_cell("Property Type: ")
        td = custom_table.add_cell(type_select)
        type_select.add_event(
            "onchange",
            "spt.custom_property_adder.property_type_select_cbk(this)")

        # extra info for foreign key
        custom_table.add_row()
        div = DivWdg()
        div.add_class("foreign_key_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")
        div.add("Options")
        div.add(HtmlElement.br())
        # TODO: this class should not be in prod!!
        from pyasm.prod.web import SearchTypeSelectWdg
        div.add("Relate to: ")
        search_type_select = SearchTypeSelectWdg(
            "foreign_key_search_select",
            mode=SearchTypeSelectWdg.CURRENT_PROJECT)
        div.add(search_type_select)
        td.add(div)

        # extra info for list
        custom_table.add_row()
        div = DivWdg()
        div.add_class("list_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")
        div.add("Options")
        div.add(HtmlElement.br())
        # TODO: this class should not be in prod!!
        from pyasm.prod.web import SearchTypeSelectWdg
        div.add("Values: ")
        search_type_text = TextWdg("list_values")
        div.add(search_type_text)
        td.add(div)

        # extra info for button
        custom_table.add_row()
        div = DivWdg()
        div.add_class("button_options")
        div.add_style("display: none")
        div.add_style("margin-top: 10px")

        class_path = "tactic.ui.table.ButtonElementWdg"
        button = Common.create_from_class_path(class_path)
        args_keys = button.get_args_keys()

        div.add("Options")
        div.add(HtmlElement.br())

        for key in args_keys.keys():
            div.add("Name: ")
            option_name_text = TextWdg("option_name")
            option_name_text.add_attr("readonly", "true")
            option_name_text.set_value(key)
            div.add(option_name_text)

            div.add(" &nbsp; ")

            div.add("Value: ")
            input = button.get_input_by_arg_key(key)
            div.add(input)

            #option_value_text = TextWdg("option_value")
            #div.add(option_value_text)
            div.add(HtmlElement.br())
        td.add(div)

        # is searchable checkbox
        tr = custom_table.add_row()
        tr.add_color("background", "background", -7)
        current_searchable_wdg = CheckboxWdg("is_searchable")
        #current_view_wdg.set_checked()
        custom_table.add_cell("Is Searchable? ")
        td = custom_table.add_cell(current_searchable_wdg)

        custom_table.close_tbody()