def get_display(my): my.work_order_code = str(my.kwargs.get('work_order_code')) my.client_code = str(my.kwargs.get('client_code')) my.parent_pipe = str(my.kwargs.get('parent_pipe')) my.is_master = str(my.kwargs.get('is_master')) my.order_sk = str(my.kwargs.get('order_sk')) wo_search = Search("twog/work_order") wo_search.add_filter('code', my.work_order_code) work_order = wo_search.get_sobject() wo_sk = work_order.get_search_key() proj_code = work_order.get_value('proj_code') wo_templ_code = work_order.get_value('work_order_templ_code') ws_search = Search("twog/work_order_sources") ws_search.add_filter("work_order_code", my.work_order_code) work_order_sources = ws_search.get_sobjects() user_group_names = Environment.get_group_names() groups_str = '' for mg in user_group_names: if groups_str == '': groups_str = mg else: groups_str = '%s,%s' % (groups_str, mg) user_is_scheduler = False if 'scheduling' in groups_str: user_is_scheduler = True ignore_processes = work_order.get_value('process') other_search = Search("twog/work_order") other_search.add_filter('proj_code', work_order.get_value('proj_code')) other_search.add_filter('process', ignore_processes, op="!=") all_other_wos = other_search.get_sobjects() all_other_interms = {} for other in all_other_wos: or_search = Search("twog/work_order_intermediate") or_search.add_filter('work_order_code',other.get_value('code')) other_reals = or_search.get_sobjects() for otr in other_reals: intermediate_file_code = otr.get_value('intermediate_file_code') inter_search = Search("twog/intermediate_file") inter_search.add_filter('code', intermediate_file_code) intermediate_file = inter_search.get_sobject() inter_title = intermediate_file.get_value('inter_file') if other.get_value('code') not in all_other_interms.keys(): all_other_interms[other.get_value('code')] = [] all_other_interms[other.get_value('code')].append([inter_title, intermediate_file.get_value('code')]) order_code = my.order_sk.split('code=')[1] overhead = Table() overhead.add_attr('class','sp_overhead_%s' % my.work_order_code) overhead.add_attr('client_code', my.client_code) overhead.add_attr('is_master', my.is_master) overhead.add_attr('parent_pipe', my.parent_pipe) table = Table() src_tbl = Table() for sc in work_order_sources: src_search = Search("twog/source") src_search.add_filter('code', sc.get_value('source_code')) src = src_search.get_sobjects() if len(src) > 0: src = src[0] src_tbl.add_row() if user_is_scheduler: killer = src_tbl.add_cell(my.x_butt) killer.add_style('cursor: pointer;') killer.add_behavior(get_source_killer_behavior(sc.get_value('code'), my.work_order_code, my.parent_pipe, my.client_code, my.is_master, '%s: %s' % (src.get_value('title'), src.get_value('episode')), my.order_sk)) alabel = src_tbl.add_cell('Source: ') alabel.add_attr('align', 'center') popper = src_tbl.add_cell('<u>%s: %s</u>' % (src.get_value('title'), src.get_value('episode'))) popper.add_attr('nowrap', 'nowrap') popper.add_style('cursor: pointer;') popper.add_behavior(get_launch_wo_source_behavior(my.work_order_code, wo_sk, src.get_value('code'), my.order_sk)) table.add_row() table.add_cell(src_tbl) pass_search = Search("twog/work_order_passin") pass_search.add_filter('work_order_code', my.work_order_code) passins = pass_search.get_sobjects() table.add_row() table.add_cell(' ') table.add_cell(' ') add_deliv_passin_butt = table.add_cell('<input type="button" value="Add Permanent Element Pass-in"/>') add_deliv_passin_butt.add_attr('colspan', '2') add_deliv_passin_butt.add_behavior(get_add_deliverable_passin_behavior(my.work_order_code, wo_templ_code, proj_code, my.order_sk)) # Now do passed in permanent sources, which can be templated dsrc_tbl = Table() for p in passins: if p.get_value('deliverable_source_code') not in [None,'']: ds_search = Search("twog/source") ds_search.add_filter('code', p.get_value('deliverable_source_code')) d_source = ds_search.get_sobjects() if len(d_source) > 0: d_source = d_source[0] dsrc_tbl.add_row() if user_is_scheduler: killer = dsrc_tbl.add_cell(my.x_butt) killer.add_style('cursor: pointer;') killer.add_behavior(get_deliverable_passin_killer_behavior(p.get_value('code'), my.work_order_code, wo_templ_code, my.parent_pipe, my.client_code, my.is_master, '%s: %s' % (d_source.get_value('title'), d_source.get_value('episode')), my.order_sk)) alabel = dsrc_tbl.add_cell('Source: ') alabel.add_attr('align', 'center') popper = dsrc_tbl.add_cell('<u>%s: %s</u>' % (d_source.get_value('title'), d_source.get_value('episode'))) popper.add_attr('nowrap', 'nowrap') popper.add_style('cursor: pointer;') popper.add_behavior(get_launch_wo_source_behavior(my.work_order_code, wo_sk, d_source.get_value('code'), my.order_sk)) if my.is_master in [True,'true','True',1,'t']: if p.get_value('passin_templ_code') in [None,'']: template_button = ButtonSmallNewWdg(title="Template This Passed-in Source", icon=CustomIconWdg.icons.get('TEMPLATE')) if my.is_master == 'true': template_button.add_behavior(get_template_deliverable_passin_behavior(my.work_order_code, wo_templ_code, p.get_value('code'))) else: template_button = '<img border="0" style="vertical-align: middle" title="Templated" name="Templated" src="/context/icons/silk/tick.png">' tb = dsrc_tbl.add_cell(template_button) tb.add_attr('class', 'sp_templ_%s' % p.get_value('code')) if my.is_master in [True, 'true', 'True', 1, 't']: table.add_row() table.add_cell(dsrc_tbl) table.add_row() divider = table.add_cell('<hr/>') divider.add_attr('colspan', '4') table.add_row() table.add_cell(' ') table.add_cell(' ') adinter_fm_butt = table.add_cell('<input type="button" value="Add Intermediate Pass-in"/>') adinter_fm_butt.add_attr('colspan', '2') adinter_fm_butt.add_behavior(get_add_intermediate_passin_behavior(my.work_order_code, wo_templ_code, proj_code, my.order_sk)) inter_tbl = Table() for p in passins: if p.get_value('intermediate_file_code') not in [None,'']: in_search = Search("twog/intermediate_file") in_search.add_filter('code', p.get_value('intermediate_file_code')) inter_f = in_search.get_sobjects() if len(inter_f) > 0: inter_f = inter_f[0] inter_tbl.add_row() if user_is_scheduler: killer = inter_tbl.add_cell(my.x_butt) killer.add_style('cursor: pointer;') killer.add_behavior(get_intermediate_passin_killer_behavior(p.get_value('code'), my.work_order_code, wo_templ_code, my.parent_pipe, my.client_code, my.is_master, inter_f.get_value('title'), my.order_sk)) alabel = inter_tbl.add_cell('Intermediate: ') alabel.add_attr('align','center') popper = inter_tbl.add_cell('<u>%s</u>' % (inter_f.get_value('title'))) popper.add_attr('nowrap','nowrap') popper.add_style('cursor: pointer;') popper.add_behavior(get_open_intermediate_behavior(inter_f.get_value('code'),my.work_order_code, my.client_code, my.order_sk)) if my.is_master in [True,'true','True',1,'t']: if p.get_value('passin_templ_code') in [None,'']: template_button = ButtonSmallNewWdg(title="Template This Passed-in Intermediate File", icon=CustomIconWdg.icons.get('TEMPLATE')) if my.is_master == 'true': template_button.add_behavior(get_template_intermediate_passin_behavior(my.work_order_code, wo_templ_code, p.get_value('code'))) else: template_button = '<img border="0" style="vertical-align: middle" title="Templated" name="Templated" src="/context/icons/silk/tick.png">' tb = inter_tbl.add_cell(template_button) tb.add_attr('class', 'sp_templ_%s' % p.get_value('code')) table.add_row() table.add_cell(inter_tbl) overhead.add_row() oh_cell = overhead.add_cell(table) oh_cell.add_attr('class', 'sp_list_cell') return overhead
def get_display(my): my.work_order_code = str(my.kwargs.get('work_order_code')) my.work_order_sk = str(my.kwargs.get('work_order_sk')) my.work_order_sk = my.server.build_search_key('twog/work_order', my.work_order_code) my.order_sk = str(my.kwargs.get('order_sk')) wsource_search = Search("twog/work_order_sources") wsource_search.add_filter('work_order_code', my.work_order_code) wo_sources = wsource_search.get_sobjects() table = Table() table.add_attr('width', '100%') table.add_attr('bgcolor', '#c6c6e4') table.add_style('border-bottom-left-radius', '10px') table.add_style('border-top-left-radius', '10px') table.add_row() source_limit = 4 pass_search = Search("twog/work_order_passin") pass_search.add_filter('work_order_code', my.work_order_code) passins = pass_search.get_sobjects() sources = [] inter_passins = [] for passin in passins: if passin.get_value('deliverable_source_code') not in [None,'']: source_search = Search("twog/source") source_search.add_filter('code', passin.get_value('deliverable_source_code')) that_src = source_search.get_sobject() sources.append(that_src) elif passin.get_value('intermediate_file_code') not in [None,'']: inter_search = Search("twog/intermediate_file") inter_search.add_filter('code', passin.get_value('intermediate_file_code')) inter_file = inter_search.get_sobject() inter_passins.append(inter_file) seen = [] for wo_source in wo_sources: source_code = wo_source.get_value('source_code') if source_code not in seen: seen.append(source_code) source_search = Search("twog/source") source_search.add_filter("code", source_code) source = source_search.get_sobject() sources.append(source) if len(sources) > 0: table.add_row() mr_title = table.add_cell('<b><u><i>Sources</i></u></b>') mr_title.add_style('font-size: 90%;') count = 0 for source in sources: inner_table = Table() inner_table.add_row() if not source.get_value('high_security'): celly = inner_table.add_cell('<font color="#3e3e3e"><b><u>(%s): %s</u></b></font>' % (source.get_value('barcode'),source.get_value('title'))) else: celly = inner_table.add_cell('<font color="#ff0000"><b><u>!!!(%s): %s!!!</u></b></font>' % (source.get_value('barcode'),source.get_value('title'))) celly.add_attr('nowrap','nowrap') celly.add_style('cursor: pointer;') celly.add_style('font-size: 80%s;' % '%') celly.add_behavior(get_launch_wo_source_behavior(my.work_order_code, my.work_order_sk, source.get_value('code'), my.order_sk)) if count % source_limit == 0: table.add_row() inner_cell = table.add_cell(inner_table) inner_cell.add_attr('valign', 'top') table.add_cell(' ') count += 1 inter_pass_table = Table() inter_pass_table.add_attr('width', '100%') inter_pass_table.add_attr('bgcolor', '#c6c6e4') if len(inter_passins) > 0: inter_pass_table.add_row() mr_title = inter_pass_table.add_cell('<b><u><i>Intermediate Sources</i></u></b>') mr_title.add_attr('nowrap', 'nowrap') mr_title.add_style('font-size: 90%;') if len(sources) < 1: inter_pass_table.add_style('border-top-left-radius', '10px') inter_pass_table.add_style('border-bottom-left-radius', '10px') count = 0 for intermediate in inter_passins: inner_table = Table() inner_table.add_row() celly = inner_table.add_cell('<font color="#3e3e3e"><b><u>%s</u></b></font>' % (intermediate.get_value('title'))) celly.add_attr('nowrap', 'nowrap') celly.add_style('cursor: pointer;') celly.add_style('font-size: 80%;') celly.add_behavior(get_launch_wo_inter_behavior(my.work_order_code, my.work_order_sk, intermediate.get_value('code'), my.order_sk)) if count % source_limit == 0: inter_pass_table.add_row() inner_cell = inter_pass_table.add_cell(inner_table) inner_cell.add_attr('valign','top') inter_pass_table.add_cell(' ') count += 1 # Need to enter Interims and Delivs Here inter_table = Table() inter_table.add_attr('width', '100%') inter_table.add_attr('bgcolor', '#acbe49e') wointer_search = Search("twog/work_order_intermediate") wointer_search.add_filter('work_order_code', my.work_order_code) wointers = wointer_search.get_sobjects() if len(wointers) > 0: inter_table.add_row() mr_title = inter_table.add_cell('<b><u><i>Intermediate Results</i></u></b>') mr_title.add_attr('nowrap', 'nowrap') mr_title.add_style('font-size: 90%s;' % '%') if len(sources) < 1 and len(inter_passins) < 1: inter_table.add_style('border-top-left-radius', '10px') inter_table.add_style('border-bottom-left-radius', '10px') count = 0 for wointer in wointers: inter_code = wointer.get_value('intermediate_file_code') if inter_code not in seen: seen.append(inter_code) inter_search = Search("twog/intermediate_file") inter_search.add_filter('code',inter_code) intermediate = inter_search.get_sobject() inner_table = Table() inner_table.add_row() celly = inner_table.add_cell('<font color="#3e3e3e"><b><u>%s</u></b></font>' % (intermediate.get_value('title'))) celly.add_attr('nowrap','nowrap') celly.add_style('cursor: pointer;') celly.add_style('font-size: 80%s;' % '%') celly.add_behavior(get_launch_wo_inter_behavior(my.work_order_code, my.work_order_sk, inter_code, my.order_sk)) if count % source_limit == 0: inter_table.add_row() inner_cell = inter_table.add_cell(inner_table) inner_cell.add_attr('valign', 'top') inter_table.add_cell(' ') count += 1 # Need deliverables listed here deliv_table = Table() deliv_table.add_attr('width','100%s' % '%') deliv_table.add_attr('bgcolor','#acbe49e') deliv_table.add_style('border-bottom-right-radius', '10px') deliv_table.add_style('border-top-right-radius', '10px') d_search = Search("twog/work_order_deliverables") d_search.add_filter('work_order_code',my.work_order_code) wodelivs = d_search.get_sobjects() if len(wodelivs) > 0: deliv_table.add_row() mr_title = deliv_table.add_cell('<b><u><i>Permanent Results</i></u></b>') mr_title.add_attr('nowrap','nowrap') mr_title.add_style('font-size: 90%s;' % '%') if len(sources) < 1 and len(inter_passins) < 1 and len(wointers) < 1: deliv_table.add_style('border-top-left-radius', '10px') deliv_table.add_style('border-bottom-left-radius', '10px') count = 0 for wodeliv in wodelivs: deliv_code = wodeliv.get_value('deliverable_source_code') if deliv_code not in seen: seen.append(deliv_code) s_search = Search("twog/source") s_search.add_filter('code',deliv_code) deliverable = s_search.get_sobjects() if len(deliverable) > 0: deliverable = deliverable[0] inner_table = Table() inner_table.add_row() if not deliverable.get_value('high_security'): celly = inner_table.add_cell('<font color="#3e3e3e"><b><u>(%s): %s</u></b></font>' % (deliverable.get_value('barcode'), deliverable.get_value('title'))) else: celly = inner_table.add_cell('<font color="#ff0000"><b><u>!!!(%s): %s!!!</u></b></font>' % (deliverable.get_value('barcode'), deliverable.get_value('title'))) celly.add_attr('nowrap','nowrap') celly.add_style('cursor: pointer;') celly.add_style('font-size: 80%s;' % '%') celly.add_behavior(get_launch_wo_deliv_behavior(my.work_order_code, my.work_order_sk, deliv_code, my.order_sk)) if count % source_limit == 0: deliv_table.add_row() inner_cell = deliv_table.add_cell(inner_table) inner_cell.add_attr('valign','top') deliv_table.add_cell(' ') count += 1 else: with open('/var/www/html/Lost_Sources','a') as lostsources: lostsources.write('%s:%s SOURCE: %s\n' % (my.order_sk, my.work_order_code, deliv_code)) lostsources.close() if len(wodelivs) < 1: inter_table.add_style('border-bottom-right-radius', '10px') inter_table.add_style('border-top-right-radius', '10px') if len(wodelivs) < 1 and len(wointers) < 1: inter_pass_table.add_style('border-bottom-right-radius', '10px') inter_pass_table.add_style('border-top-right-radius', '10px') if len(inter_passins) < 1 and len(wointers) < 1 and len(wodelivs) < 1: table.add_style('border-bottom-right-radius', '10px') table.add_style('border-top-right-radius', '10px') table2 = Table() table2.add_row() barcode_text_wdg = TextWdg('wo_barcode_insert') barcode_text_wdg.add_behavior(get_wo_barcode_insert_behavior(my.work_order_code, my.work_order_sk, my.order_sk)) bct = table2.add_cell(barcode_text_wdg) bct.add_attr('align', 'right') bct.add_attr('width', '100%') two_gether = Table() two_gether.add_row() if len(sources) > 0: srcs = two_gether.add_cell(table) srcs.add_attr('width', '100%') srcs.add_attr('valign', 'top') if len(inter_passins) > 0: ips = two_gether.add_cell(inter_pass_table) ips.add_attr('width', '100%') ips.add_attr('valign', 'top') if len(wointers) > 0: intr = two_gether.add_cell(inter_table) intr.add_attr('width', '100%') intr.add_attr('valign', 'top') if len(wodelivs) > 0: delvs = two_gether.add_cell(deliv_table) delvs.add_attr('width', '100%') delvs.add_attr('valign', 'top') long = two_gether.add_cell(' ') long.add_style('width: 100%') bcentry = two_gether.add_cell(table2) bcentry.add_attr('valign', 'top') bcentry.add_attr('align', 'right') for source in sources: if source.get_value('children') in [None,'']: update_str = '' for wod in wodelivs: if update_str == '': update_str = wod.get_value('deliverable_source_code') else: update_str = '%s,%s' % (update_str, wod.get_value('deliverable_source_code')) d_search = Search("twog/source") d_search.add_filter('code', wod.get_value('deliverable_source_code')) d_src = d_search.get_sobject() ancestors = d_src.get_value('ancestors') if ancestors.find(source.get_value('code')) == -1: if ancestors in [None,'']: ancestors = source.get_value('code') else: ancestors = '%s,%s' % (ancestors, source.get_value('code')) my.server.update(d_src.get_search_key(), {'ancestors': ancestors}) if len(wodelivs) > 0: my.server.update(source.get_search_key(), {'children': update_str}) return two_gether