Пример #1
0
 def get_input_by_arg_key(my, key):
     if key == 'icon':
         input = SelectWdg("option_icon_select")
         input.set_option("values", IconWdg.get_icons_keys())
         input.add_empty_option("-- Select --")
     elif key == 'script':
         input = SelectWdg("option_script_select")
         input.set_option("query", "config/custom_script|code|code")
         input.add_empty_option("-- Select --")
     else:
         input = TextWdg("value")
     return input
Пример #2
0
    def get_language_select_wdg(self, name, width=100):
        """
        Get a select widget that chooses from the languages saved in the database.

        :param name: String, set as the name and ID for the select widget. Should correspond to a column on the MetaData
                     sobject
        :param width: int, the desired width of the widget in pixels
        :return: SelectWdg
        """
        select_wdg = SelectWdg(name)
        select_wdg.set_id(name)
        select_wdg.add_style('width', '{0}px'.format(width))
        select_wdg.add_empty_option()

        language_search = Search('twog/language')
        languages = language_search.get_sobjects()

        for language in languages:
            select_wdg.append_option(language.get_value('name'),
                                     language.get_code())

        if hasattr(self, name):
            select_wdg.set_value(getattr(self, name))

        return select_wdg
Пример #3
0
    def get_security_wdg(my):

        div = DivWdg()
        div.add_class("spt_security")

        div.add(
            "A server can sync either be scoped for a single project or all projects.  Transactions that occur in the admin project never get synced."
        )

        div.add("<br/>" * 2)

        div.add("Project: ")

        search = Search("sthpw/project")
        search.add_filters("code", ['admin', 'unittest'], op='not in')
        search.add_order_by("title")
        projects = search.get_sobjects()

        select = SelectWdg("projects")
        div.add(select)
        labels = [x.get_value("title") for x in projects]
        values = [x.get_value("code") for x in projects]

        project_code = Project.get_project_code()
        if project_code != 'admin':
            select.set_value(project_code)
        select.set_option("labels", labels)
        select.set_option("values", values)
        select.add_empty_option("-- All --")

        div.add("<br/>" * 2)

        return div
Пример #4
0
    def get_sync_mode_wdg(my):

        div = DivWdg()
        div.add_class("spt_sync_mode")

        div.add("Share Mode: ")
        select = SelectWdg("sync_mode")
        div.add(select)
        select.set_option("values", "file|xmlrpc")

        select.add_behavior({
            'type':
            'change',
            'cbjs_action':
            '''
            var top = bvr.src_el.getParent(".spt_sync_mode");
            var value = bvr.src_el.value;
            var xmlrpc_el = top.getElement(".spt_xmlrpc_mode");
            var file_el = top.getElement(".spt_file_mode");

            if (value == 'xmlrpc') {
                spt.show(xmlrpc_el);
                spt.hide(file_el);
            }
            else {
                spt.hide(xmlrpc_el);
                spt.show(file_el);
            }
            '''
        })

        div.add(my.get_xmlrpc_mode_wdg())
        div.add(my.get_file_mode_wdg())

        return div
    def get_display(self):
        outer_div = DivWdg()
        outer_div.set_id('new-department-request-entry-form')

        page_label = "<div>Fill out the following form to submit a new request. The request will be added to the " \
                     "department's list, and will be addressed as soon as possible. You will receive a " \
                     "notification when the request is complete.</div><br/>"
        outer_div.add(page_label)

        outer_div.add(get_label_widget('Name'))
        outer_div.add(get_text_input_wdg('name', 800))

        outer_div.add(get_label_widget('Description'))
        outer_div.add(
            obu.get_text_area_input_wdg('description', 800,
                                        [('display', 'block')]))

        outer_div.add(get_label_widget('Due Date'))
        outer_div.add(get_datetime_calendar_wdg())

        department_select_wdg = SelectWdg('department_select')
        department_select_wdg.append_option('Onboarding', 'onboarding')
        department_select_wdg.append_option('Edel', 'edel')
        department_select_wdg.append_option('Compression', 'compression')
        department_select_wdg.append_option('QC', 'qc')

        outer_div.add(get_label_widget('Department'))
        outer_div.add(department_select_wdg)

        self.get_submit_widget(outer_div)

        return outer_div
Пример #6
0
    def get_frame_rate_section(self):
        section_span = SpanWdg()

        section_span.add('Frame Rate: ')

        frame_rate_select = SelectWdg('frame_rate_select')
        frame_rate_select.set_id('frame_rate_code')
        frame_rate_select.add_style('width', '153px')
        frame_rate_select.add_style('display', 'inline-block')
        frame_rate_select.add_empty_option()

        frame_rate_search = Search('twog/frame_rate')
        frame_rates = frame_rate_search.get_sobjects()

        for frame_rate in frame_rates:
            frame_rate_select.append_option(frame_rate.get_value('name'), frame_rate.get_code())

        try:
            frame_rate_select.set_value(self.frame_rate_code)
        except AttributeError:
            pass

        section_span.add(frame_rate_select)

        return section_span
Пример #7
0
def get_task_status_select_wdg(task_sobject):
    """
    Given a sthpw/task sobject, return a SelectWdg with all its potential status options. This is done by looking up
    what those options are through the parent Pipeline.

    :param task_sobject: sthpw/task sobject
    :return: SelectWdg
    """

    task_status_select = SelectWdg('task_status_select')
    task_status_select.set_id('task_status_select')
    task_status_select.add_style('width: 165px;')
    task_status_select.add_empty_option()

    task_pipe_code = task_sobject.get_value('pipeline_code')

    # if the current task has no pipeline, then search for
    # any task pipeline
    if not task_pipe_code:
        # just use the default
        task_pipe_code = 'task'

    pipeline = Pipeline.get_by_code(task_pipe_code)
    if not pipeline:
        pipeline = Pipeline.get_by_code('task')

    for status in pipeline.get_process_names():
        task_status_select.append_option(status, status)

    if task_sobject.get('status'):
        task_status_select.set_value(task_sobject.get('status'))

    return task_status_select
    def get_display(self):
        div_wdg = DivWdg()

        current_code_div = DivWdg()
        component_code = self.file_flow_sobject.get('component_code')

        component_sobject = get_sobject_by_code('twog/component',
                                                component_code)
        current_code_div.add('Current Component set to {0} ({1})'.format(
            component_sobject.get('name'), component_code))

        order_sobject = get_order_sobject_from_component_sobject(
            component_sobject)
        component_sobjects_for_order = get_component_sobjects_from_order_code(
            order_sobject.get_code())

        component_select_wdg = SelectWdg()
        component_select_wdg.set_id('component_select')
        component_select_wdg.add_style('width: 165px;')
        component_select_wdg.add_empty_option()

        for component in component_sobjects_for_order:
            component_select_wdg.append_option(component.get('name'),
                                               component.get_code())

        div_wdg.add(current_code_div)
        div_wdg.add(component_select_wdg)

        return div_wdg
Пример #9
0
    def get_display(my):
        widget = DivWdg(id='link_view_select')
        widget.add_class("link_view_select")
        if my.refresh:
            widget = Widget()
        else:
            my.set_as_panel(widget)

        views = []
        if my.search_type:
            from pyasm.search import WidgetDbConfig
            search = Search(WidgetDbConfig.SEARCH_TYPE)
            search.add_filter("search_type", my.search_type)
            search.add_regex_filter("view",
                                    "link_search:|saved_search:",
                                    op="NEQI")
            search.add_order_by('view')
            widget_dbs = search.get_sobjects()
            views = SObject.get_values(widget_dbs, 'view')

        labels = [view for view in views]

        views.insert(0, 'table')
        labels.insert(0, 'table (Default)')
        st_select = SelectWdg('new_link_view', label='View: ')
        st_select.set_option('values', views)
        st_select.set_option('labels', labels)
        widget.add(st_select)
        return widget
Пример #10
0
    def get_display(self):
        return ''

        search_types = 'MMS/discipline.MMS/product_type'.split(".")

        top = DivWdg()
        parents = None
        for search_type in search_types:

            if not parents:
                search = Search(search_type)
                sobjects = search.get_sobjects()

                columns = search.get_columns()
                column = columns[1]

                select = SelectWdg(search_type)
                select.set_option("values", [x.get_id() for x in sobjects] )
                select.set_option("labels", [x.get_value(column) for x in sobjects] )
                top.add(select)
            else:
                for parent in parents:

                    search = Search(search_type)
                    search.add_relationship_filter(parent)
                    sobjects = search.get_sobjects()

                    if not sobjects:
                        continue

                    columns = search.get_columns()
                    column = columns[1]


                    values = [x.get_id() for x in sobjects]
                    labels = [x.get_value(column) for x in sobjects]


                    select = SelectWdg(search_type)
                    select.add_attr("spt_input_key", parent.get_id() )
                    select.set_option("values", values )
                    select.set_option("labels", labels )
                    top.add(select)

            parents = sobjects
        return top
Пример #11
0
    def get_display(my):

        state = my.get_state()
        search_type = state.get("search_type")
        sobj = my.get_current_sobject()

        if search_type:
            st = search_type
        else:

            st = sobj.get_base_search_type()
        # for inline insert, this should proceed
        #if not sobj:
        #    return ''

        st_suffix = st.split('/', 1)

        if len(st_suffix) == 2:
            st_suffix = st_suffix[1]

        search = Search('sthpw/pipeline')
        search.add_op_filters([('search_type', 'EQ', '/%s' % st_suffix)])

        # takes into account site-wide pipeline
        search.add_project_filter(show_unset=True)
        sobjects = search.get_sobjects()

        codes = [x.get_code() for x in sobjects]

        if my.get_option("use_code") in [True, 'true']:
            names = codes
        else:

            names = []
            for x in sobjects:
                name = x.get_value("name")
                if not name:
                    name = x.get_value("code")
                names.append(name)

        select = SelectWdg(my.get_input_name())
        select.add_empty_option("-- Default --")
        select.set_option("values", codes)
        select.set_option("labels", names)
        if sobj:
            value = sobj.get_value(my.get_name())
            if value:
                select.set_value(value)

        else:
            # only for inline
            #behavior =  { 'type': 'click',
            #       'cbjs_action': 'spt.dg_table.select_wdg_clicked( evt, bvr.src_el );'}
            #select.add_behavior(behavior)
            pass

        return select
Пример #12
0
    def get_display(my):
        sobject = my.get_current_sobject()
        key = sobject.get_value("key")
        options = sobject.get_value("options")
        type = sobject.get_value("type")

        # get the value of the users preferences
        search = Search("sthpw/pref_setting")
        search.add_user_filter()
        search.add_filter("key", key)
        pref_setting = search.get_sobject()
        if pref_setting:
            value = pref_setting.get_value("value")
        else:
            value = ""

        div = DivWdg()

        element_name = "%s_%s" % (my.get_name(), sobject.get_id())

        script = '''var server = TacticServerStub.get();
                var value = bvr.src_el.value;
                if (!value) return;

                spt.app_busy.show("Saving", "Saving Preference for [%s]");

                setTimeout( function() {
                    try{
                        server.execute_cmd('tactic.ui.table.SetPreferenceCmd', {key: '%s', value: value});
                    }catch(e){
                        spt.alert(spt.exception.handler(e));
                    }
                        
                    spt.app_busy.hide() 
                        
                    }, 200);''' % (key, key)

        if key in ['skin', 'palette', 'js_logging_level']:
            script = '''%s; spt.app_busy.show('Reloading Page ...'); setTimeout('spt.refresh_page()', 200);''' % script

        if type == "sequence":
            from pyasm.prod.web import SelectWdg
            select = SelectWdg(element_name)
            select.add_behavior({'type': "change", 'cbjs_action': script})

            select.set_option("values", options)
            if value:
                select.set_value(value)
            div.add(select)
        else:
            text = TextWdg(element_name)
            text.add_behavior({'type': "blur", 'cbjs_action': script})
            if value:
                text.set_value(value)
            div.add(text)

        return div
Пример #13
0
    def configure_category(my, title, category, options, options_type={}):
        div = DivWdg()

        title_wdg = DivWdg()
        div.add(title_wdg)

        #from tactic.ui.widget.swap_display_wdg import SwapDisplayWdg
        #swap = SwapDisplayWdg()
        #div.add(swap)

        title_wdg.add("<b>%s</b>" % title)

        table = Table()
        div.add(table)
        #table.add_color("color", "color")
        table.add_style("color: #000")
        table.add_style("margin: 20px")

        for option in options:
            table.add_row()
            display_title = Common.get_display_title(option)
            td = table.add_cell("%s: " % display_title)
            td.add_style("width: 150px")

            option_type = options_type.get(option)
            validation_scheme = ""

            #add selectWdg for those options whose type is bool
            if option_type == 'bool':
                text = SelectWdg(name="%s/%s" % (category, option))
                text.set_option('values', 'true|false')
                text.set_option('empty', 'true')
                text.add_style("margin-left: 0px")

            elif option.endswith('password'):
                text = PasswordInputWdg(name="%s/%s" % (category, option))

            # dealing with options whose type is number
            else:
                if option_type == 'number':
                    validation_scheme = 'INTEGER'

                else:
                    validation_scheme = ""

                text = TextInputWdg(name="%s/%s" % (category, option),
                                    validation_scheme=validation_scheme,
                                    read_only="false")

            value = Config.get_value(category, option)
            if value:
                text.set_value(value)

            table.add_cell(text)

        return div
def get_file_in_package_status_select():
    task_status_select = SelectWdg('file_status_select')
    task_status_select.set_id('file_status_select')
    task_status_select.add_style('width: 165px;')
    task_status_select.add_empty_option()

    pipeline = Pipeline.get_by_code('twog_Delivery')

    for status in pipeline.get_process_names():
        task_status_select.append_option(status, status)

    return task_status_select
Пример #15
0
def get_season_select_wdg(width=300):
    season_select_wdg = SelectWdg('season_code')
    season_select_wdg.set_id('season_code')
    season_select_wdg.add_style('width', '{0}px'.format(width))

    season_search = Search('twog/season')
    seasons = season_search.get_sobjects()

    for season in seasons:
        season_select_wdg.append_option(season.get_value('name'),
                                        season.get_code())

    return season_select_wdg
Пример #16
0
    def get_style_select(self):
        style_sel = SelectWdg('style_select')
        style_sel.set_id('style')
        style_sel.add_style('width: 135px;')
        style_sel.add_empty_option()

        for style in ('Technical', 'Spot QC', 'Mastering'):
            style_sel.append_option(style, style)

        if self.prequal_eval_sobject:
            style_sel.set_value(self.prequal_eval_sobject.get_value('style'))

        return style_sel
Пример #17
0
    def get_action_wdg(my):

        filter_div = DivWdg()

        select = SelectWdg("filter_action")
        select.add_empty_option("-- search action --")
        select.add_style("text-align: right")
        select.set_option("labels", "Retrieve Search|Save Search")
        select.set_option("values", "retrieve|save")
        select.add_event("onchange", "spt.dg_table.search_action_cbk(this)")
        filter_div.add(select)

        return filter_div
Пример #18
0
    def get_bay_select(self):
        bay_sel = SelectWdg('bay_select')
        bay_sel.set_id('bay')
        bay_sel.add_style('width', '135px')
        bay_sel.add_empty_option()

        for i in range(1, 13):
            bay_sel.append_option('Bay %s' % i, 'Bay %s' % i)

        if self.prequal_eval_sobject:
            bay_sel.set_value(self.prequal_eval_sobject.get_value('bay'))

        return bay_sel
Пример #19
0
    def get_display(self):

        widget = DivWdg()

        pipeline_code = self.get_option('pipeline')
        pipeline = Pipeline.get_by_code(pipeline_code)
        if not pipeline:
            widget.add("No pipeline defined")
            return widget
            

        processes = pipeline.get_process_names()

        widget.add_style("border: solid 1px blue")
        widget.add_style("position: absolute")
        widget.add_style("top: 300")
        widget.add_style("left: -500")

        for process in processes:

            #inputs = pipeline.get_input_processes(process)
            outputs = pipeline.get_output_processes(process)

            div = DivWdg()
            widget.add(div)
            div.add_class("spt_input_option")
            div.add_attr("spt_input_key", process)

            #if not outputs:
            #    # then we can't go anywhere, so just add a message
            #    text = ""
            #    div.add(text)
            #    continue

            values = []
            #values.extend( [str(x) for x in inputs] )
            values.append(process)
            values.extend( [str(x) for x in outputs] )


            select = SelectWdg(self.get_input_name())
            select.set_value(process)
            select.add_empty_option('-- Select --')
            select.set_option("values", values)
            div.add(select)

            from tactic.ui.panel import CellEditWdg
            CellEditWdg.add_edit_behavior(select)


        return widget
Пример #20
0
    def get_display(self):
        # add a view action
        view_div = DivWdg()
        view_select = SelectWdg("action|view_action")
        view_select.add_style("text-align: right")
        view_select.add_empty_option("-- view --")
        view_select.set_option("values", "copy_url|add_my_view|edit|save|rename|delete|custom_property|custom_script")
        view_select.set_option("labels", "X Copy URL to this View|Add to My Views|Edit as Draft|Save Project View As|X Rename View|X Delete View|Add Custom Property|Add Custom Script")
        view_div.add_style("float: right")
        view_div.add(view_select)

        view_select.add_event("onchange", "spt.dg_table.view_action_cbk(this,'%s')" % self.table_id)

        return view_div
Пример #21
0
def get_title_select_wdg(width=300):
    title_select_wdg = SelectWdg('title_code')
    title_select_wdg.set_id('title_code')
    title_select_wdg.add_style('width', '{0}px'.format(width))
    title_select_wdg.add_empty_option()

    title_search = Search('twog/title')
    titles = title_search.get_sobjects()

    for title in titles:
        title_select_wdg.append_option(title.get_value('name'),
                                       title.get_code())

    return title_select_wdg
Пример #22
0
    def get_bay_select(self):
        bay_sel = SelectWdg('bay_select')
        bay_sel.set_id('bay')
        bay_sel.add_style('width', '135px')
        bay_sel.add_empty_option()

        for i in range(1, 13):
            bay_sel.append_option('Bay %s' % i, 'Bay %s' % i)

        try:
            bay_sel.set_value(self.bay)
        except AttributeError:
            pass

        return bay_sel
Пример #23
0
def get_instructions_select_wdg():
    """
    Get a Select Widget with all the instructions options

    :return: SelectWdg
    """

    instructions_search = Search('twog/instructions')

    instructions_select_wdg = SelectWdg('instructions_select')
    instructions_select_wdg.set_id('instructions_select')
    instructions_select_wdg.add_empty_option()
    instructions_select_wdg.set_search_for_options(instructions_search, 'code', 'name')

    return instructions_select_wdg
Пример #24
0
    def get_status_select(self):
        status_sel = SelectWdg('status_select')
        status_sel.set_id('status')
        status_sel.add_style('width', '135px')
        status_sel.add_empty_option()

        statuses = ('Approved', 'In Progress', 'Rejected')

        for status in statuses:
            status_sel.append_option(status, status)

        if hasattr(self, 'status'):
            status_sel.set_value(self.status)

        return status_sel
Пример #25
0
    def get_status_select(self):
        status_sel = SelectWdg('status_select')
        status_sel.set_id('status')
        status_sel.add_style('width', '135px')
        status_sel.add_empty_option()

        statuses = ('Approved', 'Condition', 'Rejected')

        for status in statuses:
            status_sel.append_option(status, status)

        if self.prequal_eval_sobject:
            status_sel.set_value(self.prequal_eval_sobject.get_value('status'))

        return status_sel
Пример #26
0
    def get_format_select_wdg(self):
        format_sel = SelectWdg('format_select')
        format_sel.set_id('format')
        format_sel.add_style('width', '153px')
        format_sel.add_style('display', 'inline-block')
        format_sel.add_empty_option()

        for file_format in ('Electronic/File', 'File - ProRes', 'File - MXF', 'File - MPEG', 'File - WAV', 'DBC', 'D5',
                            'HDCAM SR', 'NTSC', 'PAL'):
            format_sel.append_option(file_format, file_format)

        if self.prequal_eval_sobject:
            format_sel.set_value(self.prequal_eval_sobject.get_value('format'))

        return format_sel
Пример #27
0
    def get_style_select(self):
        style_sel = SelectWdg('style_select')
        style_sel.set_id('style')
        style_sel.add_style('width: 135px;')
        style_sel.add_empty_option()

        for style in ('Technical', 'Spot QC', 'Mastering'):
            style_sel.append_option(style, style)

        try:
            style_sel.set_value(self.style_sel)
        except AttributeError:
            pass

        return style_sel
Пример #28
0
    def get_machine_select(self):
        machine_sel = SelectWdg('machine_select')
        machine_sel.set_id('machine_code')
        machine_sel.add_style('width', '135px')
        machine_sel.add_empty_option()

        machine_search = Search('twog/machine')
        machines = machine_search.get_sobjects()

        for machine in machines:
            machine_sel.append_option(machine.get_value('name'), machine.get_code())

        if self.prequal_eval_sobject:
            machine_sel.set_value(self.prequal_eval_sobject.get_value('machine_code'))

        return machine_sel
Пример #29
0
    def get_display(self):

        # add a view action
        view_div = DivWdg()
        view_select = SelectWdg("action|table")
        view_select.add_style("text-align: right")
        view_select.add_empty_option("-- items --")
        view_select.set_option("values", "add|edit|retire|delete|export_all|export_selected")
        view_select.set_option("labels", "Add New Item|X Edit Selected|Retire Selected|Delete Selected|X CSV Export (all)|X CSV Export (selected)")
        view_div.add_style("float: right")
        view_div.add(view_select)

        #view_select.add_event("onchange", "spt.dg_table.retire_selected_cbk('%s')" % self.target_id)
        view_select.add_event("onchange", "spt.dg_table.table_action_cbk(this,'%s')" % self.table_id )

        return view_div
Пример #30
0
def get_language_select_wdg():
    language_select_wdg = SelectWdg('language_code')
    language_select_wdg.set_id('language_code')
    language_select_wdg.add_style('display', 'inline-block')
    language_select_wdg.add_empty_option()

    language_search = Search('twog/language')
    languages = language_search.get_sobjects()

    languages = sorted(languages, key=lambda x: x.get_value('name'))

    for language in languages:
        language_select_wdg.append_option(language.get_value('name'),
                                          language.get_code())

    return language_select_wdg