def get_display(my): sobject = my.get_current_sobject() sk = sobject.get_search_key() widget = DivWdg() sts_to_perm = {'twog/qc_report_vars': 'compression|qc supervisor|edeliveries'} if '-1' not in sk: table = Table() table.add_attr('width', '50px') login = Environment.get_login() user_name = login.get_login() groups = Environment.get_group_names() st = sk.split('?')[0]; perms = sts_to_perm[st] allow = False for g in groups: if g in perms: allow = True if user_name == 'admin': allow = True if allow: table.add_row() cell1 = table.add_cell(my.x_butt) cell1.add_attr('id','sp_del_%s' % sk) launch_behavior = my.get_delete_behavior(sk) cell1.add_style('cursor: pointer;') cell1.add_behavior(launch_behavior) widget.add(table) return widget
def init(self): self.task_code = self.kwargs.get('task_code', '') self.task_pipelines = '' self.parent_sk = self.kwargs.get('parent_sk', '') self.parent_pyclass = '' self.order_sk = self.kwargs.get('order_sk', '') self.groups = Environment.get_group_names() if 'user' in self.kwargs.keys(): self.user = str(self.kwargs.get('user')) else: self.user = Environment.get_user_name()
def init(my): nothing = 'true' my.server = None my.login = Environment.get_login() my.groups_arr = Environment.get_group_names() my.groups_str = '' for guy in my.groups_arr: if my.groups_str == '': my.groups_str = guy else: my.groups_str = '%s,%s' % (my.groups_str, guy) my.user_name = my.login.get_login()
def init(my): my.group_list = Environment.get_group_names() login = Environment.get_login() my.user = login.get_login() my.server = TacticServerStub.get() my.sk = '' my.code = '' my.st = '' my.is_scheduler = False for gname in my.group_list: if 'scheduling' in gname: my.is_scheduler = True if my.user == 'admin': my.is_scheduler = True
def init(my): from client.tactic_client_lib import TacticServerStub from pyasm.common import Environment my.group_list = Environment.get_group_names() login = Environment.get_login() my.user = login.get_login() my.server = TacticServerStub.get() my.sk = '' my.code = '' my.st = '' my.is_scheduler = False for gname in my.group_list: if 'scheduling' in gname: my.is_scheduler = True if my.user == 'admin': my.is_scheduler = True
def get_display(self): """ Get the code for displaying this widget. :return: the sobject edit widget """ search_type = self.kwargs.get('search_type') sobject_code = self.kwargs.get('sobject_code') if not (search_type and sobject_code): return DivWdg('Could not display [{0}]: [{1}]'.format(search_type, sobject_code)) mode = 'view' user_groups = Environment.get_group_names() if 'scheduling' in user_groups: mode = 'edit' sobject_type = ctu.get_sobject_type(search_type) # TODO: get a relevant display name display_name = sobject_code title = '{0} {1}: {2}'.format(mode.title(), sobject_type.title(), display_name) edit_widget = EditWdg(search_type=search_type, code=sobject_code, title=title, mode=mode, view='edit', show_header='true') return edit_widget
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): login_groups = Environment.get_group_names() top = DivWdg() if 'admin' not in login_groups: return top top.add_border() top.add_style("padding: 10px") top.add_color("color", "color") top.add_gradient("background", "background", 0, -5) #top.add_style("height: 550px") top.add_behavior( { 'type': 'load', 'cbjs_action': ''' spt.named_events.fire_event("side_bar|hide_now", {} ); ''' } ) project = Project.get() title = DivWdg() title.add("Project Startup and Configuration") title.add_style("font-size: 18px") title.add_style("font-weight: bold") title.add_style("text-align: center") title.add_style("padding: 10px") title.add_style("margin: -10px -10px 10px -10px") top.add(title) title.add_gradient("background", "background3", 5, -10) shelf = DivWdg() top.add(shelf) shelf.add_style("margin-left: -8px") shelf.add_style("width: 130px") button_div = DivWdg() shelf.add(button_div) button_div.add_style("float: left") button_div.add_style("margin-top: -3px") security = Environment.get_security() view_side_bar = security.check_access("builtin", "view_side_bar", "allow", default='allow') if view_side_bar: button = IconButtonWdg(title="Side Bar", icon=IconWdg.ARROW_LEFT) button_div.add(button) shelf.add("Toggle Side Bar") shelf.add_attr("title", "Toggle Side Bar (or press '1')") button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("side_bar|toggle"); ''' } ) shelf.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' spt.named_events.fire_event("side_bar|toggle"); ''' } ) shelf.add_class("hand") else: shelf.add(" ") search_wdg = Table() top.add(search_wdg) search_wdg.add_row() search_wdg.add_class("spt_main_top") search_wdg.add_style("padding: 10px") search_wdg.add_style("margin: 20px auto") search_wdg.add_style("width: 430px") td = search_wdg.add_cell("Search: ") td.add_style("vertical-align: top") td.add_style("padding-top: 8px") custom_cbk = {} custom_cbk['enter'] = ''' var top = bvr.src_el.getParent(".spt_main_top"); var search_el = top.getElement(".spt_main_search"); var keywords = search_el.value; if (keywords != '') { var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'search_type': 'sthpw/sobject_list', 'view': 'result_list', 'keywords': keywords, 'simple_search_view': 'simple_filter', //'show_shelf': false, } spt.tab.set_main_body_tab(); spt.tab.add_new("Search Results", "Search Results", class_name, kwargs); } ''' from tactic.ui.input import TextInputWdg, LookAheadTextInputWdg #text = TextInputWdg(name="search") text = LookAheadTextInputWdg(name="search", custom_cbk=custom_cbk, width='280', height='42px') #text = TextWdg("search") text.add_class("spt_main_search") text.add_style("width: 290px") search_wdg.add_cell(text) search_wdg.add_style("font-weight: bold") search_wdg.add_style("font-size: 16px") icon_div = DivWdg() td = search_wdg.add_cell(icon_div) td.add_style("vertical-align: top") icon_div.add_style("width: 38px") icon_div.add_style("height: 27px") icon_div.add_style("padding-top: 7px") icon_div.add_style("padding-left: 4px") icon_div.add_style("text-align: center") #icon_div.add_gradient("background", "background3", 15, -10) icon_div.add_color("background", "background3", 10) over_color = icon_div.get_color("background3", 0) out_color = icon_div.get_color("background3", 10) icon_div.set_round_corners(5) icon_div.set_box_shadow("1px 1px 1px 1px") icon = IconWdg("Search", IconWdg.SEARCH_32, width=24) icon_div.add(icon) button = icon_div icon_div.add_class("hand") icon_div.add_behavior( { 'type': 'mouseover', 'color': over_color, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.color); ''' } ) icon_div.add_behavior( { 'type': 'mouseout', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("background", bvr.color); bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-5"); bvr.src_el.setStyle("margin-right", "0"); ''' } ) icon_div.add_behavior( { 'type': 'click', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "0px 0px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-3"); bvr.src_el.setStyle("margin-right", "-2"); ''' } ) icon_div.add_behavior( { 'type': 'click_up', 'color': out_color, 'cbjs_action': ''' bvr.src_el.setStyle("box-shadow", "1px 1px 1px 1px #999"); bvr.src_el.setStyle("margin-top", "-5"); bvr.src_el.setStyle("margin-right", "0"); ''' } ) button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var top = bvr.src_el.getParent(".spt_main_top"); var search_el = top.getElement(".spt_main_search"); var keywords = search_el.value; if (keywords == '') { return; } var class_name = 'tactic.ui.panel.ViewPanelWdg'; var kwargs = { 'search_type': 'sthpw/sobject_list', 'view': 'result_list', 'keywords': keywords, 'simple_search_view': 'simple_filter', //'show_shelf': false, } spt.tab.set_main_body_tab(); spt.tab.add_new("Search Results", "Search Results", class_name, kwargs); ''' } ) #desc = DivWdg() #top.add(desc) #desc.add("Dashboard") #desc.add_style("width: 600px") # create a bunch of panels table = Table() table.add_color("color", "color") table.add_style("margin-bottom: 20px") table.center() top.add(table) table.add_row() #security = Environment.get_security() #if not security.check_access("builtin", "view_site_admin", "allow"): td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Configuration" #description = '''All TACTIC projects can be uniquely designed and managed using our configuration tools.''' description = '''Configure a Project from start to finish.''' image = "<img src='/context/icons/64x64/configuration_64.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.startup.ProjectConfigWdg'; var kwargs = { help_alias: 'project-startup-configuration' }; spt.tab.add_new("project_configuration", "Configuration", class_name, kwargs); ''' } config_wdg = my.get_main_section_wdg(title, description, image, behavior) td.add(config_wdg) # Manage Users td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Manage Users and Security" image = "<img src='/context/icons/64x64/dashboard_64.png'/>" image = DivWdg() image_link = "<div style='margin-bottom: -64px'><img src='/context/icons/64x64/lock_64.png'/></div>" image.add(image_link) image1 = IconWdg("Manage Users", IconWdg.USER_32) image2 = IconWdg("Manage Users", IconWdg.USER_32) image3 = IconWdg("Manage Users", IconWdg.USER_32) image4 = IconWdg("Manage Users", IconWdg.USER_32) image.add(image1) image.add(image2) image.add("<br/>") image.add(image3) image.add(image4) description = '''Manage users that can access the system''' behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.startup.UserConfigWdg'; var kwargs = { help_alias: 'project-startup-manage-users' }; spt.tab.add_new("manage_user", "Manage Users", class_name, kwargs); ''' } manage_users_wdg = my.get_main_section_wdg(title, description, image, behavior) td.add(manage_users_wdg) # custom layout editor td = table.add_cell() td.add_style("padding: 3px") td.add_style("vertical-align: top") title = "Custom Layouts" description = '''Create interfaces using the Custom Layout Editor.''' image = "<img src='/context/icons/64x64/layout_64.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.tab.set_main_body_tab(); var class_name = 'tactic.ui.tools.CustomLayoutEditWdg'; var kwargs = { help_alias: 'project-startup-configuration' }; spt.tab.add_new("custom_layout_editor", "Custom Layout Editor", class_name, kwargs); ''' } config_wdg = my.get_main_section_wdg(title, description, image, behavior) td.add(config_wdg) tr = table.add_row() # Plugins td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Plugin Manager" image = IconWdg("Plugins Manager", IconWdg.PLUGIN_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''Upload, install, remove and create TACTIC plugins.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.app.PluginWdg'; spt.tab.set_main_body_tab(); spt.tab.add_new("plugins", "Plugin Manager", class_name, kwargs); ''' } plugin_wdg = my.get_small_section_wdg(title, description, image, behavior) td.add(plugin_wdg) # Examples td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Tools" image = IconWdg("Tools", IconWdg.SHARE_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''A collection of example views.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.startup.ToolsWdg'; spt.tab.set_main_body_tab(); spt.tab.add_new("tools", "Tools", class_name, kwargs); ''' } share_wdg = my.get_small_section_wdg(title, description, image, behavior) td.add(share_wdg) # Share """ td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Shares" image = IconWdg("Shares", IconWdg.SHARE_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''Share project with other TACTIC installs.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.startup.ShareWdg'; spt.tab.set_main_body_tab(); spt.tab.add_new("shares", "Shares", class_name, kwargs); ''' } share_wdg = my.get_small_section_wdg(title, description, image, behavior) td.add(share_wdg) """ # Advanced td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Advanced Setup" image = IconWdg("Advanced", IconWdg.ADVANCED_32) #image = "<img src='/context/icons/64x64/dashboard_64.png'/>" description = '''A set of advanced configuration tools.''' behavior = { 'type': 'click_up', 'cbjs_action': ''' var class_name = 'tactic.ui.app.ProjectStartWdg'; spt.tab.set_main_body_tab() spt.tab.add_new("project_setup", "Project Setup", class_name) ''' } share_wdg = my.get_small_section_wdg(title, description, image, behavior) td.add(share_wdg) """ td = table.add_cell() td.add_style("vertical-align: top") td.add_style("padding: 3px") title = "Documentation" description = '''TACTIC Documentation. * Project Setup Documentation<br/> <br/> * End User Documentation<br/> <br/> * Developer Documentation<br/> <br/> * System Administrator Documentation<br/> <br/> ''' image = "<img src='/context/images/getting_started_pipeline.png'/>" behavior = { 'type': 'click_up', 'cbjs_action': ''' spt.help.load_alias("main") ''' } doc_wdg = my.get_section_wdg(title, description, image, behavior) td.add(doc_wdg) """ tr, td = table.add_row_cell() td.add_style("font-size: 14px") td.add("<br/>") from misc_wdg import QuickLinksWdg quick_links_wdg = QuickLinksWdg() td.add(quick_links_wdg) #td = table.add_cell() #totals_wdg = my.get_totals_wdg() #td.add(totals_wdg) return top
def get_display(my): web = WebContainer.get_web() widget = Widget() html = HtmlElement("html") is_xhtml = False if is_xhtml: web.set_content_type("application/xhtml+xml") widget.add('''<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ''') html.add_attr("xmlns", "http://www.w3.org/1999/xhtml") #html.add_attr("xmlns:svg", "http://www.w3.org/2000/svg") # add the copyright widget.add( my.get_copyright_wdg() ) widget.add(html) # create the header head = HtmlElement("head") html.add(head) head.add('<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>\n') head.add('<meta http-equiv="X-UA-Compatible" content="IE=edge"/>\n') # Add the tactic favicon head.add('<link rel="shortcut icon" href="/context/favicon.ico" type="image/x-icon"/>') # add the css styling head.add(my.get_css_wdg()) # add the title in the header project = Project.get() project_code = project.get_code() project_title = project.get_value("title") if web.is_admin_page(): is_admin = " - Admin" else: is_admin = "" if project_code == 'admin': head.add("<title>TACTIC Site Admin</title>\n" ) else: head.add("<title>%s%s</title>\n" % (project_title, is_admin) ) # add the javascript libraries head.add( JavascriptImportWdg() ) # add the body body = my.body html.add( body ) # Add a NOSCRIPT tag block here to provide a warning message on browsers where 'Enable JavaScript' # is not checked ... TODO: clean up and re-style to make look nicer body.add( """ <NOSCRIPT> <div style="border: 2px solid black; background-color: #FFFF99; color: black; width: 600px; height: 70px; padding: 20px;"> <img src="%s" style="border: none;" /> <b>Javascript is not enabled on your browser!</b> <p>This TACTIC powered, web-based application requires JavaScript to be enabled in order to function. In your browser's options/preferences, please make sure that the 'Enable JavaScript' option is checked on, click OK to accept the settings change, and then refresh this web page.</p> </div> </NOSCRIPT> """ % ( IconWdg.get_icon_path("ERROR") ) ) # add the content if my.widgets: content_wdg = my.get_widget('content') else: content_wdg = Widget() my.add(content_wdg) body.add( content_wdg ) body.add_event('onload', 'spt.onload_startup(this)') if web.is_admin_page(): from tactic_branding_wdg import TacticCopyrightNoticeWdg branding = TacticCopyrightNoticeWdg(show_license_info=True) body.add(branding) # add the admin bar security = Environment.get_security() if not web.is_admin_page() and security.check_access("builtin", "view_site_admin", "allow"): div = DivWdg() body.add(div) body.add_style("padding-top: 21px") div.add_class("spt_admin_bar") div.add_style("height: 15px") div.add_style("padding: 3px 0px 3px 15px") #div.add_style("margin-bottom: -5px") div.add_style("position: fixed") div.add_style("top: 0px") div.add_style("left: 0px") div.add_style("opacity: 0.7") div.add_style("width: 100%") #div.add_gradient("background", "background2", 20, 10) div.add_style("background-color", "#000") div.add_style("color", "#FFF") div.add_style("z-index", "1000") div.add_class("hand") div.set_box_shadow("0px 5px 5px") # remove icon_div = DivWdg() div.add(icon_div) icon_div.add_style("float: right") icon_div.add_style("margin-right: 10px") icon_div.add_style("margin-top: -3px") icon_button = IconButtonWdg(title="Remove Admin Bar", icon=IconWdg.POPUP_WIN_CLOSE) icon_div.add(icon_button) icon_button.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var parent = bvr.src_el.getParent(".spt_admin_bar"); spt.behavior.destroy_element(parent); $(document.body).setStyle("padding-top", "0px"); ''' } ) div.add("<b>ADMIN >></b>") div.add_behavior( { 'type': 'listen', 'event_name': 'close_admin_bar', 'cbjs_action': ''' spt.behavior.destroy_element(bvr.src_el); $(document.body).setStyle("padding-top", "0px"); ''' } ) div.add_behavior( { 'type': 'mouseover', 'cbjs_action': ''' bvr.src_el.setStyle("opacity", 0.85) //new Fx.Tween(bvr.src_el).start('height', "30px"); ''' } ) div.add_behavior( { 'type': 'mouseout', 'cbjs_action': ''' bvr.src_el.setStyle("opacity", 0.7) //new Fx.Tween(bvr.src_el).start('height', "15px"); ''' } ) project_code = Project.get_project_code() div.add_behavior( { 'type': 'click_up', 'cbjs_action': ''' var url = "/tactic/%s/link/_startup"; window.open(url); ''' % project_code } ) # Add the script editor listener load_div = DivWdg() body.add(load_div) load_div.add_behavior( { 'type': 'listen', 'event_name': 'show_script_editor', 'cbjs_action': ''' var js_popup_id = "TACTIC Script Editor"; var js_popup = $(js_popup_id); if( js_popup ) { spt.popup.toggle_display( js_popup_id, false ); } else { spt.panel.load_popup(js_popup_id, "tactic.ui.app.ShelfEditWdg", {}, {"load_once": true} ); } '''} ) # deal with the palette defined in /index which can override the palette if my.kwargs.get("hash") == (): key = "index" search = Search("config/url") search.add_filter("url", "/%s/%%"%key, "like") search.add_filter("url", "/%s"%key) search.add_where("or") url = search.get_sobject() if url: xml = url.get_xml_value("widget") palette_key = xml.get_value("element/@palette") # look up palette the expression for index from pyasm.web import Palette palette = Palette.get() palette.set_palette(palette_key) colors = palette.get_colors() colors = jsondumps(colors) script = HtmlElement.script(''' var env = spt.Environment.get(); env.set_colors(%s); env.set_palette('%s'); ''' % (colors, palette_key) ) body.add(script) env = Environment.get() client_handoff_dir = env.get_client_handoff_dir(include_ticket=False, no_exception=True) client_asset_dir = env.get_client_repo_dir() login = Environment.get_login() user_name = login.get_value("login") user_id = login.get_id() login_groups = Environment.get_group_names() # add environment information script = HtmlElement.script(''' var env = spt.Environment.get(); env.set_project('%s'); env.set_user('%s'); env.set_user_id('%s'); var login_groups = '%s'.split('|'); env.set_login_groups(login_groups); env.set_client_handoff_dir('%s'); env.set_client_repo_dir('%s'); ''' % (Project.get_project_code(), user_name, user_id, '|'.join(login_groups), client_handoff_dir,client_asset_dir)) body.add(script) # add a global container for commonly used widgets div = DivWdg() body.add(div) div.set_id("global_container") # add in the app busy widget # find out if there is an override for this search = Search("config/url") search.add_filter("url", "/app_busy") url = search.get_sobject() if url: busy_div = DivWdg() div.add(busy_div) busy_div.add_class( "SPT_PUW" ) busy_div.add_styles( "display: none; position: absolute; z-index: 1000" ) busy_div.add_class("app_busy_msg_block") busy_div.add_style("width: 300px") busy_div.add_style("height: 100px") busy_div.add_style("padding: 20px") busy_div.add_color("background", "background3") busy_div.add_border() busy_div.set_box_shadow() busy_div.set_round_corners(20) busy_div.set_attr("id","app_busy_msg_block") # put the custom url here title_wdg = DivWdg() busy_div.add(title_wdg) title_wdg.add_style("font-size: 20px") title_wdg.add_class("spt_app_busy_title") busy_div.add("<hr/>") msg_div = DivWdg() busy_div.add(msg_div) msg_div.add_class("spt_app_busy_msg") else: from page_header_wdg import AppBusyWdg div.add( AppBusyWdg() ) # popup parent popup = DivWdg() popup.set_id("popup") div.add(popup) # create another general popup popup_div = DivWdg() popup_div.set_id("popup_container") popup_div.add_class("spt_panel") popup = PopupWdg(id="popup_template",destroy_on_close=True) popup_div.add(popup) div.add(popup_div) # popup parent inner_html_div = DivWdg() inner_html_div.set_id("inner_html") div.add(inner_html_div) # add in a global color from tactic.ui.input import ColorWdg color = ColorWdg() div.add(color) # add in a global notify wdg from notify_wdg import NotifyWdg widget.add(NotifyWdg()) return widget
def get_display(my): my.sk = str(my.kwargs.get('sk')) my.code = my.sk.split('code=')[1] my.order_sk = str(my.kwargs.get('parent_sk')) order_code = my.order_sk.split('code=')[1] my.parent_sid = str(my.kwargs.get('parent_sid')) 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 '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 '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 my.parent_sk = my.order_sk if 'main_obj' in my.kwargs.keys(): main_obj = my.kwargs.get('main_obj') else: main_search = Search("twog/title") main_search.add_filter('code', my.code) main_obj = main_search.get_sobject() my.search_id = main_obj.get_value('id') proj_search = Search("twog/proj") proj_search.add_filter('title_code', my.code) proj_search.add_order_by('order_in_pipe') projs = proj_search.get_sobjects() table = Table() table.add_attr('cellpadding', '0') table.add_attr('cellspacing', '0') table.add_attr('class', 'TitleRow_%s' % my.code) table.add_style('border-collapse', 'separate') table.add_style('border-spacing', '25px 0px') 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_style('color: #00056a;') table.add_style('background-color: %s;' % my.off_color) table.add_style('width: 100%;') table.add_row() epis = '' full_title_name = main_obj.get_value('title') if main_obj.get_value('episode'): epis = ' Episode: %s' % main_obj.get_value('episode') full_title_name = '%s: %s' % (full_title_name, main_obj.get_value('episode')) title_cell = table.add_cell('<b><u>Title: %s%s</u></b>' % (main_obj.get_value('title'), epis)) title_cell.add_attr('nowrap', 'nowrap') title_cell.add_style('cursor: pointer;') title_cell.add_behavior(get_panel_change_behavior('twog/title', my.code, my.sk, my.order_sk, my.title, '', 'builder/refresh_from_save', '', my.parent_sk, '%s: %s' % (main_obj.get_value('title'), main_obj.get_value('episode')), user_is_scheduler)) due_cell = table.add_cell('Due: %s' % fix_date(main_obj.get_value('due_date')).split(' ')[0]) due_cell.add_attr('nowrap', 'nowrap') pipe_disp = main_obj.get_value('pipeline_code') if 'XsX' in pipe_disp: pipe_disp = 'Not Assigned' pipe_cell = table.add_cell('Pipeline: %s' % pipe_disp) pipe_cell.add_attr('nowrap', 'nowrap') long_cell1 = table.add_cell(' ') long_cell1.add_attr('align', 'right') long_cell1.add_style('width: 100%') if my.small: select_check = CustomCheckboxWdg(name='select_%s' % my.code, value_field=my.code, checked='false', dom_class='ob_selector', parent_table="TitleRow_%s" % my.code, normal_color=my.off_color, selected_color=my.on_color, code=my.code, ntype='title', search_key=my.sk, additional_js=get_selected_color_behavior(my.code, 'TitleRow', my.on_color, my.off_color)) table.add_cell(select_check) elif user_is_scheduler or 'onboarding' in my.groups_str: xb = table.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, 'OrderTable', '%s: %s' % (main_obj.get_value('title'), main_obj.get_value('episode')), my.order_sk, my.is_master)) table.add_row() long_cell2 = table.add_cell('Code: %s' % my.code) long_cell2.add_style('width: 100%') status = main_obj.get_value('status') status = status.strip(' \t\n\r') stat_cell = table.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]) stat_cell.add_style('width: 100%') long_cell22 = table.add_cell('Client Status: %s' % main_obj.get_value('client_status')) long_cell22.add_attr('nowrap', 'nowrap') long_cell22.add_style('width: 100%') if my.small: title_cell.add_style('font-size: 8px;') due_cell.add_style('font-size: 8px;') pipe_cell.add_style('font-size: 8px;') long_cell1.add_style('font-size: 8px;') long_cell2.add_style('font-size: 8px;') long_cell22.add_style('font-size: 8px;') stat_cell.add_style('font-size: 8px;') else: table.add_row() bottom_buttons = Table() bottom_buttons.add_row() deliverable_count = DeliverableCountWdg(title_code=my.code, order_sk=my.order_sk, full_title=full_title_name) d_launcher = bottom_buttons.add_cell(deliverable_count) d_launcher.add_attr('class', 'deliverable_count_%s' % my.code) d_launcher.add_attr('valign', 'bottom') bottom_buttons.add_row() prereq_count = PreReqCountWdg(sob_code=my.code, sob_st='twog/title', sob_sk=my.sk, prereq_st='twog/title_prereq', sob_name='%s %s' % (main_obj.get_value('title'), main_obj.get_value('episode')), pipeline=main_obj.get_value('pipeline_code'), order_sk=my.order_sk) prereq_launcher = bottom_buttons.add_cell(prereq_count) prereq_launcher.add_attr('class', 'prereq_count_%s' % my.code) prereq_launcher.add_attr('valign', 'bottom') if not my.is_master and user_is_scheduler: in_bigboard = 'Nope' if main_obj.get_value('bigboard') in [True, 'true', 't', 'T', 1]: in_bigboard = 'Yep' bbo = BigBoardSelectWdg(search_type='twog/title', code=my.code, in_bigboard=in_bigboard) bboc = bottom_buttons.add_cell(bbo) bboc.add_attr('align', 'right') adder = ButtonSmallNewWdg(title="Add A Project", icon=CustomIconWdg.icons.get('ADD')) adder.add_behavior(get_multi_add_projs_behavior(my.order_sk, my.sk)) add = bottom_buttons.add_cell(adder) add.add_attr('align', 'right') qc_launcher = QCReportLauncherWdg(code=my.code) qcl = bottom_buttons.add_cell(qc_launcher) qcl.add_attr('align', 'right') if user_is_scheduler: stop_button = ButtonSmallNewWdg(title='Deactivate Title - Remove from Operator Views', icon='/context/icons/custom/stopsmall.png') stop_button.add_behavior(get_deactivate_behavior(my.code)) sb = bottom_buttons.add_cell(stop_button) sb.add_attr('id', 'stop_button_%s' % my.code) sb.add_attr('align', 'right') mastering_icon = '/context/icons/custom/mastering_gray.png' mastering_text = "Currently Doesn't Require QC Mastering. Change?" if main_obj.get('requires_mastering_qc') not in ['False', 'false', '0', None, False]: mastering_icon = '/context/icons/custom/mastering_lilac.png' mastering_text = "Currently Requires QC Mastering. Change?" mastering_button = ButtonSmallNewWdg(title=mastering_text, icon=mastering_icon) mastering_button.add_behavior(get_set_mastering(main_obj.get_value('code'), my.order_sk)) mb = bottom_buttons.add_cell(mastering_button) mb.add_attr('id', 'mastering_button_%s' % my.code) mb.add_attr('align', 'right') face_icon = CustomIconWdg.icons.get('GRAY_BOMB') face_text = "All is Ok - Set External Rejection?" if main_obj.get('is_external_rejection') == 'true': face_icon = CustomIconWdg.icons.get('RED_BOMB') face_text = "This is an External Rejection!!!" panic_button = ButtonSmallNewWdg(title=face_text, icon=face_icon) panic_button.add_behavior(get_set_external_rejection(main_obj.get_value('code'), my.order_sk)) pb = bottom_buttons.add_cell(panic_button) pb.add_attr('id', 'panic_button_%s' % my.code) pb.add_attr('align', 'right') redo_icon = '/context/icons/custom/history_gray.png' redo_text = "This is not set as a Redo Title" if main_obj.get('redo') not in ['False', 'false', '0', None, False]: redo_icon = '/context/icons/custom/history.png' redo_text = "Currently marked as a Redo Title. Change?" redo_button = ButtonSmallNewWdg(title=redo_text, icon=redo_icon) redo_button.add_behavior(get_set_redo(main_obj.get_value('code'), my.order_sk)) rb = bottom_buttons.add_cell(redo_button) rb.add_attr('id', 'redo_button_%s' % my.code) rb.add_attr('align', 'right') if main_obj.get('repurpose'): repurpose_button_text = 'Title is set as a "Repurpose", do you want to remove this?' else: repurpose_button_text = 'Set title as a "Repurpose"?' repurpose_button = ButtonSmallNewWdg(title=repurpose_button_text, icon=CustomIconWdg.icons.get('REPURPOSE')) repurpose_button.add_behavior(set_repurpose(main_obj.get_value('code'), my.order_sk, main_obj.get_value('repurpose'))) repurpose_button_cell = bottom_buttons.add_cell(repurpose_button) repurpose_button_cell.add_attr('id', 'repurpose_button_{0}'.format(my.code)) repurpose_button_cell.add_attr('align', 'right') if main_obj.get('imf'): imf_button_text = 'Title is set as an IMF order, do you want to remove this?' else: imf_button_text = 'Set title as an IMF order?' imf_button = ButtonSmallNewWdg(title=imf_button_text, icon=CustomIconWdg.icons.get('IMF')) imf_button.add_behavior(set_imf(main_obj.get_value('code'), my.order_sk, main_obj.get_value('imf'))) imf_button_cell = bottom_buttons.add_cell(imf_button) imf_button_cell.add_attr('id', 'imf_button_{0}'.format(my.code)) imf_button_cell.add_attr('align', 'right') prio_reset = ButtonSmallNewWdg(title="Reset Dept Priorities", icon=CustomIconWdg.icons.get('UNDO')) prio_reset.add_behavior(get_reset_dept_prios(main_obj.get_value('code'))) pr = bottom_buttons.add_cell(prio_reset) pr.add_attr('align', 'right') sts_launcher = ButtonSmallNewWdg(title="Set Status Triggers", icon=CustomIconWdg.icons.get('LINK')) sts_launcher.add_behavior(get_launch_title_proj_sts_behavior(main_obj.get_value('code'))) stsl = bottom_buttons.add_cell(sts_launcher) stsl.add_attr('align', 'right') source_inspector = ButtonSmallNewWdg(title="Inspect Sources", icon=CustomIconWdg.icons.get('SOURCE_PORTAL')) source_inspector.add_behavior(get_source_inspector_behavior(my.sk, '%s: %s' % (main_obj.get_value('title'), main_obj.get_value('episode')))) si = bottom_buttons.add_cell(source_inspector) si.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('title'))) 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/title', my.search_id, my.parent_sid, my.width, my.height, main_obj.get_value('pipeline_code'), main_obj.get_search_key(), 'TitleRow', '%s: %s' % (main_obj.get_value('title'), main_obj.get_value('episode')), my.order_sk)) bottom_buttons.add_cell(pipe_button) request_pipeline_button = ButtonSmallNewWdg(title="Request a Pipeline", icon=CustomIconWdg.icons.get('PROCESS')) request_pipeline_button.add_behavior(request_pipeline_behavior(my.sk)) bottom_buttons.add_cell(request_pipeline_button) if my.is_master and (user_is_scheduler or 'onboarding' in my.groups_str): templer = ButtonSmallNewWdg(title="Template All", icon=CustomIconWdg.icons.get('TEMPLATE_DOWN')) templer.add_behavior(get_template_all_behavior(my.order_sk, my.code, my.is_master_str)) tem = bottom_buttons.add_cell(templer) tem.add_attr('align', 'right') tem.add_style('cursor: pointer;') long_cell3 = table.add_cell(bottom_buttons) long_cell3.add_attr('align', 'right') long_cell3.add_attr('valign', 'bottom') long_cell3.add_attr('colspan', '3') long_cell3.add_style('width: 100%') sources = SourcesRow(title_code=my.code, title_sk=my.sk, order_sk=my.order_sk) src_row = table.add_row() src_row.add_attr('class', 'sources_row') src_cell = table.add_cell(sources) src_cell.add_attr('colspan', '6') src_cell.add_attr('class', 'sources_%s' % my.sk) src_cell.add_attr('order_sk', my.order_sk) if main_obj.get_value('is_external_rejection') == 'true': table.add_row() explanation_cell = table.add_cell('<u><b>External Rejection Reason:</b></u> %s' % main_obj.get('external_rejection_reason')) explanation_cell.add_attr('colspan', '5') bottom = Table() bottom.add_attr('width', '100%') bottom.add_attr('cellpadding', '0') bottom.add_attr('cellspacing', '0') for proj in projs: proj_sk = proj.get_search_key() proj_row = bottom.add_row() proj_row.add_attr('class', 'row_%s' % proj_sk) proj_obj = ProjRow(sk=proj_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=proj) proj_cell = bottom.add_cell(proj_obj) proj_cell.add_attr('width', '100%') proj_cell.add_attr('sk', proj_sk) proj_cell.add_attr('order_sk', my.order_sk) proj_cell.add_attr('parent_sk', my.sk) proj_cell.add_attr('parent_sid', my.search_id) proj_cell.add_attr('call_me', proj.get_value('process')) proj_cell.add_attr('my_class', 'ProjRow') proj_cell.add_attr('display_mode', my.disp_mode) proj_cell.add_attr('class', 'cell_%s' % proj_sk) tab2ret = Table() tab2ret.add_attr('width', '100%') top_row = tab2ret.add_row() top_row.add_attr('class', 'top_%s' % my.sk) 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
def get_display(my): my.work_order_sk = str(my.kwargs.get('work_order_sk')) my.work_order_code = str(my.kwargs.get('work_order_code')) my.client_code = str(my.kwargs.get('client_code')) my.order_sk = str(my.kwargs.get('order_sk')) order_code = my.order_sk.split('code=')[1] overhead = Table() overhead.add_attr('class', 'out_overhead_%s' % my.work_order_code) overhead.add_attr('client_code', my.client_code) wo_search = Search("twog/work_order") wo_search.add_filter('code', my.work_order_code) work_order = wo_search.get_sobject() delivs_search = Search("twog/work_order_deliverables") delivs_search.add_filter('work_order_code', my.work_order_code) delivs = delivs_search.get_sobjects() inter_search = Search("twog/work_order_intermediate") inter_search.add_filter('work_order_code', my.work_order_code) inters = inter_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 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' table = Table() table.add_row() table.add_cell('<font size="4"><b><u>Intermediates</u></b></font>') add_inter = table.add_cell('<input type="button" value="Add Intermediate File"/>') add_inter.add_attr('nowrap','nowrap') add_inter.add_style('cursor: pointer;') add_inter.add_behavior(get_add_inter_behavior(my.work_order_code, my.client_code, my.is_master_str, my.order_sk)) inters_tbl = Table() for inter1 in inters: i_search = Search("twog/intermediate_file") i_search.add_filter('code',inter1.get_value('intermediate_file_code')) inter = i_search.get_sobject() inters_tbl.add_row() if user_is_scheduler: killer = inters_tbl.add_cell(my.x_butt) killer.add_style('cursor: pointer;') killer.add_behavior(get_intermediate_killer_behavior(inter1.get_value('code'), inter.get_value('title'), my.work_order_code, my.is_master_str, my.order_sk)) alabel = inters_tbl.add_cell('Intermediate: ') alabel.add_attr('align','center') popper = inters_tbl.add_cell('<u>%s</u>' % inter.get_value('title')) popper.add_attr('nowrap','nowrap') popper.add_style('cursor: pointer;') popper.add_behavior(get_open_intermediate_behavior(inter.get_value('code'), my.work_order_code, my.client_code, my.order_sk)) if str(inter1.get_value('satisfied')) == 'True': check_val = 'true' else: check_val = 'false' checkbox = CustomCheckboxWdg(name='satisfied_%s' % inter.get_value('code'), value_field=inter.get_value('code'), checked=check_val, dom_class='inter_selector', code=inter.get_value('code'), additional_js=get_change_inter_satisfied_behavior(inter1.get_value('code'), my.work_order_code, my.client_code, str(inter1.get_value('satisfied')), my.order_sk)) ck = inters_tbl.add_cell(checkbox) ck.add_attr('align','center') inters_tbl.add_cell(' ') if my.is_master: if inter.get_value('intermediate_file_templ_code') in [None,'']: template_button = ButtonSmallNewWdg(title="Template This Intermediate File", icon=CustomIconWdg.icons.get('TEMPLATE')) template_button.add_behavior(get_template_intermediate_behavior(inter.get_value('code'), my.work_order_code, my.order_sk)) else: template_button = '<img border="0" style="vertical-align: middle" title="Templated" name="Templated" src="/context/icons/silk/tick.png">' tb = inters_tbl.add_cell(template_button) tb.add_class('inter_templ_%s' % inter.get_value('code')) table.add_row() intr = table.add_cell(inters_tbl) intr.add_attr('colspan','2') table.add_row() table.add_cell('<hr/>') table.add_row() table.add_cell('<font size="4"><b><u>Permanents</u></b></font>') add_delv = table.add_cell('<input type="button" value="Add Permanent Element"/>') add_delv.add_style('cursor: pointer;') add_delv.add_behavior(get_add_deliverable_behavior(my.work_order_code, my.client_code, my.order_sk)) delv_tbl = Table() client_search = Search("twog/client") client_search.add_order_by('name desc') clients = client_search.get_sobjects() client_sel = '<select class="deliver_to_DELIV_CODE"><option value="">--Select--</option>' for client in clients: client_sel = '%s<option value="%s">%s</option>' % (client_sel, client.get_value('name'), client.get_value('name')) client_sel = '%s</select>' % client_sel for deliv1 in delivs: d_search = Search("twog/source") d_search.add_filter('code',deliv1.get_value('deliverable_source_code')) deliv = d_search.get_sobject() deliv_name = '%s, Episode: %s, Type: %s' % (deliv.get_value('title'), deliv.get_value('episode'), deliv.get_value('source_type')) delv_tbl.add_row() if user_is_scheduler: killer = delv_tbl.add_cell(my.x_butt) killer.add_style('cursor: pointer;') killer.add_behavior(get_deliverable_killer_behavior(deliv1.get_value('code'), my.work_order_code, deliv1.get_value('title_code'), deliv.get_value('code'), '%s (%s: %s)' % (deliv1.get_value('name'), deliv.get_value('title'), deliv.get_value('episode')), my.is_master_str, my.order_sk)) alabel = delv_tbl.add_cell('Permanent: ') alabel.add_attr('align','center') popper = delv_tbl.add_cell('<u>%s</u>' % deliv.get_value('title')) popper.add_attr('nowrap','nowrap') popper.add_style('cursor: pointer;') popper.add_behavior(get_open_deliverable_behavior(deliv.get_value('code'), my.work_order_code, deliv1.get_value('title_code'), my.client_code, my.order_sk)) if str(deliv1.get_value('satisfied')) == 'True': check_val = 'true' else: check_val = 'false' checkbox = CustomCheckboxWdg(name='satisfied_%s' % deliv.get_value('code'), value_field=deliv.get_value('code'), checked=check_val, dom_class='deliv_selector', code=deliv.get_value('code'), additional_js=get_change_deliverable_satisfied_behavior(deliv1.get_value('code'), my.work_order_code, deliv1.get_value('title_code'), str(deliv1.get_value('satisfied')), my.client_code, my.order_sk)) ck = delv_tbl.add_cell(checkbox) ck.add_attr('align','center') delv_tbl.add_cell(' ') if my.is_master: if deliv.get_value('templ_code') in [None,'']: template_button = ButtonSmallNewWdg(title="Template This Intermediate File", icon=CustomIconWdg.icons.get('TEMPLATE')) template_button.add_behavior(get_template_deliverable_behavior(deliv1.get_value('code'), work_order.get_value('work_order_templ_code'), deliv1.get_value('deliverable_source_code'), my.work_order_code)) else: template_button = '<img border="0" style="vertical-align: middle" title="Templated" name="Templated" src="/context/icons/silk/tick.png">' tb = delv_tbl.add_cell(template_button) tb.add_class('deliverable_templ_%s' % deliv1.get_value('code')) bot_delv = Table() bot_delv.add_row() bot_delv.add_cell('Name: ') bot_delv.add_cell('<input type="text" class="deliv_name_%s" value="%s"/>' % (deliv1.get_value('code'), deliv1.get_value('name'))) bot_delv.add_row() nw = bot_delv.add_cell('Deliver To: ') nw.add_attr('nowrap','nowrap') this_client_sel = client_sel.replace('DELIV_CODE',deliv1.get_value('code')) this_client_sel = this_client_sel.replace('value="%s"' % deliv1.get_value('deliver_to'), 'value="%s" selected="selected"' % deliv1.get_value('deliver_to')) bot_delv.add_cell(this_client_sel) bot_delv.add_row() bot_delv.add_cell('Attn: ') bot_delv.add_cell('<input type="text" class="deliv_attn_%s" value="%s"/>' % (deliv1.get_value('code'), deliv1.get_value('attn'))) bot_delv.add_row() save_cell = bot_delv.add_cell('<input type="button" value="Save Permanent Element Info"/>') save_cell.add_behavior(get_save_deliv_info_behavior(deliv1.get_value('code'), my.work_order_code, deliv1.get_value('title_code'), my.client_code, my.is_master_str, my.order_sk)) delv_tbl.add_row() bot = delv_tbl.add_cell(bot_delv) bot.add_attr('colspan','4') table.add_row() delv = table.add_cell(delv_tbl) delv.add_attr('colspan', '2') overhead.add_row() oh_cell = overhead.add_cell(table) oh_cell.add_attr('class','out_list_cell') return overhead
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.parent_sid = str(my.kwargs.get('parent_sid')) my.order_sk = str(my.kwargs.get('order_sk')) order_code = my.order_sk.split('code=')[1] 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 in [True, 'true', 't', 1]: my.is_master = True my.is_master_str = '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 = 'false' 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/work_order") main_search.add_filter('code', my.code) main_obj = main_search.get_sobject() parent_obj = None if 'parent_obj' in my.kwargs.keys(): parent_obj = my.kwargs.get('parent_obj') else: parent_search = Search("twog/proj") parent_search.add_filter('code',main_obj.get_value('proj_code')) parent_obj = parent_search.get_sobject() eu_search = Search("twog/equipment_used") eu_search.add_filter('work_order_code', my.code) eus = eu_search.get_sobjects() task_search = Search("sthpw/task") task_search.add_filter('code',main_obj.get_value('task_code')) task = task_search.get_sobjects() my.search_id = main_obj.get_value('id') due_date = '' start_date = '' end_date = '' status = '' assigned = '' priority = '' task_sk = '' active_bool = False active_status = '' task_exists = False if len(task) > 0: task = task[0] task_exists = True due_date = task.get_value('bid_end_date') start_date = task.get_value('actual_start_date') end_date = task.get_value('actual_end_date') status = task.get_value('status') assigned = task.get_value('assigned') priority = task.get_value('priority') task_sk = task.get_search_key() active_bool = task.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>' bgcol = my.off_color if main_obj.get_value('work_group') in [None,''] or main_obj.get_value('estimated_work_hours') in [None,'']: bgcol = '#FFFFFF' if assigned not in [None,'']: assigned_s = Search('sthpw/login') assigned_s.add_filter('location', 'internal') assigned_s.add_filter('login', assigned) assigned_o = assigned_s.get_sobject() assigned = '' if assigned_o: assigned = '%s %s' % (assigned_o.get_value('first_name'), assigned_o.get_value('last_name')) table = Table() table.add_attr('id', main_obj.get_value('code')) table.add_attr('cellpadding', '0') table.add_attr('cellspacing', '0') table.add_attr('class', 'WorkOrderRow_%s' % my.code) table.add_attr('width', '100%') table.add_style('border-collapse', 'separate') table.add_style('border-spacing', '25px 0px') table.add_style('color: #373a6a;') table.add_style('background-color: %s;' % bgcol) 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') row1 = table.add_row() row1.add_attr('width', '100%') row1.add_style('width: 100%;') wo_cell = table.add_cell('<b><u>Work Order: %s</u></b>' % main_obj.get_value('process')) wo_cell.add_attr('nowrap', 'nowrap') wo_cell.add_style('cursor: pointer;') wo_cell.add_behavior(get_panel_change_behavior('twog/work_order', my.code, my.sk, my.order_sk, 'Work Order', main_obj.get_value('work_order_templ_code'), 'builder/refresh_from_save', main_obj.get_value('task_code'), my.parent_sk, main_obj.get_value('process'), user_is_scheduler)) stat_cell = table.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]) priority_cell = table.add_cell('Priority: %s' % priority) priority_cell.add_attr('nowrap', 'nowrap') assigned_cell = table.add_cell('Assigned to: %s' % assigned) assigned_cell.add_attr('nowrap', 'nowrap') due_cell = table.add_cell('Due: %s' % fix_date(due_date)) 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="WorkOrderRow_%s" % my.code, process=main_obj.get_value('process'), work_group=main_obj.get_value('work_group'), proj_code=main_obj.get_value('proj_code'), title_code=main_obj.get_value('title_code'), order_code=order_code, task_code=main_obj.get_value('task_code'), normal_color=my.off_color, selected_color=my.on_color, code=my.code, ntype='work_order', search_key=my.sk, task_sk=task_sk, additional_js=get_selected_color_behavior(my.code, 'WorkOrderRow', my.on_color, my.off_color)) cb = top_buttons.add_cell(select_check) elif user_is_scheduler: xb = top_buttons.add_cell("<img src='/context/icons/common/BtnKill.gif' title='Delete' name='Delete'/>") xb.add_attr('align', 'right') xb.add_style('cursor: pointer;') xb.add_behavior(get_killer_behavior(my.sk, my.parent_sk, 'ProjRow', 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_attr('colspan', '1') long_cell1.add_style('width: 100%') table.add_row() ccel = table.add_cell('Code: %s' % my.code) ccel.add_attr('nowrap', 'nowrap') start_cell = table.add_cell('Start: %s' % fix_date(start_date)) start_cell.add_attr('nowrap', 'nowrap') end_cell = table.add_cell('End: %s' % fix_date(end_date)) end_cell.add_attr('nowrap', 'nowrap') 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%;") if my.small: wo_cell.add_style('font-size: 8px;') stat_cell.add_style('font-size: 8px;') priority_cell.add_style('font-size: 8px;') assigned_cell.add_style('font-size: 8px;') due_cell.add_style('font-size: 8px;') long_cell1.add_style('font-size: 8px;') ccel.add_style('font-size: 8px;') start_cell.add_style('font-size: 8px;') end_cell.add_style('font-size: 8px;') active_cell.add_style('font-size: 8px;') else: table.add_row() bottom_buttons = Table() bottom_buttons.add_row() bbl = Table() bbl.add_row() ins = bbl.add_cell(main_obj.get_value('instructions').replace('<', '<').replace('>', '>')) ins.add_attr('align', 'left') ins.add_attr('colspan', '5') ins.add_attr('width', '100%') empt = bbl.add_cell(' ') empt.add_attr('width', '100%') bbr = Table() bbr.add_row() prereq_count = PreReqCountWdg(sob_code=my.code, sob_st='twog/work_order', sob_sk=my.sk, prereq_st='twog/work_order_prereq', sob_name=main_obj.get_value('process'), pipeline='nothing', order_sk=my.order_sk) prereq_launcher = bbr.add_cell(prereq_count) prereq_launcher.add_attr('class','prereq_count_%s' % my.code) prereq_launcher.add_attr('valign','bottom') prereq_launcher.add_attr('colspan','2') if main_obj.get_value('creation_type') == 'hackup' and user_is_scheduler: 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 = bbr.add_cell(hack_edit) he.add_attr('align','right') he.add_attr('valign','bottom') else: blah = bbr.add_cell('') if user_is_scheduler: error_edit = ButtonSmallNewWdg(title="Report Error", icon=CustomIconWdg.icons.get('REPORT_ERROR')) error_edit.add_behavior(get_add_wo_error_behavior(my.order_sk, my.user, my.code)) uno = bbr.add_cell(' ') er = bbr.add_cell(error_edit) er.add_attr('align', 'right') er.add_attr('valign', 'bottom') er.add_attr('colspan', '3') er.add_attr('width', '100%') bbr.add_row() if not my.is_master and user_is_scheduler and task_exists: indie_button = IndieBigBoardSelectWdg(search_key=task.get_search_key(), indie_bigboard=task.get_value('indie_bigboard'), title_code=parent_obj.get_value('title_code'), lookup_code=my.code) indie = bbr.add_cell(indie_button) indie.add_attr('align', 'right') indie.add_attr('valign', 'bottom') big_button = BigBoardSingleWOSelectWdg(search_key=task.get_search_key(), bigboard=task.get_value('bigboard'), title_code=parent_obj.get_value('title_code'), lookup_code=my.code) bbw = bbr.add_cell(big_button) bbw.add_attr('align', 'right') bbw.add_attr('valign', 'bottom') print_button = WorkOrderPrintLauncherWdg(work_order_code=my.code) prnt = bbr.add_cell(print_button) prnt.add_attr('align', 'right') prnt.add_attr('valign', 'bottom') upload = ButtonSmallNewWdg(title="Upload", icon=CustomIconWdg.icons.get('PUBLISH')) upload.add_behavior(get_upload_behavior(my.sk)) up = bbr.add_cell(upload) up.add_attr('align', 'right') up.add_attr('valign', 'bottom') note_adder = ButtonSmallNewWdg(title="Add Note", icon=CustomIconWdg.icons.get('NOTE_ADD')) note_adder.add_behavior(get_launch_note_behavior(my.parent_sk, parent_obj.get_value('process'))) nadd = bbr.add_cell(note_adder) nadd.add_attr('align', 'right') nadd.add_attr('valign', 'bottom') nadd.add_style('cursor: pointer;') if user_is_scheduler: add_eq_used_butt = ButtonSmallNewWdg(title="Add Equipment", icon=CustomIconWdg.icons.get('EQUIPMENT_ADD')) add_eq_used_butt.add_behavior(get_eu_add_behavior(main_obj.get_value('process'), main_obj.get_search_key(), main_obj.get_value('code'), my.order_sk)) eu_adder = bbr.add_cell(add_eq_used_butt) eu_adder.add_attr('width','100%') eu_adder.add_attr('align', 'right') eu_adder.add_attr('valign', 'bottom') eu_adder.add_style('cursor: pointer;') source_portal = ButtonSmallNewWdg(title="Passed in Result(s) or Source(s)", icon=CustomIconWdg.icons.get('SOURCE_PORTAL')) source_portal.add_behavior(get_launch_source_portal_behavior(main_obj.get_value('process'), main_obj.get_search_key(), main_obj.get_value('code'), parent_obj.get_value('pipeline_code'), my.is_master_str, my.order_sk)) sp = bbr.add_cell(source_portal) sp.add_attr('align', 'right') sp.add_attr('valign', 'bottom') file_add = ButtonSmallNewWdg(title="Intermediate File(s) or Permanent Element(s)", icon=CustomIconWdg.icons.get('FILE_ADD')) file_add.add_behavior(get_launch_out_files_behavior(main_obj.get_value('process'), main_obj.get_search_key(), main_obj.get_value('code'), my.order_sk)) fa = bbr.add_cell(file_add) fa.add_attr('align', 'right') fa.add_attr('valign', 'bottom') if my.is_master: if main_obj.get_value('templ_me') == True: templ_icon = CustomIconWdg.icons.get('CHECK') templ_title = "This is the Templating Work Order" else: templ_icon = CustomIconWdg.icons.get('TEMPLATE') templ_title = "Use This as Template for Parent Pipeline" templ_button = ButtonSmallNewWdg(title=templ_title, icon=templ_icon) if main_obj.get_value('templ_me') == False: templ_button.add_behavior(get_templ_wo_behavior(main_obj.get_value('templ_me'), main_obj.get_value('work_order_templ_code'), main_obj.get_search_key(), my.order_sk)) templ_butt = bbr.add_cell(templ_button) templ_butt.add_attr('class', 'templ_butt_%s' % my.sk) templ_butt.add_attr('width', '100%') templ_butt.add_attr('align', 'right') templ_butt.add_attr('valign', 'bottom') bl = bottom_buttons.add_cell(bbl) bl.add_attr('valign', 'bottom') bl.add_attr('align', 'left') bl.add_attr('width', '100%') br = bottom_buttons.add_cell(bbr) br.add_attr('valign', 'bottom') bbs = table.add_cell(bottom_buttons) bbs.add_attr('width', '100%') bbs.add_attr('align', 'left') bbs.add_attr('valign', 'bottom') if user_is_scheduler: src_row = table.add_row() src_row.add_attr('class', 'wo_sources_row') wos = WorkOrderSourcesRow(work_order_code=my.code, work_order_sk=my.sk, order_sk=my.order_sk) wos_cell = table.add_cell(wos) wos_cell.add_attr('colspan', '4') wos_cell.add_attr('class', 'wo_sources_%s' % my.sk) bottom = Table() bottom.add_attr('width', '100%') bottom.add_attr('cellpadding', '0') bottom.add_attr('cellspacing', '0') for eu in eus: eu_sk = eu.get_search_key() if eu.get_value('client_code') in [None,'']: my.server.update(eu_sk, {'client_code': main_obj.get_value('client_code')}, triggers=False) eu_row = bottom.add_row() eu_row.add_attr('class', 'EquipmentUsedRowRow row_%s' % eu_sk) eu_obj = EquipmentUsedRow(sk=eu_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=eu) eu_cell = bottom.add_cell(eu_obj) eu_cell.add_attr('width', '100%') eu_cell.add_attr('sk', eu_sk) eu_cell.add_attr('order_sk', my.order_sk) eu_cell.add_attr('parent_sk', my.sk) eu_cell.add_attr('parent_sid', my.search_id) eu_cell.add_attr('call_me', eu.get_value('name')) eu_cell.add_attr('wot_code', main_obj.get_value('work_order_templ_code')) eu_cell.add_attr('my_class', 'EquipmentUsedRow') eu_cell.add_attr('class', 'cell_%s' % eu_sk) tab2ret = Table() tab2ret.add_attr('width', '100%') top_row = tab2ret.add_row() top_row.add_attr('class', 'top_%s' % my.sk) tab2ret.add_cell(table) bot_row = tab2ret.add_row() if not open_bottom: bot_row.add_style('display: none;') else: bot_row.add_style('display: table-row;') bot_row.add_attr('class', 'bot_%s' % my.sk) bot = tab2ret.add_cell(bottom) bot.add_style('padding-left: 40px;') return tab2ret
def main(server=None, input=None): """ The main function of the custom script. The entire script was copied and pasted into the body of the try statement in order to add some error handling. It's all legacy code, so edit with caution. :param server: the TacticServerStub object :param input: a dict with data like like search_key, search_type, sobject, and update_data :return: None """ if not input: input = {} try: # CUSTOM_SCRIPT00063 # Matthew Tyler Misenhimer # This was made to handle new snapshot insertions (uploads) and notify relevant people via email about the new upload # Do Not send external if location is internal def make_right_code_ending(sid): ending = str(sid) ending_len = len(ending) if ending_len < 5: zeros = 5 - ending_len for num in range (0, zeros): ending = '0%s' % ending return ending def make_note_code_ending(sid): ending = str(sid) ending_len = len(ending) if ending_len < 8: zeros = 8 - ending_len for num in range (0, zeros): ending = '0%s' % ending return ending def make_timestamp(): import datetime now = datetime.datetime.now() return now.strftime("%Y-%m-%d %H:%M:%S") def get_time_date_dict(str_time): pre_split = str_time.split('.')[0] first_split = pre_split.split(' ') date = first_split[0] time = first_split[1] date_split = date.split('-') dt = {} dt['year'] = int(date_split[0]) dt['month'] = int(date_split[1]) dt['day'] = int(date_split[2]) dt['date'] = date dt['time'] = time time_split = time.split(':') dt['hour'] = int(time_split[0]) dt['minute'] = int(time_split[1]) dt['second'] = int(time_split[2]) dt['big_time'] = float((dt['hour'] * 3600) + (dt['minute'] * 60) + dt['second']) return dt def compare_dt_dicts(dt1, dt2): # This is rough. Don't use it for anything else. Should work for this though. difference = 0 newest = -1 dt1_bignum = float(float((dt1['year'] - 2000) * 365 * 24 * 3600) + float((dt1['month'] - 1) * 31 * 24 * 3600) + float((dt1['day'] - 1) * 24 * 3600) + dt1['big_time']) dt2_bignum = float(float((dt2['year'] - 2000) * 365 * 24 * 3600) + float((dt2['month'] - 1) * 31 * 24 * 3600) + float((dt2['day'] - 1) * 24 * 3600) + dt2['big_time']) difference = dt2_bignum - dt1_bignum if difference < 0: newest = 0 else: newest = 1 return [difference, newest] def fix_date(date): #This is needed due to the way Tactic deals with dates (using timezone info), post v4.0 from pyasm.common import SPTDate return_date = '' date_obj = SPTDate.convert_to_local(date) if date_obj not in [None,'']: return_date = date_obj.strftime("%Y-%m-%d %H:%M") return return_date def fix_note_chars(note): if isinstance(note, bool): note2 = 'False' if note: note2 = 'True' note = note2 else: import sys from json import dumps as jsondumps if note not in [None,'']: if sys.stdout.encoding: note = note.decode(sys.stdout.encoding) note = jsondumps(note) note = note.replace('||t',' ') note = note.replace('\\\\t',' ') note = note.replace('\\\t',' ') note = note.replace('\\t',' ') note = note.replace('\t',' ') note = note.replace('\\"','"') note = note.replace('\"','"') note = note.replace('||n','<br/>') note = note.replace('\\\\n','<br/>') note = note.replace('\\\n','<br/>') note = note.replace('\\n','<br/>') note = note.replace('\n','<br/>') return note import os from pyasm.common import Environment allow_client_emails = True sobject = input.get('sobject') update_data = input.get('update_data') parent_type_solid = update_data.get('search_type') parent_type = update_data.get('search_type').split('?')[0] find_str = parent_type.split('/')[1].upper().split('?')[0] is_latest = sobject.get('is_latest') process = sobject.get('process') id = sobject.get('id') search_id = sobject.get('search_id') code = sobject.get('code') version = sobject.get('version') snap_timestamp = sobject.get('timestamp') sea_t = update_data.get('search_type').split('?')[0] upper_st = sea_t.split('/')[1].upper() srch_id = update_data.get('search_id') full_ending = make_right_code_ending(srch_id) parent_code = '%s%s' % (upper_st, full_ending) parent_sk = server.build_search_key(sea_t, parent_code) parent_type = parent_sk.split('?')[0] internal_template_file = '/opt/spt/custom/formatted_emailer/internal_email_template.html' external_template_file = '/opt/spt/custom/formatted_emailer/external_email_template.html' if is_latest and find_str == 'ORDER': # If this is the newest file, and it was uploaded to an order... order_code = parent_code if version not in [-1,'-1']: if process == 'PO': # ... notify people about the upload if it was a new PO file parent = server.eval("@SOBJECT(%s['code','%s'])" % (parent_type, parent_code))[0] parent_timestamp = parent.get('timestamp') snap_tdict = get_time_date_dict(snap_timestamp) parent_tdict = get_time_date_dict(parent_timestamp) #If the snapshot was made after the order, then we can search for the files rez = compare_dt_dicts(parent_tdict, snap_tdict) if rez[1] == 1: # If the order has been there for at least 15 milliseconds before the snapshot, then you'll be able to find the file objects if rez[0] > 15: filez = server.eval("@SOBJECT(sthpw/file['search_id','%s']['search_type','%s'])" % (search_id, parent_type_solid)) file_name = '' if filez: for fi in filez: if fi.get('type') == 'main': sp = fi.get('source_path').split('/') lsp = sp[len(sp) - 1].split('\\') file_name = lsp[len(lsp) - 1] #Then send an email from formatted_emailer import EmailDirections ed = EmailDirections(order_code=order_code) int_data = ed.get_internal_data() subject = '2G-FILE-UPLOAD %s Order: "%s" PO#: %s' % (file_name, int_data['order_name'], int_data['po_number']) if int_data['client_email'] == '' and int_data['location'] == 'external': subject = 'NOT SENT TO CLIENT!? %s' % subject subject_see = subject subject = subject.replace(' ','..') # Spaces are no good when sending to php as a parameter message = '%s has uploaded a new PO File.' % int_data['from_name'].replace('.',' ') message = '%s<br/>Uploaded PO File: %s' % (message, file_name) message = fix_note_chars(message) #Fill the internal template file to create a file you can email template = open(internal_template_file, 'r') filled = '' for line in template: line = line.replace('[ORDER_CODE]', int_data['order_code']) line = line.replace('[PO_NUMBER]', int_data['po_number']) line = line.replace('[CLIENT_EMAIL]', int_data['client_email']) line = line.replace('[EMAIL_CC_LIST]', int_data['ccs']) line = line.replace('[SCHEDULER_EMAIL]', int_data['scheduler_email']) line = line.replace('[SUBJECT]', subject_see) line = line.replace('[MESSAGE]', message) line = line.replace('[CLIENT]', int_data['client_name']) line = line.replace('[CLIENT_LOGIN]', int_data['client_login']) line = line.replace('[ORDER_NAME]', int_data.get('order_hyperlink', int_data['order_name'])) line = line.replace('[START_DATE]', fix_date(int_data['start_date'])) line = line.replace('[DUE_DATE]', fix_date(int_data['due_date'])) line = line.replace('[TITLE_ROW]', '') line = line.replace('[PROJ_ROW]', '') filled = '%s%s' % (filled, line) template.close() filled_in_email = '/var/www/html/formatted_emails/int_snap_inserted_%s.html' % code filler = open(filled_in_email, 'w') filler.write(filled) filler.close() #Send the internal email the_command = "php /opt/spt/custom/formatted_emailer/inserted_order_email.php '''%s''' '''%s''' '''%s''' '''%s''' '''%s''' '''%s'''" % (filled_in_email, int_data['to_email'], int_data['from_email'], int_data['from_name'], subject, int_data['ccs'].replace(';','#Xs*')) os.system(the_command) if int_data['location'] == 'external' and allow_client_emails: ext_data = ed.get_external_data() #Fill the external template file to create a file you can email template = open(external_template_file, 'r') filled = '' for line in template: line = line.replace('[ORDER_CODE]', ext_data['order_code']) line = line.replace('[PO_NUMBER]', ext_data['po_number']) line = line.replace('[CLIENT_EMAIL]', ext_data['client_email']) line = line.replace('[EMAIL_CC_LIST]', ext_data['ccs']) line = line.replace('[SCHEDULER_EMAIL]', ext_data['scheduler_email']) line = line.replace('[SUBJECT]', subject_see) line = line.replace('[MESSAGE]', message) line = line.replace('[CLIENT]', ext_data['client_name']) line = line.replace('[CLIENT_LOGIN]', ext_data['client_login']) line = line.replace('[ORDER_NAME]', ext_data['order_name']) line = line.replace('[START_DATE]', fix_date(ext_data['start_date'])) line = line.replace('[DUE_DATE]', fix_date(ext_data['due_date'])) filled = '%s%s' % (filled, line) template.close() filled_in_email = '/var/www/html/formatted_emails/ext_snap_inserted_%s.html' % code filler = open(filled_in_email, 'w') filler.write(filled) filler.close() #Send the external email os.system("php /opt/spt/custom/formatted_emailer/inserted_order_email.php '''%s''' '''%s''' '''%s''' '''%s''' '''%s''' '''%s'''" % (filled_in_email, ext_data['to_email'], ext_data['from_email'], ext_data['from_name'], subject, ext_data['ccs'].replace(';','#Xs*'))) else: print "THIS MAKES NO SENSE. THE SNAPSHOT WAS CREATED BEFORE THE ORDER?" elif find_str == 'NOTE': #If the upload was made to a note #Get the correct #full_ending = make_note_code_ending(srch_id) #This was for Tactic v3.9 #parent_code = 'NOTE%s' % (full_ending) #This was for Tactic v3.9 #parent_sk = server.build_search_key('sthpw/note', parent_code) #This was for Tactic v3.9 #note_obj = server.eval("@SOBJECT(sthpw/note['code','%s'])" % parent_code)[0] #This was for Tactic v3.9 note_obj = server.eval("@SOBJECT(sthpw/note['id','%s'])" % srch_id)[0] parent_sk = note_obj.get('__search_key__') parent_code = note_obj.get('code') note = note_obj.get('note') #Need to wait until all files have been checked in to Tactic if 'HASATTACHEDFILES:' in note: prenote = note.split('HASATTACHEDFILES')[0] count = int(note.split('HASATTACHEDFILES:')[1].split('MTMCOUNT')[0]) new_count = count - 1 if count == 1 or count == 0: #Get all the files that have been checked in so far and send them along with the note in an email #MAKE SURE TO REMOVE THE HASATTACHEDFILES section from the note before sending it, also update it in the db server.update(parent_sk, {'note': prenote}, triggers=False) search_id = note_obj.get('search_id') login = note_obj.get('login') process = note_obj.get('process') note = prenote #Have to make the note work in html format note = note.replace('\t',' ') note = note.replace('\n','<br/>') note = note.replace(' ', ' ') note = fix_note_chars(note) note_id = note_obj.get('id') timestamp = note_obj.get('timestamp').split('.')[0] #time.sleep(60) addressed_to = note_obj.get('addressed_to') search_type = note_obj.get('search_type').split('?')[0] parent_tall_str = search_type.split('/')[1].upper() groups = Environment.get_group_names() order = None title = None proj = None work_order = None order_code = '' display_ccs = '' subject_see = '' message = '' title_row = '' proj_row = '' if parent_tall_str in ['ORDER','TITLE','PROJ','WORK_ORDER']: # and 'compression' not in groups and 'compression supervisor' not in groups: from formatted_emailer import EmailDirections right_ending = make_right_code_ending(search_id) parent_code = '%s%s' % (parent_tall_str, right_ending) parent = server.eval("@SOBJECT(%s['code','%s'])" % (search_type, parent_code)) if parent: parent = parent[0] ident_str = '' going_to_client = False if parent_tall_str == 'WORK_ORDER': proj = server.eval("@SOBJECT(twog/work_order['code','%s'].twog/proj)" % parent_code)[0] title = server.eval("@SOBJECT(twog/work_order['code','%s'].twog/proj.twog/title)" % parent_code)[0] order = server.eval("@SOBJECT(twog/order['code','%s'])" % title.get('order_code'))[0] elif parent_tall_str == 'PROJ': proj = parent title = server.eval("@SOBJECT(twog/proj['code','%s'].twog/title)" % parent_code)[0] order = server.eval("@SOBJECT(twog/order['code','%s'])" % title.get('order_code'))[0] elif parent_tall_str == 'TITLE': title = parent order = server.eval("@SOBJECT(twog/order['code','%s'])" % title.get('order_code'))[0] elif parent_tall_str == 'ORDER': order = server.eval("@SOBJECT(twog/order['code','%s'])" % parent_code)[0] if parent_tall_str == 'ORDER' and process == 'client': order = parent going_to_client = True elif parent_tall_str == 'TITLE' and process == 'client': going_to_client = True display_heirarchy = '' ed = EmailDirections(order_code=order.get('code')) int_data = ed.get_internal_data() ext_data = ed.get_external_data() if title: title_display = title.get('title') if title.get('episode') not in [None,'']: title_display = '%s: %s' % (title_display, title.get('episode')) display_heirarchy = '"%s" in %s' % (title_display, display_heirarchy) ident_str = '' if parent_tall_str in ['ORDER','TITLE']: ident_str = '%s PO#: %s' % (display_heirarchy, ext_data['po_number']) else: ident_str = '%s (%s)' % (parent_code, ext_data['po_number']) subject = '2G-NOTE FOR %s' % (ident_str) if ext_data['to_email'] == '' and ext_data['ext_ccs'] == '' and ext_data['location'] == 'external': subject = 'NOT SENT TO CLIENT!? %s' % subject subject_see = subject subject = subject.replace(' ','..') message = '<br/>%s has added a new note for %s:<br/><br/>Note:<br/>%s<br/>%s' % (ext_data['from_name'], ident_str, note, timestamp) message = fix_note_chars(message) if going_to_client and allow_client_emails: ext_template = open(external_template_file, 'r') filled = '' for line in ext_template: line = line.replace('[ORDER_CODE]', ext_data['order_code']) line = line.replace('[PO_NUMBER]', ext_data['po_number']) line = line.replace('[CLIENT_EMAIL]', ext_data['client_email']) line = line.replace('[EMAIL_CC_LIST]', ext_data['ext_ccs']) line = line.replace('[SCHEDULER_EMAIL]', ext_data['scheduler_email']) line = line.replace('[SUBJECT]', subject_see) line = line.replace('[MESSAGE]', message) line = line.replace('[CLIENT]', ext_data['client_name']) line = line.replace('[CLIENT_LOGIN]', ext_data['client_login']) line = line.replace('[ORDER_NAME]', ext_data['order_name']) line = line.replace('[START_DATE]', fix_date(ext_data['start_date'])) line = line.replace('[DUE_DATE]', fix_date(ext_data['due_date'])) filled = '%s%s' % (filled, line) snaps_expr = "@SOBJECT(sthpw/snapshot['search_type','sthpw/note']['search_id','%s'])" % note_id snaps = server.eval(snaps_expr) for snap in snaps: if snap.get('is_current') in [True,'T','true','t']: #files_expr = "@SOBJECT(sthpw/file['snapshot_code','%s'])" % snap.get('code') files_expr = "@SOBJECT(sthpw/file['search_type','sthpw/note']['search_id','%s'])" % note_obj.get('id') files = server.eval(files_expr) for file in files: if file.get('type') == 'main' and file.get('snapshot_code') == snap.get('code'): file_path = '%s/%s' % (file.get('checkin_dir'), file.get('file_name')) filled = '%s\nMATTACHMENT:%s' % (filled, file_path) ext_template.close() filled_in_email = '/var/www/html/formatted_emails/ext_note_inserted_%s.html' % note_id filler = open(filled_in_email, 'w') filler.write(filled) filler.close() if addressed_to not in [None,'']: adt = addressed_to.split(',') for adta in adt: if '@2gdigital' not in adta and adta not in ext_data['ext_ccs']: if ext_data['ext_ccs'] == '': ext_data['ext_ccs'] = adta else: ext_data['ext_ccs'] = '%s;%s' % (ext_data['ext_ccs'], adta) the_command = "php /opt/spt/custom/formatted_emailer/trusty_emailer.php '''%s''' '''%s''' '''%s''' '''%s''' '''%s''' '''%s'''" % (filled_in_email, ext_data['to_email'], ext_data['from_email'], ext_data['from_name'], subject, ext_data['ext_ccs'].replace(';','#Xs*')) if ext_data['to_email'] not in [None,''] and ext_data['ext_ccs'] not in [None,'',';']: os.system(the_command) #Now do internal email if title: full_title = title.get('title') if title.get('episode') not in [None,'']: full_title = '%s: %s' % (full_title, title.get('episode')) title_row = "<div id='pagesubTitle3'>Title: <strong>%s</strong> | Title Code: <strong>%s</strong></div>" % (full_title, title.get('code')) if proj: proj_row = "<div id='pagesubTitle3'>Project: <strong>%s</strong> | Project Code: <strong>%s</strong></div>" % (proj.get('process'), proj.get('code')) int_template = open(internal_template_file, 'r') filled = '' for line in int_template: line = line.replace('[ORDER_CODE]', int_data['order_code']) line = line.replace('[PO_NUMBER]', int_data['po_number']) line = line.replace('[CLIENT_EMAIL]', int_data['client_email']) line = line.replace('[EMAIL_CC_LIST]', int_data['int_ccs']) line = line.replace('[SCHEDULER_EMAIL]', int_data['scheduler_email']) line = line.replace('[SUBJECT]', subject_see) line = line.replace('[MESSAGE]', message) line = line.replace('[CLIENT]', int_data['client_name']) line = line.replace('[CLIENT_LOGIN]', int_data['client_login']) line = line.replace('[ORDER_NAME]', int_data.get('order_hyperlink', int_data['order_name'])) line = line.replace('[START_DATE]', fix_date(int_data['start_date'])) line = line.replace('[DUE_DATE]', fix_date(int_data['due_date'])) line = line.replace('[TITLE_ROW]', title_row) line = line.replace('[PROJ_ROW]', proj_row) filled = '%s%s' % (filled, line) snaps_expr = "@SOBJECT(sthpw/snapshot['search_type','sthpw/note']['search_id','%s'])" % note_id snaps = server.eval(snaps_expr) for snap in snaps: if snap.get('is_current') in [True,'T','true','t']: #files_expr = "@SOBJECT(sthpw/file['snapshot_code','%s'])" % snap.get('code') files_expr = "@SOBJECT(sthpw/file['search_type','sthpw/note']['search_id','%s'])" % note_obj.get('id') files = server.eval(files_expr) for file in files: if file.get('type') == 'main' and file.get('snapshot_code') == snap.get('code'): file_path = '%s/%s' % (file.get('checkin_dir'), file.get('file_name')) filled = '%s\nMATTACHMENT:%s' % (filled, file_path) int_template.close() filled_in_email = '/var/www/html/formatted_emails/int_note_inserted_%s.html' % note_id filler = open(filled_in_email, 'w') filler.write(filled) filler.close() if addressed_to not in [None,'']: adt = addressed_to.split(',') for adta in adt: if '@2gdigital' in adta and adta not in int_data['int_ccs']: if int_data['int_ccs'] == '': int_data['int_ccs'] = adta else: int_data['int_ccs'] = '%s;%s' % (int_data['int_ccs'], adta) login_email = server.eval("@GET(sthpw/login['login','%s'].email)" % login) if login_email: int_data['from_email'] = login_email[0] the_command = "php /opt/spt/custom/formatted_emailer/trusty_emailer.php '''%s''' '''%s''' '''%s''' '''%s''' '''%s''' '''%s'''" % (filled_in_email, int_data['to_email'], int_data['from_email'], int_data['from_name'], subject, int_data['int_ccs'].replace(';','#Xs*')) if int_data['to_email'] not in [None,''] and int_data['int_ccs'] not in [None,'',';']: os.system(the_command) else: #Keep going until all uploads have been accounted for new_note = '%s\nHASATTACHEDFILES:%sMTMCOUNT' % (prenote, new_count) server.update(parent_sk, {'note': new_note}) except AttributeError as e: traceback.print_exc() print str(e) + '\nMost likely the server object does not exist.' raise e except KeyError as e: traceback.print_exc() print str(e) + '\nMost likely the input dictionary does not exist.' raise e except Exception as e: traceback.print_exc() print str(e) raise e
def main(server=None, input=None): """ The main function of the custom script. The entire script was copied and pasted into the body of the try statement in order to add some error handling. It's all legacy code, so edit with caution. :param server: the TacticServerStub object :param input: a dict with data like like search_key, search_type, sobject, and update_data :return: None """ if not input: input = {} try: # CUSTOM_SCRIPT00074 # Matthew Tyler Misenhimer # This is run when a new file is uploaded to an object or a note (notes handled differently) # Do Not send external if location is internal def make_right_code_ending(sid): ending = str(sid) ending_len = len(ending) if ending_len < 5: zeros = 5 - ending_len for num in range (0, zeros): ending = '0%s' % ending return ending def make_note_code_ending(sid): ending = str(sid) ending_len = len(ending) if ending_len < 8: zeros = 8 - ending_len for num in range (0, zeros): ending = '0%s' % ending return ending def make_timestamp(): import datetime now = datetime.datetime.now() return now.strftime("%Y-%m-%d %H:%M:%S") def get_time_date_dict(str_time): pre_split = str_time.split('.')[0] first_split = pre_split.split(' ') date = first_split[0] time = first_split[1] date_split = date.split('-') dt = {} dt['year'] = int(date_split[0]) dt['month'] = int(date_split[1]) dt['day'] = int(date_split[2]) dt['date'] = date dt['time'] = time time_split = time.split(':') dt['hour'] = int(time_split[0]) dt['minute'] = int(time_split[1]) dt['second'] = int(time_split[2]) dt['big_time'] = float((dt['hour'] * 3600) + (dt['minute'] * 60) + dt['second']) return dt def compare_dt_dicts(dt1, dt2): # This is rough. Don't use it for anything else. Should work for this though. # This is to see the difference in seconds between two special date&time dicts. # Result in first position in return array will be 1 if the first passed in variable is older, 0 if it is newer than the second passed in difference = 0 newest = -1 dt1_bignum = float(float((dt1['year'] - 2000) * 365 * 24 * 3600) + float((dt1['month'] - 1) * 31 * 24 * 3600) + float((dt1['day'] - 1) * 24 * 3600) + dt1['big_time']) dt2_bignum = float(float((dt2['year'] - 2000) * 365 * 24 * 3600) + float((dt2['month'] - 1) * 31 * 24 * 3600) + float((dt2['day'] - 1) * 24 * 3600) + dt2['big_time']) difference = dt2_bignum - dt1_bignum if difference < 0: newest = 0 else: newest = 1 return [difference, newest] def fix_date(date): #This is needed due to the way Tactic deals with dates (using timezone info), post v4.0 from pyasm.common import SPTDate return_date = '' date_obj = SPTDate.convert_to_local(date) if date_obj not in [None,'']: return_date = date_obj.strftime("%Y-%m-%d %H:%M") return return_date def fix_note_chars(note): import sys from json import dumps as jsondumps if sys.stdout.encoding: note = note.decode(sys.stdout.encoding) note = jsondumps(note) note = note.replace('||t',' ') note = note.replace('\\\\t',' ') note = note.replace('\\\t',' ') note = note.replace('\\t',' ') note = note.replace('\t',' ') note = note.replace('\\"','"') note = note.replace('\"','"') note = note.replace('||n','<br/>') note = note.replace('\\\\n','<br/>') note = note.replace('\\\n','<br/>') note = note.replace('\\n','<br/>') note = note.replace('\n','<br/>') return note import os from pyasm.common import Environment allow_client_emails = True sobject = input.get('sobject') parent_type_solid = sobject.get('search_type') parent_type = sobject.get('search_type').split('?')[0] find_str = parent_type.split('/')[1].upper().split('?')[0] file_name = sobject.get('file_name') #.replace(' ','_') #This only handles files that were attached to notes or orders if '_web.' not in file_name and '_icon.' not in file_name and 'icon' not in sobject.get('checkin_dir'): #see if the file was attached to a note, if not, see if it was connected to an order note_expr = "@SOBJECT(sthpw/snapshot['search_id','%s']['search_type','sthpw/note']['@ORDER_BY','timestamp asc'])" % sobject.get('search_id') snapshots = server.eval(note_expr) if len(snapshots) == 0: order_expr = "@SOBJECT(sthpw/snapshot['search_id','%s']['search_type','twog/order?project=twog'])" % sobject.get('search_id') snapshots = server.eval(order_expr) if len(snapshots) > 0: #Get the most recent snapshot that the file could have been attached to snapshot = snapshots[len(snapshots) - 1] is_latest = snapshot.get('is_latest') description = snapshot.get('description') process = snapshot.get('process') id = snapshot.get('id') search_id = snapshot.get('search_id') code = snapshot.get('code') snap_timestamp = snapshot.get('timestamp') sea_t = sobject.get('search_type').split('?')[0] upper_st = sea_t.split('/')[1].upper() srch_id = sobject.get('search_id') full_ending = make_right_code_ending(srch_id) parent_code = '%s%s' % (upper_st, full_ending) parent_sk = server.build_search_key(sea_t, parent_code) parent_type = parent_sk.split('?')[0] version = int(snapshot.get('version')) #There's a template for the internal emails, and one for those that go out to our clients internal_template_file = '/opt/spt/custom/formatted_emailer/internal_email_template.html' external_template_file = '/opt/spt/custom/formatted_emailer/external_email_template.html' if is_latest and find_str == 'ORDER': #Handle the case in which it was attached to an order order_code = parent_code if version not in [-1,'-1']: #The only process we care about sending alerts out for is the "PO" if process == 'PO': parent = server.eval("@SOBJECT(%s['code','%s'])" % (parent_type, parent_code))[0] sched = parent.get('login') sched_email = server.eval("@GET(sthpw/login['login','%s'].email)" % sched) if sched_email: sched_email = sched_email[0] else: sched_email = 'imakestringnothinghappn' parent_timestamp = parent.get('timestamp') snap_tdict = get_time_date_dict(snap_timestamp) parent_tdict = get_time_date_dict(parent_timestamp) rez = compare_dt_dicts(parent_tdict, snap_tdict) #If the result is 1, the parent is older than the snapshot #If the snapshot is older than the order, the result will be 0, which means there is a problem if rez[1] == 1: #If the difference in seconds between the object creation is greater than 15 seconds, there will probably be no problems with the following queries (Had to put it in, because it was creating errors occasionally) if rez[0] > 15: #Get all the files associated with the file upload (there could be others attached to the same snapshot) #Then send an email, using the internal template from formatted_emailer import EmailDirections ed = EmailDirections(order_code=order_code) int_data = ed.get_internal_data() subject = '2G-PO-FILE-UPLOAD %s Order: "%s" PO#: %s' % (file_name, int_data['order_name'], int_data['po_number']) if int_data['client_email'] == '' and int_data['location'] == 'external': subject = 'NOT SENT TO CLIENT!? %s' % subject subject_see = subject subject = subject.replace(' ','..') message = '%s has uploaded a new PO File.' % int_data['from_name'].replace('.',' ') message = '%s<br/>Uploaded PO File: %s' % (message, file_name) if parent_type == 'twog/order': sales_repper = parent.get('sales_rep') sales_rep_email = server.eval("@GET(sthpw/login['login','%s']['location','internal'].email)" % sales_repper) if sales_rep_email not in [None,'',[]]: sales_rep_email = sales_rep_email[0] if int_data['ccs'] not in [None,'']: int_data['ccs'] = '%s;%s' % (int_data['ccs'], sales_rep_email) else: int_data['ccs'] = '%s' % sales_rep_email int_data['ccs'] = int_data['ccs'].replace(';%s' % sched_email, '').replace('%s;' % sched_email, '') template = open(internal_template_file, 'r') filled = '' for line in template: line = line.replace('[ORDER_CODE]', int_data['order_code']) line = line.replace('[PO_NUMBER]', int_data['po_number']) line = line.replace('[CLIENT_EMAIL]', int_data['client_email']) line = line.replace('[EMAIL_CC_LIST]', int_data['ccs']) line = line.replace('[SCHEDULER_EMAIL]', int_data['scheduler_email']) line = line.replace('[SUBJECT]', subject_see) line = line.replace('[MESSAGE]', message) line = line.replace('[CLIENT]', int_data['client_name']) line = line.replace('[CLIENT_LOGIN]', int_data['client_login']) line = line.replace('[ORDER_NAME]', int_data.get('order_hyperlink', int_data['order_name'])) line = line.replace('[START_DATE]', fix_date(int_data['start_date'])) line = line.replace('[DUE_DATE]', fix_date(int_data['due_date'])) line = line.replace('[TITLE_ROW]', '') line = line.replace('[PROJ_ROW]', '') filled = '%s%s' % (filled, line) transaction_ticket = server.get_transaction_ticket() upload_dir = Environment.get_upload_dir(transaction_ticket) filled = '%s\nMATTACHMENT:%s/%s' % (filled, upload_dir, file_name) template.close() filled_in_email = '/var/www/html/formatted_emails/int_snap_inserted_%s.html' % code filler = open(filled_in_email, 'w') filler.write(filled) filler.close() the_command = "php /opt/spt/custom/formatted_emailer/trusty_emailer.php '''%s''' '''%s''' '''%s''' '''%s''' '''%s''' '''%s'''" % (filled_in_email, int_data['to_email'], int_data['from_email'], int_data['from_name'], subject, int_data['ccs'].replace(';','#Xs*')) os.system(the_command) #If the location of the user is external, and we allow this client to receive emails, then send them an email as well if int_data['location'] == 'external' and allow_client_emails: ext_data = ed.get_external_data() template = open(external_template_file, 'r') filled = '' for line in template: line = line.replace('[ORDER_CODE]', ext_data['order_code']) line = line.replace('[PO_NUMBER]', ext_data['po_number']) line = line.replace('[CLIENT_EMAIL]', ext_data['client_email']) line = line.replace('[EMAIL_CC_LIST]', ext_data['ccs']) line = line.replace('[SCHEDULER_EMAIL]', ext_data['scheduler_email']) line = line.replace('[SUBJECT]', subject_see) line = line.replace('[MESSAGE]', message) line = line.replace('[CLIENT]', ext_data['client_name']) line = line.replace('[CLIENT_LOGIN]', ext_data['client_login']) line = line.replace('[ORDER_NAME]', ext_data['order_name']) line = line.replace('[START_DATE]', fix_date(ext_data['start_date'])) line = line.replace('[DUE_DATE]', fix_date(ext_data['due_date'])) filled = '%s%s' % (filled, line) filled = '%s\nMATTACHMENT:%s/%s' % (filled, upload_dir, file_name) template.close() filled_in_email = '/var/www/html/formatted_emails/ext_snap_inserted_%s.html' % code filler = open(filled_in_email, 'w') filler.write(filled) filler.close() os.system("php /opt/spt/custom/formatted_emailer/trusty_emailer.php '''%s''' '''%s''' '''%s''' '''%s''' '''%s''' '''%s'''" % (filled_in_email, ext_data['to_email'], ext_data['from_email'], ext_data['from_name'], subject, ext_data['ccs'].replace(';','#Xs*'))) else: print "THIS MAKES NO SENSE. THE SNAPSHOT WAS CREATED BEFORE THE ORDER?" elif find_str == 'NOTE': #So it was attached to a note #Need to make a code with the search id, as there's different ways the order and note deal with their snapshots full_ending = make_note_code_ending(srch_id) parent_code = 'NOTE%s' % (full_ending) parent_sk = server.build_search_key('sthpw/note', parent_code) #Get the note sobject #note_obj = server.eval("@SOBJECT(sthpw/note['code','%s'])" % parent_code)[0] note_obj = server.eval("@SOBJECT(sthpw/note['id','%s'])" % srch_id)[0] note = note_obj.get('note') #Need to wait until all files have been checked in to Tactic if process == 'note_attachment': timestamp = note_obj.get('timestamp').split('.')[0] search_id = note_obj.get('search_id') login = note_obj.get('login') process = note_obj.get('process') note_id = note_obj.get('id') addressed_to = note_obj.get('addressed_to') override_compression = True #if addressed_to not in [None,'']: # override_compression = True search_type = note_obj.get('search_type').split('?')[0] parent_tall_str = search_type.split('/')[1].upper() groups = Environment.get_group_names() note = note_obj.get('note') note = note.replace('\t',' ') note = note.replace('\n','<br/>') note = note.replace(' ', ' ') note = fix_note_chars(note) order = None title = None proj = None work_order = None order_code = '' display_ccs = '' subject_see = '' message = '' title_row = '' proj_row = '' #If the note was attached to an order, title, proj or work_order, and compression didn't write the note, then send it. If compression intended to send it, then go ahead and send. if parent_tall_str in ['ORDER','TITLE','PROJ','WORK_ORDER']: # and (('compression' not in groups and 'compression supervisor' not in groups) or override_compression): from formatted_emailer import EmailDirections #create the note parent's code from search_id right_ending = make_right_code_ending(search_id) parent_code = '%s%s' % (parent_tall_str, right_ending) parent = server.eval("@SOBJECT(%s['code','%s'])" % (search_type, parent_code)) if parent: parent = parent[0] ident_str = '' going_to_client = False #Get info from the related elements, going up the chain if parent_tall_str == 'WORK_ORDER': proj = server.eval("@SOBJECT(twog/work_order['code','%s'].twog/proj)" % parent_code)[0] title = server.eval("@SOBJECT(twog/work_order['code','%s'].twog/proj.twog/title)" % parent_code)[0] order = server.eval("@SOBJECT(twog/order['code','%s'])" % title.get('order_code'))[0] elif parent_tall_str == 'PROJ': proj = parent title = server.eval("@SOBJECT(twog/proj['code','%s'].twog/title)" % parent_code)[0] order = server.eval("@SOBJECT(twog/order['code','%s'])" % title.get('order_code'))[0] elif parent_tall_str == 'TITLE': title = parent order = server.eval("@SOBJECT(twog/order['code','%s'])" % title.get('order_code'))[0] elif parent_tall_str == 'ORDER': order = server.eval("@SOBJECT(twog/order['code','%s'])" % parent_code)[0] #If the note was attached to an order or a title, go ahead and send it to the client (as long as we allow emailing to that client), otherwise it will remain internal if parent_tall_str == 'ORDER' and process == 'client': order = parent going_to_client = True elif parent_tall_str == 'TITLE' and process == 'client': going_to_client = True display_heirarchy = '' #Get the different message elements and mail_to lists for internal and external emails ed = EmailDirections(order_code=order.get('code')) int_data = ed.get_internal_data() ext_data = ed.get_external_data() if title: title_display = title.get('title') if title.get('episode') not in [None,'']: title_display = '%s: %s' % (title_display, title.get('episode')) display_heirarchy = '"%s" in %s' % (title_display, display_heirarchy) ident_str = '' if parent_tall_str in ['ORDER','TITLE']: ident_str = '%s PO#: %s' % (display_heirarchy, ext_data['po_number']) else: ident_str = '%s (%s)' % (parent_code, ext_data['po_number']) subject = '2G-NOTE ATTACHMENT FOR %s (%s)' % (ident_str, file_name) #If it's not going to the client because we don't have their email, at least tell the people internally that it didn't go out to the client if ext_data['to_email'] == '' and ext_data['ext_ccs'] == '' and ext_data['location'] == 'external': subject = 'NOT SENT TO CLIENT!? %s' % subject subject_see = subject subject = subject.replace(' ','..') message = '<br/>%s has added a new note for %s:<br/><br/>Note:<br/>%s<br/>%s' % (ext_data['from_name'], ident_str, note, timestamp) if going_to_client and allow_client_emails: ext_template = open(external_template_file, 'r') filled = '' for line in ext_template: line = line.replace('[ORDER_CODE]', ext_data['order_code']) line = line.replace('[PO_NUMBER]', ext_data['po_number']) line = line.replace('[CLIENT_EMAIL]', ext_data['client_email']) line = line.replace('[EMAIL_CC_LIST]', ext_data['ext_ccs']) line = line.replace('[SCHEDULER_EMAIL]', ext_data['scheduler_email']) line = line.replace('[SUBJECT]', subject_see) line = line.replace('[MESSAGE]', message) line = line.replace('[CLIENT]', ext_data['client_name']) line = line.replace('[CLIENT_LOGIN]', ext_data['client_login']) line = line.replace('[ORDER_NAME]', ext_data['order_name']) line = line.replace('[START_DATE]', fix_date(ext_data['start_date'])) line = line.replace('[DUE_DATE]', fix_date(ext_data['due_date'])) filled = '%s%s' % (filled, line) #If there were files attached (which there should be), show what they are in the email transaction_ticket = server.get_transaction_ticket() upload_dir = Environment.get_upload_dir(transaction_ticket) filled = '%s\nMATTACHMENT:%s/%s' % (filled, upload_dir, file_name) ext_template.close() filled_in_email = '/var/www/html/formatted_emails/ext_note_inserted_%s.html' % note_id filler = open(filled_in_email, 'w') filler.write(filled) filler.close() if addressed_to not in [None,'']: adt = addressed_to.split(',') for adta in adt: if '@2gdigital' not in adta and adta not in ext_data['ext_ccs']: if ext_data['ext_ccs'] == '': ext_data['ext_ccs'] = adta else: ext_data['ext_ccs'] = '%s;%s' % (ext_data['ext_ccs'], adta) the_command = "php /opt/spt/custom/formatted_emailer/trusty_emailer.php '''%s''' '''%s''' '''%s''' '''%s''' '''%s''' '''%s'''" % (filled_in_email, ext_data['to_email'], ext_data['from_email'], ext_data['from_name'], subject, ext_data['ext_ccs'].replace(';','#Xs*')) if ext_data['to_email'] not in [None,''] and ext_data['ext_ccs'] not in [None,'',';']: os.system(the_command) #Now do internal email if title: full_title = title.get('title') if title.get('episode') not in [None,'']: full_title = '%s: %s' % (full_title, title.get('episode')) title_row = "<div id='pagesubTitle3'>Title: <strong>%s</strong> | Title Code: <strong>%s</strong></div>" % (full_title, title.get('code')) if proj: proj_row = "<div id='pagesubTitle3'>Project: <strong>%s</strong> | Project Code: <strong>%s</strong></div>" % (proj.get('process'), proj.get('code')) int_template = open(internal_template_file, 'r') filled = '' for line in int_template: line = line.replace('[ORDER_CODE]', int_data['order_code']) line = line.replace('[PO_NUMBER]', int_data['po_number']) line = line.replace('[CLIENT_EMAIL]', int_data['client_email']) line = line.replace('[EMAIL_CC_LIST]', int_data['int_ccs']) line = line.replace('[SCHEDULER_EMAIL]', int_data['scheduler_email']) line = line.replace('[SUBJECT]', subject_see) line = line.replace('[MESSAGE]', message) line = line.replace('[CLIENT]', int_data['client_name']) line = line.replace('[CLIENT_LOGIN]', int_data['client_login']) line = line.replace('[ORDER_NAME]', int_data.get('order_hyperlink', int_data['order_name'])) line = line.replace('[START_DATE]', fix_date(int_data['start_date'])) line = line.replace('[DUE_DATE]', fix_date(int_data['due_date'])) line = line.replace('[TITLE_ROW]', title_row) line = line.replace('[PROJ_ROW]', proj_row) filled = '%s%s' % (filled, line) #If there were files attached (which there should be), show what they are in the email transaction_ticket = server.get_transaction_ticket() upload_dir = Environment.get_upload_dir(transaction_ticket) filled = '%s\nMATTACHMENT:%s/%s' % (filled, upload_dir, file_name) int_template.close() filled_in_email = '/var/www/html/formatted_emails/int_note_inserted_%s.html' % note_id filler = open(filled_in_email, 'w') filler.write(filled) filler.close() if addressed_to not in [None,'']: adt = addressed_to.split(',') for adta in adt: if '@2gdigital' in adta and adta not in int_data['int_ccs']: if int_data['int_ccs'] == '': int_data['int_ccs'] = adta else: int_data['int_ccs'] = '%s;%s' % (int_data['int_ccs'], adta) login_email = server.eval("@GET(sthpw/login['login','%s'].email)" % login) if login_email: int_data['from_email'] = login_email[0] the_command = "php /opt/spt/custom/formatted_emailer/trusty_emailer.php '''%s''' '''%s''' '''%s''' '''%s''' '''%s''' '''%s'''" % (filled_in_email, int_data['to_email'], int_data['from_email'], int_data['from_name'], subject, int_data['int_ccs'].replace(';','#Xs*')) if int_data['to_email'] not in [None,''] and int_data['int_ccs'] not in [None,'',';']: #Do it. Send the email os.system(the_command) elif '_icon' in file_name: snapshot_code = sobject.get('snapshot_code') extension = 'jpg' #I don't know why I can't get the actual info on this file right now. Kinda tarded. We just have to assume that it will end up being a jpg fsplit = file_name.split('.') sexpr = "@SOBJECT(sthpw/snapshot['code','%s'])" % snapshot_code snapshot = server.eval(sexpr)[0] version = int(snapshot.get('version')) if version > 9: version = 'v0%s' % version elif version > 99: version = 'v%s' % version else: version = 'v00%s' % version parent_type = snapshot.get('search_type').split('?')[0] find_str = parent_type.split('/')[1].upper().split('?')[0] process = snapshot.get('process') if process == 'icon': id = snapshot.get('id') search_id = snapshot.get('search_id') sea_t = snapshot.get('search_type').split('?')[0] upper_st = sea_t.split('/')[1].upper() srch_id = snapshot.get('search_id') full_ending = make_right_code_ending(srch_id) parent_code = '%s%s' % (upper_st, full_ending) parent_sk = server.build_search_key(sea_t, parent_code) parent_type = parent_sk.split('?')[0] #This is to set the icon for orders if find_str == 'ORDER': preview_path = server.get_path_from_snapshot(snapshot.get('code'), mode="web") preview_path_i = preview_path.split('/') fn2 = preview_path_i[len(preview_path_i) - 1] fn3_s = fn2.split('.') fn3 = '%s_icon_%s.%s' % (fn3_s[0], version, extension) preview_path = preview_path.replace(fn2, fn3) server.update(parent_sk, {'icon_path': preview_path}) except AttributeError as e: traceback.print_exc() print str(e) + '\nMost likely the server object does not exist.' raise e except KeyError as e: traceback.print_exc() print str(e) + '\nMost likely the input dictionary does not exist.' raise e except Exception as e: traceback.print_exc() print str(e) raise e
def get_display(self): pyclass_dict = { 'twog/title': 'TitleRow', 'twog/order': 'OrderTable', 'twog/proj': 'ProjRow', 'twog/work_order': 'WorkOrderRow', 'twog/equipment_used': 'EquipmentUsedRow' } groups_str = '' user_group_names = Environment.get_group_names() for mg in user_group_names: if groups_str == '': groups_str = mg else: groups_str = '%s,%s' % (groups_str, mg) if 'scheduling' in groups_str: user_is_scheduler = True else: user_is_scheduler = False table = Table() table.add_attr('class', 'task_table') table.add_attr('width', '100%') if self.task_code in ['', None]: table.add_row() table.add_cell('') else: self.parent_pyclass = pyclass_dict[self.parent_sk.split('?')[0]] table.add_style('background-color: 90a0b5;') task_search = Search("sthpw/task") task_search.add_filter('code', self.task_code) tasks_found = task_search.get_sobjects() if len(tasks_found) > 0: task = tasks_found[0] hours_search = Search('sthpw/work_hour') hours_search.add_filter('task_code', task.get_code()) hours = hours_search.get_sobjects() hours_added = 0 for hour in hours: hour_num = hour.get_value('straight_time') if hour_num in [None, '']: hour_num = 0 hour_num = float(hour_num) hours_added = float(hours_added) + hour_num pipe_code = task.get_value('pipeline_code') if 'task' not in pipe_code: pipe_code = 'task' task_select = self.get_statuses_select_from_task_pipe(task.get_value('status'), pipe_code, 'sthpw/pipeline', task.get_search_key(), user_is_scheduler) worker_select = self.get_assigned_select(task.get_value('assigned')) group_select = self.get_assigned_group_select(task.get_value('assigned_login_group')) table.add_row() top = table.add_cell('<b>Assignment Information<b>') top.add_attr('colspan', '4') top.add_attr('align', 'center') top.add_style('background-color: #6789b7;') table.add_row() table.add_cell('Status: ') table.add_cell(task_select) table.add_cell('Assigned: ') table.add_cell(worker_select) table.add_row() table.add_cell('Hours Added:') table.add_cell(hours_added) table.add_cell('Add Hours:') table.add_cell('<input type="text" class="hour_adder" value=""/>') table.add_row() table.add_cell('Priority: ') table.add_cell('<input type="text" class="priority_setter" value="%s"/>' % task.get_value('priority')) table.add_cell('Assigned Group: ') table.add_cell(group_select) bid_start = CalendarInputWdg(name='task_bid_start') # 4.2 bid_start.set_option('show_time', 'true') bid_start.set_option('show_activator', 'true') bid_start.set_option('display_format', 'MM/DD/YYYY HH:MM') bid_start.set_option('time_input_default', '5:00 PM') if task.get_value('bid_start_date') not in ['', None]: bid_start.set_option('default', fix_date(task.get_value('bid_start_date'))) bid_end = CalendarInputWdg(name='task_bid_end') # 4.2 bid_end.set_option('show_time', 'true') bid_end.set_option('show_activator', 'true') bid_end.set_option('display_format', 'MM/DD/YYYY HH:MM') bid_end.set_option('time_input_default', '5:00 PM') if task.get_value('bid_end_date') not in ['', None]: bid_end.set_option('default', fix_date(task.get_value('bid_end_date'))) table.add_row() bs = table.add_cell('Bid Start: ') bs.add_attr('nowrap', 'nowrap') table.add_cell(bid_start) be = table.add_cell('Due Date: ') be.add_attr('nowrap', 'nowrap') table.add_cell(bid_end) table.add_row() acs = table.add_cell('Actual Start: ') acs.add_attr('nowrap', 'nowrap') acsv = fix_date(task.get_value('actual_start_date')) if acsv in ['', None]: acsv = 'Has not begun' table.add_cell(acsv) ace = table.add_cell('Actual End: ') acev = fix_date(task.get_value('actual_end_date')) if acev in ['', None]: acev = 'Has not ended' ace.add_attr('nowrap', 'nowrap') table.add_cell(acev) table.add_row() doubl = table.add_cell('<input type="button" value="Save"/>') doubl.add_attr('colspan', '4') doubl.add_attr('align', 'center') doubl.add_behavior(get_save_task_info_behavior(task.get_search_key(), self.parent_sk, self.parent_pyclass, self.order_sk, 'false', self.user)) else: table.add_row() table.add_cell('') return table
def get_display(my): import common_tools.utils as ctu from common_tools.copy_url_button import CopyUrlButton my.sk = str(my.kwargs.get('sk')) my.sid = str(my.kwargs.get('search_id')) allowed_search_titles = '' 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 = my.kwargs.get('display_mode') if my.disp_mode == 'Small': my.small = True my.code = my.sk.split('code=')[1] if 'allowed_titles' in my.kwargs.keys(): my.allowed_titles_str = str(my.kwargs.get('allowed_titles')) split_allow = my.allowed_titles_str.split('|') for sa in split_allow: if allowed_search_titles == '': allowed_search_titles = "('%s'" % sa else: allowed_search_titles = "%s,'%s'" % (allowed_search_titles, sa) if allowed_search_titles != '': allowed_search_titles = '%s)' % allowed_search_titles if my.allowed_titles_str == '': my.allowed_titles_str = 'NOTHING|NOTHING' main_search = Search("twog/order") main_search.add_filter('code', my.code) main_obj = main_search.get_sobject() 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: if main_obj.get_value('classification') in ['master', 'Master']: my.is_master = True my.is_master_str = 'true' sched_full_name = '' if main_obj.get_value('login') not in [None,'']: sched_s = Search('sthpw/login') sched_s.add_filter('location', 'internal') sched_s.add_filter('login', main_obj.get_value('login')) sched = sched_s.get_sobject() if sched: sched_full_name = '%s %s' % (sched.get_value('first_name'), sched.get_value('last_name')) sales_full_name = '' if main_obj.get_value('sales_rep') not in [None,'']: sales_s = Search('sthpw/login') sales_s.add_filter('location', 'internal') sales_s.add_filter('login', main_obj.get_value('sales_rep')) sales = sales_s.get_sobject() if sales: sales_full_name = '%s %s' % (sales.get_value('first_name'), sales.get_value('last_name')) title_search = Search("twog/title") title_search.add_filter('order_code', main_obj.get_value('code')) if allowed_search_titles != '': title_search.add_where("\"code\" in %s" % allowed_search_titles) titles = title_search.get_sobjects() table = Table() table.add_attr('I_AM', 'ORDER TABLE') if user_is_scheduler: table.add_attr('SOY', 'ORDER-O TABLE-O') 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: #00033a;') table.add_style('background-color: #d9edf7;') 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') order_name_row = table.add_row() full_o_name = main_obj.get('name') if main_obj.get('details') not in [None,'']: full_o_name = '%s - %s' % (full_o_name, main_obj.get('details')) order_name_cell = table.add_cell('<b><u>Order: %s</u><b>' % full_o_name) order_name_cell.add_attr('nowrap','nowrap') order_name_cell.add_style('cursor: pointer;') order_name_cell.add_behavior(get_panel_change_behavior('twog/order', my.code, my.sk, my.sk, my.title, '', 'builder/refresh_from_save', '', my.sk, main_obj.get_value('name'), user_is_scheduler)) order_due_cell = table.add_cell("Due: %s" % fix_date(main_obj.get_value('due_date')).split(' ')[0]) order_due_cell.add_attr('nowrap', 'nowrap') long_cell1 = table.add_cell('Scheduler: %s' % sched_full_name) long_cell1.add_style('width: 100%') order_sales_row = table.add_row() order_po_cell = table.add_cell("Code: %s PO Number: %s" % (my.code, main_obj.get_value('po_number'))) order_po_cell.add_attr('nowrap', 'nowrap') order_sales_cell = table.add_cell('Sales Rep: %s' % sales_full_name) order_sales_cell.add_attr('nowrap', 'nowrap') bottom_buttons = Table() bottom_buttons.add_row() order_builder_url = ctu.get_order_builder_url(my.code) copy_url_button = CopyUrlButton(title='Copy URL to Clipboard', url=order_builder_url) copy_url_cell = bottom_buttons.add_cell(copy_url_button) copy_url_cell.add_attr('align', 'right') instructions_button = FullInstructionsLauncherWdg(title='View Instructions', search_key=my.sk) instructions_cell = bottom_buttons.add_cell(instructions_button) instructions_cell.add_attr('align', 'right') if user_is_scheduler: tcloner = ButtonSmallNewWdg(title="Title Cloner", icon=CustomIconWdg.icons.get('STAR')) tcloner.add_behavior(get_launch_title_cloner_behavior(my.sk, main_obj.get_value('name'), my.user)) dcl = bottom_buttons.add_cell(tcloner) dcl.add_attr('align', 'right') tchanger = ButtonSmallNewWdg(title="Title Changer", icon=CustomIconWdg.icons.get('CALENDAR')) tchanger.add_behavior(get_launch_title_changer_behavior(my.sk, main_obj.get_value('name'), my.user)) dcal = bottom_buttons.add_cell(tchanger) dcal.add_attr('align', 'right') tdeletor = ButtonSmallNewWdg(title="Title Deletor", icon=CustomIconWdg.icons.get('TABLE_ROW_DELETE')) tdeletor.add_behavior(get_launch_title_deletor_behavior(my.sk, main_obj.get_value('name'), my.user)) dfilt = bottom_buttons.add_cell(tdeletor) dfilt.add_attr('align', 'right') tfilter = ButtonSmallNewWdg(title="Filter Titles", icon=CustomIconWdg.icons.get('CONTENTS')) tfilter.add_behavior(get_launch_title_filter_behavior(my.sk, main_obj.get_value('name'), my.user)) filt = bottom_buttons.add_cell(tfilter) filt.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('name'))) 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: title_adder = ButtonSmallNewWdg(title="Add Titles", icon=CustomIconWdg.icons.get('INSERT_MULTI')) title_adder.add_behavior(get_title_add_behavior(my.sk, my.sid, main_obj.get_value('client_code'), main_obj.get_value('name'))) tadd = bottom_buttons.add_cell(title_adder) tadd.add_attr('align', 'right') tadd.add_style('cursor: pointer;') long_cell2 = table.add_cell(bottom_buttons) long_cell2.add_attr('align', 'right') long_cell2.add_attr('valign', 'bottom') long_cell2.add_style('width: 100%') bottom = Table() bottom.add_attr('width', '100%') bottom.add_attr('cellpadding', '0') bottom.add_attr('cellspacing', '0') for title in titles: title_sk = title.get_search_key() title_row = bottom.add_row() title_row.add_attr('width', '100%') title_row.add_attr('class', 'row_%s' % title_sk) title_obj = TitleRow(sk=title_sk, parent_sk=my.sk, parent_sid=my.sid, groups_str=my.groups_str, user=my.user, display_mode=my.disp_mode, is_master=my.is_master_str, main_obj=title) content_cell = bottom.add_cell(title_obj) content_cell.add_attr('width', '100%') content_cell.add_attr('sk', title_sk) content_cell.add_attr('order_sk', my.sk) content_cell.add_attr('parent_sk', my.sk) content_cell.add_attr('parent_sid', my.sid) content_cell.add_attr('call_me', title.get_value('title')) content_cell.add_attr('episode', title.get_value('episode')) content_cell.add_attr('my_class', 'TitleRow') content_cell.add_attr('client_code', title.get_value('client_code')) content_cell.add_attr('class', 'cell_%s' % title_sk) tab2ret = Table() tab2ret.add_attr('width', '100%') tab2ret.add_row() tab2ret.add_cell(table) tab2ret.add_row() bot = tab2ret.add_cell(bottom) bot.add_style('padding-left: 40px;') return tab2ret
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 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
def get_display(my): my.sob_code = str(my.kwargs.get("sob_code")) my.sob_sk = str(my.kwargs.get("sob_sk")) my.sob_st = str(my.kwargs.get("sob_st")) my.sob_name = str(my.kwargs.get("sob_name")) my.pipeline = str(my.kwargs.get("pipeline")) my.order_sk = str(my.kwargs.get("order_sk")) order_code = my.order_sk.split("code=")[1] if "is_master" in my.kwargs.keys(): my.is_master = my.kwargs.get("is_master") 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 if my.sob_st == "twog/title": my.prereq_st = "twog/title_prereq" my.prereq_field = "title_code" elif my.sob_st == "twog/work_order": my.prereq_st = "twog/work_order_prereq" my.prereq_field = "work_order_code" 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 prereq_search = Search(my.prereq_st) prereq_search.add_filter(my.prereq_field, my.sob_code) prereqs = prereq_search.get_sobjects() overhead = Table() overhead.add_attr("class", "overhead_%s" % my.sob_code) table = Table() table.add_attr("class", "prereq_adder_%s" % my.sob_code) table.add_row() if my.sob_st == "twog/work_order" and user_is_scheduler: kill_title_pqs_btn = table.add_cell('<input type="button" value="Remove\nTitle PreReqs"/>') kill_title_pqs_btn.add_attr("colspan", "2") kill_title_pqs_btn.add_behavior( get_kill_wos_title_prereqs_behavior(my.sob_sk, my.order_sk, my.sob_name, my.pipeline) ) else: table.add_cell(" ") table.add_cell(" ") table.add_cell(" ") table.add_cell(" ") sat = table.add_cell("Satisfied?") sat.add_attr("align", "center") table.add_cell(" ") for p in prereqs: table.add_row() if user_is_scheduler: killer = table.add_cell(my.x_butt) killer.add_style("cursor: pointer;") killer.add_behavior( get_prereq_killer_behavior( p.get_value("code"), my.prereq_st, my.sob_code, my.sob_sk, my.sob_st, my.sob_name, my.pipeline, my.order_sk, ) ) prereq_text = "PreReq: " if my.sob_st == "twog/work_order": if p.get_value("from_title") == True: prereq_text = "Title PreReq: " alabel = table.add_cell(prereq_text) alabel.add_attr("align", "center") table.add_cell( '<input type="text" class="prereq_%s" value="%s" style="width: 500px;"/>' % (p.get_value("code"), p.get_value("prereq")) ) save_butt = table.add_cell('<input type="button" class="save_%s" value="Save"/>' % (p.get_value("code"))) save_butt.add_behavior( get_save_prereq_behavior(p.get_value("code"), my.prereq_st, my.sob_code, my.pipeline) ) if p.get_value("satisfied") == True: check_val = "true" else: check_val = "false" checkbox = CustomCheckboxWdg( name="satisfied_%s" % p.get_value("code"), value_field=p.get_value("code"), checked=check_val, dom_class="prereq_selector", code=p.get_value("code"), additional_js=get_change_satisfied_behavior( p.get_value("code"), my.prereq_st, my.sob_code, p.get_value("satisfied"), my.sob_sk, my.sob_st, my.sob_name, my.pipeline, my.order_sk, ), ) ck = table.add_cell(checkbox) ck.add_attr("align", "center") if my.is_master: if my.sob_st == "twog/title": table.add_cell(" ") templ_search = Search("twog/pipeline_prereq") templ_search.add_filter("pipeline_code", my.pipeline) templ_search.add_filter("prereq", p.get_value("prereq")) templ_rez = templ_search.get_sobjects() templ_count = len(templ_rez) if templ_count == 0: template_button = ButtonSmallNewWdg( title="Template This PreReq", icon=CustomIconWdg.icons.get("TEMPLATE") ) if my.is_master and user_is_scheduler: template_button.add_behavior( get_template_prereq_behavior( my.sob_code, my.pipeline, my.prereq_st, 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 = table.add_cell(template_button) tb.add_class("prereq_templ_%s" % p.get_value("code")) elif my.sob_st == "twog/work_order": table.add_cell(" ") wot_search = Search("twog/work_order") wot_search.add_filter("code", my.sob_code) wot = wot_search.get_sobject() work_order_templ_code = wot.get_value("work_order_templ_code") templ_search = Search("twog/work_order_prereq_templ") templ_search.add_filter("work_order_templ_code", work_order_templ_code) templ_search.add_filter("prereq", p.get_value("prereq")) templ_rez = templ_search.get_sobjects() templ_count = len(templ_rez) if templ_count == 0: template_button = ButtonSmallNewWdg( title="Template This PreReq", icon=CustomIconWdg.icons.get("TEMPLATE") ) if my.is_master: template_button.add_behavior( get_template_wo_prereq_behavior( my.sob_code, my.prereq_st, p.get_value("code"), work_order_templ_code ) ) else: template_button = '<img border="0" style="vertical-align: middle" title="Templated" name="Templated" src="/context/icons/silk/tick.png">' tb = table.add_cell(template_button) tb.add_class("prereq_templ_%s" % p.get_value("code")) table.add_row() table.add_cell("<hr/>") table.add_row() table.add_cell(" ") if user_is_scheduler: label = table.add_cell("New PreReq: ") label.add_attr("nowrap", "nowrap") prereq_text_wdg = TextWdg("new_prereq") prereq_text_wdg.add_behavior( get_create_prereq_change_behavior( my.sob_code, my.prereq_st, my.sob_sk, my.sob_st, my.sob_name, my.pipeline, my.order_sk ) ) table.add_cell(prereq_text_wdg) create_butt = table.add_cell('<input type="button" class="create_prereq" value="Create"/>') create_butt.add_behavior( get_create_prereq_behavior( my.sob_code, my.prereq_st, my.sob_sk, my.sob_st, my.sob_name, my.pipeline, my.order_sk ) ) overhead.add_row() oh_cell = overhead.add_cell(table) oh_cell.add_attr("class", "prereq_adder_cell") return overhead
def get_display(my): in_ob = 'true' if 'order_sk' in my.kwargs.keys(): my.order_sk = my.kwargs.get('order_sk') else: work_order_code = my.kwargs.get('work_order_code') my.code = work_order_code top_order = my.server.eval("@SOBJECT(twog/work_order['code','%s'].twog/proj.twog/title.twog/order)" % work_order_code)[0] my.order_sk = top_order.get('__search_key__') if 'code' in my.kwargs.keys(): my.code = my.kwargs.get('code') order_code = my.order_sk.split('code=')[1] if 'display_mode' in my.kwargs.keys(): my.disp_mode = my.kwargs.get('display_mode') if my.disp_mode == 'Small': my.small = True 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') user_group_names = Environment.get_group_names() if my.groups_str in [None,'']: for mg in user_group_names: if my.groups_str == '': my.groups_str = mg else: my.groups_str = '%s,%s' % (my.groups_str, mg) 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: main_obj = my.server.eval("@SOBJECT(twog/order['code','%s'])" % order_code)[0] if main_obj.get('classification') in ['Master','master']: my.is_master = True my.is_master_str = 'true' if 'in_ob' in my.kwargs.keys(): in_ob = my.kwargs.get('in_ob') table = Table() table.add_attr('class','error_entry_%s' % my.order_sk) table.add_style('background-color: #797676;') table.add_row() top_tbl = Table() #Create checkbox tables of common reasons for errors video_tbl = my.make_check_table(my.video_reasons, my.video_reasons_arr, None, my.order_sk, 'Video', '#ffef91') audio_tbl = my.make_check_table(my.audio_reasons, my.audio_reasons_arr, None, my.order_sk, 'Audio', '#ffefa1') metadata_tbl = my.make_check_table(my.metadata_reasons, my.metadata_reasons_arr, None, my.order_sk, 'MetaData', '#ffefb1') subtitle_tbl = my.make_check_table(my.subtitle_reasons, my.subtitle_reasons_arr, None, my.order_sk, 'Subtitle', '#ffefc1') cc_tbl = my.make_check_table(my.cc_reasons, my.cc_reasons_arr, None, my.order_sk, 'CC', '#ffefd1') cause_sel = SelectWdg('rejection_cause_%s' % my.order_sk) cause_sel.append_option('--Select--', '--Select--') for cause in my.rejection_causes: cause_sel.append_option(cause, cause) error_types = ['Internal Error', 'External Error'] type_sel = SelectWdg('err_type_sel_%s' % my.order_sk) for error_type in error_types: type_sel.append_option(error_type, error_type) top_tbl.add_cell('Error Type: ') top_tbl.add_cell(type_sel) top_tbl.add_cell(' Cause: ') top_tbl.add_cell(cause_sel) time_spent = top_tbl.add_cell('Time Spent (on Each): ') time_spent_text = top_tbl.add_cell('<input type="text" class="err_time_spent_%s"/>' % my.order_sk) table.add_cell(top_tbl) table.add_row() op_dt = Table() op_dt.add_row() op1 = op_dt.add_cell('Description of Error') op1.add_attr('align','left') op_dt.add_row() #Create textarea for operator decription op_dt.add_cell('<textarea cols="45" rows="10" class="err_operator_description_%s"></textarea>' % my.order_sk) table.add_cell(op_dt) act_t = Table() act_t.add_row() act_t.add_cell('Action Taken') act_t.add_row() #Create textarea for operator decription act_t.add_cell('<textarea cols="45" rows="10" class="err_action_taken_%s"></textarea>' % my.order_sk) #Add the reason checkbox tables table.add_cell(act_t) table.add_row() table.add_cell(video_tbl) table.add_row() table.add_cell(audio_tbl) table.add_row() table.add_cell(metadata_tbl) table.add_row() table.add_cell(subtitle_tbl) table.add_row() table.add_cell(cc_tbl) #Only show the responsible people list if the user is in the technical_services or senior staff depts show_responsible = False for gl in user_group_names: if gl in ['technical services','senior_staff']: show_responsible = True if show_responsible: #Display the table containing workers to assign blame table.add_row() table.add_cell(my.make_login_table()) table.add_row() table.add_cell(' ') butt = table.add_cell('<input type="button" value="Apply To Selected Work Orders"/>') butt.add_attr('align','right') butt.add_behavior(my.get_submit_errors_behavior(my.code, in_ob)) return table
def get_display(my): my.title_code = str(my.kwargs.get('title_code')) my.title_sk = str(my.kwargs.get('title_sk')) my.order_sk = str(my.kwargs.get('order_sk')) origin_search = Search("twog/title_origin") origin_search.add_filter('title_code',my.title_code) origins = origin_search.get_sobjects() groups_str = '' user_group_names = Environment.get_group_names() 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 table = Table() table.add_attr('width','100%s' % '%') table.add_attr('bgcolor','#cbe49e') 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() source_limit = 7 count = 0 if len(origins) > 0: table.add_row() mr_title = table.add_cell('<b><u><i>Sources</i></u></b>') mr_title.add_style('font-size: 90%s;' % '%') seen = [] for origin in origins: source_code = origin.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() if count % source_limit == 0: table.add_row() celly = None if not source.get_value('high_security'): celly = table.add_cell('<font color="#3e3e3e"><b><u>(%s): %s</u></b></font>' % (source.get_value('barcode'),source.get_value('title'))) else: celly = 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_source_behavior(my.title_code, my.title_sk, source.get_value('code'), source.get_search_key(), my.order_sk)) table.add_cell(' ') count += 1 else: my.server = TacticServerStub.get() my.server.retire_sobject(origin.get_search_key()) table2 = Table() if user_is_scheduler: table2.add_row() barcode_text_wdg = TextWdg('barcode_insert') barcode_text_wdg.add_behavior(my.get_barcode_insert_behavior(my.title_code, my.title_sk, my.order_sk)) bct = table2.add_cell(barcode_text_wdg) bct.add_attr('align','right') bct.add_attr('width','100%s' % '%') two_gether = Table() two_gether.add_row() srcs = two_gether.add_cell(table) srcs.add_attr('width','100%s' % '%') srcs.add_attr('valign','top') if user_is_scheduler: bcentry = two_gether.add_cell(table2) bcentry.add_attr('valign','top') return two_gether
def get_display(my): my.order_sk = my.kwargs.get('order_sk') order_code = my.order_sk.split('code=')[1] my.groups_str = None if 'display_mode' in my.kwargs.keys(): my.disp_mode = my.kwargs.get('display_mode') if my.disp_mode == 'Small': my.small = True 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) 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: server = TacticServerStub.get() main_obj = server.eval("@SOBJECT(twog/order['code','%s'])" % order_code)[0] if main_obj.get('classification') in ['master', 'Master']: my.is_master = True my.is_master_str = 'true' # Get the javascript functions table = Table() table.add_attr('class', 'qe_top_%s' % my.order_sk) table.add_attr('width', '100%') table.add_row() type_checks_tbl = Table() long_row = type_checks_tbl.add_row() long_row.add_attr('width', '100%') title_check = CustomCheckboxWdg(name='qe_titles_%s' % my.order_sk, value_field='title', checked='false', dom_class='quick_edit_selector') type_checks_tbl.add_cell(title_check) type_checks_tbl.add_cell('Titles') proj_check = CustomCheckboxWdg(name='qe_projects_%s' % my.order_sk, value_field='projects', checked='false', dom_class='quick_edit_selector') type_checks_tbl.add_cell(proj_check) type_checks_tbl.add_cell('Projects') wo_check = CustomCheckboxWdg(name='qe_work_orders_%s' % my.order_sk, value_field='work orders', checked='false', dom_class='quick_edit_selector') type_checks_tbl.add_cell(wo_check) wo = type_checks_tbl.add_cell('Work Orders') wo.add_attr('nowrap', 'nowrap') eq_check = CustomCheckboxWdg(name='qe_equipment_%s' % my.order_sk, value_field='equipment', checked='false', dom_class='quick_edit_selector') type_checks_tbl.add_cell(eq_check) type_checks_tbl.add_cell('Equipment') group_selector = my.get_assigned_group_select(None, 'group_selector') group_selector.add_behavior(get_select_checks_by_group_behavior(my.order_sk)) type_checks_tbl.add_cell(' ') sbd = type_checks_tbl.add_cell('Select by Dept:') sbd.add_attr('nowrap', 'nowrap') type_checks_tbl.add_cell(group_selector) tog_check = CustomCheckboxWdg(name='qe_toggler', additional_js=my.get_toggle_select_check_behavior(), value_field='toggler', id='selection_toggler', checked='false') last_cell = type_checks_tbl.add_cell(tog_check) last_cell.add_attr('width', '100%') last_cell.add_attr('align', 'right') lc1 = type_checks_tbl.add_cell('Select/Deselect All In Table') lc1.add_attr('width', '100%') lc1.add_attr('align', 'right') lc1.add_attr('nowrap', 'nowrap') long_cell = table.add_cell(type_checks_tbl) long_cell.add_attr('colspan', '8') table.add_row() table.add_cell('Platform: ') # Get the list of platforms from the db # Create the platform select wdg platforms = my.server.eval("@GET(twog/platform['@ORDER_BY','name'].name)") platform_sel = SelectWdg('platform_sel_%s' % my.order_sk) platform_sel.append_option('--Select--', '--Select--') for platform in platforms: platform_sel.append_option(platform, platform) table.add_cell(platform_sel) # Create the territory select wdg territories = my.territory_str.split('|') territory_sel = SelectWdg('territory_sel_%s' % my.order_sk) territory_sel.append_option('--Select--', '--Select--') for territory in territories: territory_sel.append_option(territory, territory) table.add_cell('Territory: ') table.add_cell(territory_sel) # Create the languages select wdg languages = my.language_str.split('|') language_sel = SelectWdg('language_sel_%s' % my.order_sk) language_sel.append_option('--Select--', '--Select--') for language in languages: language_sel.append_option(language, language) table.add_cell('Language: ') table.add_cell(language_sel) # Create calendar input for start date sd = table.add_cell('Start Date: ') sd.add_attr('nowrap', 'nowrap') start = CalendarInputWdg("qe_start_date_%s" % my.order_sk) start.set_option('show_activator', True) start.set_option('show_confirm', False) start.set_option('show_text', True) start.set_option('show_today', False) start.set_option('read_only', False) start.get_top().add_style('width: 150px') start.set_persist_on_submit() start_date = table.add_cell(start) start_date.add_attr('nowrap', 'nowrap') # Create calendar input for due date dd = table.add_cell('Due Date: ') dd.add_attr('nowrap', 'nowrap') due = CalendarInputWdg("qe_due_date_%s" % my.order_sk) due.set_option('show_activator', True) due.set_option('show_confirm', False) due.set_option('show_text', True) due.set_option('show_today', False) due.set_option('read_only', False) due.get_top().add_style('width: 150px') due.set_persist_on_submit() due_date = table.add_cell(due) due_date.add_attr('nowrap', 'nowrap') table.add_cell('Priority: ') table.add_cell('<input type="text" name="qe_priority_%s"/>' % my.order_sk) table.add_row() # Statuses should pull from the database soon, so I won't have to adjust this list every time a new status is # added or removed statuses = ['Pending', 'Ready', 'On Hold', 'Client Response', 'Fix Needed', 'Rejected', 'In Progress', 'DR In Progress', 'Amberfin01 In Progress', 'Amberfin02 In Progress', 'BATON In Progress', 'Export In Progress', 'Need Buddy Check', 'Buddy Check In Progress', 'Completed'] status_sel = SelectWdg('eq_status_%s' % my.order_sk) status_sel.append_option('--Select--', '--Select--') for status in statuses: status_sel.append_option(status, status) table.add_cell('Status: ') table.add_cell(status_sel) assigned_group_select = my.get_assigned_group_select(None, 'assigned_group_select') ag = table.add_cell('Assigned Group: ') ag.add_attr('nowrap', 'nowrap') table.add_cell(assigned_group_select) assigned_select = my.get_assigned_select(None) ad = table.add_cell('Assigned: ') ad.add_attr('nowrap', 'nowrap') table.add_cell(assigned_select) ewh = table.add_cell('Estimated Work Hours: ') ewh.add_attr('nowrap', 'nowrap') table.add_cell('<input type="text" name="qe_ewh_%s"/>' % my.order_sk) table.add_row() ed = table.add_cell('Expected Duration: ') ed.add_attr('nowrap', 'nowrap') table.add_cell('<input type="text" name="qe_ex_dur_%s"/>' % my.order_sk) exq = table.add_cell('Expected Quantity: ') exq.add_attr('nowrap', 'nowrap') table.add_cell('<input type="text" name="qe_ex_quan_%s"/>' % my.order_sk) # Submit button applies changes to everything in the order builder that is selected submit_button = table.add_cell('<input type="button" name="submit_button" value="Apply Changes"/>') submit_button.add_behavior(get_submit_quick_changes(my.order_sk, my.user)) # Add equipment to all work orders that are selected add_eq_button = table.add_cell('<input type="button" name="add_eq_button" value="Edit Equipment"/>') add_eq_button.add_behavior(get_eq_edit_behavior(my.order_sk, my.user)) last_chunk = table.add_cell(' ') last_chunk.add_attr('width', '100%') open_errors = table.add_cell('<u>Document Errors</u>') open_errors.add_attr('name', 'qe_error_opener_%s' % my.order_sk) open_errors.add_style('cursor: pointer;') open_errors.add_behavior(get_open_errors_behavior(my.order_sk)) # Button to delete selected objects delete_button = table.add_cell('<input type="button" name="delete_button" value="Delete Selected"/>') delete_button.add_behavior(get_qe_delete(my.order_sk, my.user)) # This is where the scheduler can enter production errors. It is hidden until "Document Errors" is clicked errors_row = table.add_row() errors_row.add_attr('class', 'qe_errors_row_%s' % my.order_sk) errors_row.add_style('display: none;') errors_wdg = ErrorEntryWdg(order_sk=my.order_sk, code='NOCODE', user=my.user, groups_str=my.groups_str, display_mode=my.disp_mode) errors_cell = table.add_cell(errors_wdg) errors_cell.add_attr('colspan', '10') return table
def get_display(my): from scraper import * my.order_sk = my.kwargs.get('order_sk') order_code = my.order_sk.split('code=')[1] my.groups_str = my.kwargs.get('groups_str') main_obj = None if 'display_mode' in my.kwargs.keys(): my.disp_mode = my.kwargs.get('display_mode') if my.disp_mode == 'Small': my.small = True 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) 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: server = TacticServerStub.get() main_obj = server.eval("@SOBJECT(twog/order['code','%s'])" % order_code)[0] if main_obj.get('classification') in ['master', 'Master']: my.is_master = True my.is_master_str = 'true' user_is_scheduler = False if 'scheduling' in my.groups_str or 'onboarding' in my.groups_str: user_is_scheduler = True if main_obj in [None, '']: server = TacticServerStub.get() main_obj = server.eval("@SOBJECT(twog/order['code','%s'])" % order_code)[0] table = Table() table.add_attr('cellspacing', '3') table.add_attr('cellpadding', '3') table.add_attr('height', '100%') table.add_attr('bgcolor', '#e4e6f0') 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') # NEW START table.add_row() title = table.add_cell(' <i><b>2G Order Builder</b></i> ') title.add_attr('nowrap', 'nowrap') title.add_style('font-size: 120%;') selected_obj = table.add_cell('') selected_obj.add_attr('class', 'selected_sobject') selected_obj.add_attr('width', '100%') associator_launcher = OrderAssociatorLauncherWdg(code=order_code, search_on_load='false') associator = table.add_cell(associator_launcher) associator.add_attr('align', 'right') if main_obj.get('imdb_url') not in [None, '', 'none']: lnk = table.add_cell('<a href="%s" target="_blank">Link</a>' % main_obj.get('imdb_url')) else: lnk = table.add_cell("No Link") lnk.add_attr('align', 'left') lnk.add_attr('nowrap', 'nowrap') table.add_cell(' ') refresher = ButtonSmallNewWdg(title="Refresh", icon=CustomIconWdg.icons.get('REFRESH')) refresher.add_behavior(get_refresh_behavior(my.order_sk, my.user)) refr = table.add_cell(refresher) refr.add_attr('align', 'right') checker_launcher = OrderCheckerLauncherWdg(order_code=order_code) checker = table.add_cell(checker_launcher) checker.add_attr('align', 'right') if user_is_scheduler: global_replacer = ButtonSmallNewWdg(title="Global Replacer", icon=CustomIconWdg.icons.get('DEPENDENCY')) global_replacer.add_behavior(get_global_replacer_wdg(my.order_sk, my.user)) globalr = table.add_cell(global_replacer) globalr.add_attr('align', 'right') if my.small: normal_edit = ButtonSmallNewWdg(title="Normal Edit", icon=CustomIconWdg.icons.get('NORMAL_EDIT')) normal_edit.add_behavior(get_quick_edit_behavior(my.order_sk, my.user)) normr = table.add_cell(normal_edit) normr.add_attr('align', 'right') else: quick_edit = ButtonSmallNewWdg(title="Quick Edit", icon=CustomIconWdg.icons.get('QUICK_EDIT')) quick_edit.add_behavior(get_quick_edit_behavior(my.order_sk, my.user)) quickr = table.add_cell(quick_edit) quickr.add_attr('align', 'right') clear_cache = ButtonSmallNewWdg(title="Clear Cache", icon=CustomIconWdg.icons.get('TRASH')) clear_cache.add_behavior(get_clear_cache_behavior(my.order_sk, my.user)) clearc = table.add_cell(clear_cache) clearc.add_attr('align', 'right') source_adder = ButtonSmallNewWdg(title="Create New Source", icon=CustomIconWdg.icons.get('SOURCE_ADD_TAPE')) source_adder.add_behavior(get_create_source_behavior(my.order_sk)) sexa = table.add_cell(source_adder) sexa.add_attr('align', 'right') eq_exp = ButtonSmallNewWdg(title="Show Equipment", icon=CustomIconWdg.icons.get('ARROW_OUT_EQUIPMENT')) eq_exp.add_behavior(get_equipment_expander_behavior(my.order_sk)) eqb = table.add_cell(eq_exp) eqb.add_attr('align', 'right') eq_coll = ButtonSmallNewWdg(title="Hide Equipment", icon=CustomIconWdg.icons.get('ARROW_UP_EQUIPMENT')) eq_coll.add_behavior(get_equipment_collapser_behavior(my.order_sk)) eqlb = table.add_cell(eq_coll) eqlb.add_attr('align', 'right') source_exp = ButtonSmallNewWdg(title="Show Sources", icon=CustomIconWdg.icons.get('ARROW_OUT_SOURCE')) source_exp.add_behavior(get_source_expander_behavior(my.order_sk)) sexb = table.add_cell(source_exp) sexb.add_attr('align', 'right') source_coll = ButtonSmallNewWdg(title="Hide Sources", icon=CustomIconWdg.icons.get('ARROW_UP_SOURCE')) source_coll.add_behavior(get_source_collapser_behavior(my.order_sk)) sclb = table.add_cell(source_coll) sclb.add_attr('align', 'right') expander_button = ButtonSmallNewWdg(title="Expand All", icon=CustomIconWdg.icons.get('ARROW_OUT')) expander_button.add_behavior(get_expander_behavior(my.order_sk)) exb = table.add_cell(expander_button) exb.add_attr('align', 'right') collapser_button = ButtonSmallNewWdg(title="Collapse All", icon=CustomIconWdg.icons.get('ARROW_UP_GREEN')) collapser_button.add_behavior(get_collapser_behavior(my.order_sk)) clb = table.add_cell(collapser_button) clb.add_attr('align', 'right') space = table.add_cell(' ') space.add_attr('width', '100%') return table
def get_display(my): web = WebContainer.get_web() widget = Widget() html = HtmlElement("html") is_xhtml = False if is_xhtml: web.set_content_type("application/xhtml+xml") widget.add('''<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> ''') html.add_attr("xmlns", "http://www.w3.org/1999/xhtml") #html.add_attr("xmlns:svg", "http://www.w3.org/2000/svg") # add the copyright widget.add(my.get_copyright_wdg()) widget.add(html) # create the header head = HtmlElement("head") html.add(head) head.add( '<meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>\n' ) head.add('<meta http-equiv="X-UA-Compatible" content="IE=edge"/>\n') # Add the tactic favicon head.add( '<link rel="shortcut icon" href="/context/favicon.ico" type="image/x-icon"/>' ) # add the css styling head.add(my.get_css_wdg()) # add the title in the header project = Project.get() project_code = project.get_code() project_title = project.get_value("title") if web.is_admin_page(): is_admin = " - Admin" else: is_admin = "" if project_code == 'admin': head.add("<title>TACTIC Site Admin</title>\n") else: head.add("<title>%s%s</title>\n" % (project_title, is_admin)) # add the javascript libraries head.add(JavascriptImportWdg()) # add the body body = my.body html.add(body) body.add_event('onload', 'spt.onload_startup(this)') top = my.top # Add a NOSCRIPT tag block here to provide a warning message on browsers where 'Enable JavaScript' # is not checked ... TODO: clean up and re-style to make look nicer top.add(""" <NOSCRIPT> <div style="border: 2px solid black; background-color: #FFFF99; color: black; width: 600px; height: 70px; padding: 20px;"> <img src="%s" style="border: none;" /> <b>Javascript is not enabled on your browser!</b> <p>This TACTIC powered, web-based application requires JavaScript to be enabled in order to function. In your browser's options/preferences, please make sure that the 'Enable JavaScript' option is checked on, click OK to accept the settings change, and then refresh this web page.</p> </div> </NOSCRIPT> """ % (IconWdg.get_icon_path("ERROR"))) # add the content content_div = DivWdg() top.add(content_div) Container.put("TopWdg::content", content_div) # add a dummy button for global behaviors from tactic.ui.widget import ButtonNewWdg, IconButtonWdg ButtonNewWdg(title="DUMMY", icon=IconWdg.FILM) IconButtonWdg(title="DUMMY", icon=IconWdg.FILM) # NOTE: it does not need to be in the DOM. Just needs to be # instantiated #content_div.add(button) if my.widgets: content_wdg = my.get_widget('content') else: content_wdg = Widget() my.add(content_wdg) content_div.add(content_wdg) # add a calendar wdg from tactic.ui.widget import CalendarWdg cal_wdg = CalendarWdg(css_class='spt_calendar_template_top') cal_wdg.top.add_style('display: none') content_div.add(cal_wdg) if web.is_admin_page(): from tactic_branding_wdg import TacticCopyrightNoticeWdg branding = TacticCopyrightNoticeWdg(show_license_info=True) top.add(branding) # add the admin bar security = Environment.get_security() if not web.is_admin_page() and security.check_access( "builtin", "view_site_admin", "allow"): div = DivWdg() top.add(div) top.add_style("padding-top: 21px") div.add_class("spt_admin_bar") div.add_style("height: 15px") div.add_style("padding: 3px 0px 3px 15px") #div.add_style("margin-bottom: -5px") div.add_style("position: fixed") div.add_style("top: 0px") div.add_style("left: 0px") div.add_style("opacity: 0.7") div.add_style("width: 100%") #div.add_gradient("background", "background2", 20, 10) div.add_style("background-color", "#000") div.add_style("color", "#FFF") div.add_style("z-index", "1000") div.add_class("hand") div.set_box_shadow("0px 5px 5px") # remove icon_div = DivWdg() div.add(icon_div) icon_div.add_style("float: right") icon_div.add_style("margin-right: 10px") icon_div.add_style("margin-top: -3px") icon_button = IconButtonWdg(title="Remove Admin Bar", icon=IconWdg.G_CLOSE) icon_div.add(icon_button) icon_button.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var parent = bvr.src_el.getParent(".spt_admin_bar"); bvr.src_el.getParent(".spt_top").setStyle("padding-top", "0px"); spt.behavior.destroy_element(parent); ''' }) div.add("<b>ADMIN >></b>") div.add_behavior({ 'type': 'listen', 'event_name': 'close_admin_bar', 'cbjs_action': ''' bvr.src_el.getParent(".spt_top").setStyle("padding-top", "0px"); spt.behavior.destroy_element(bvr.src_el); ''' }) div.add_behavior({ 'type': 'mouseover', 'cbjs_action': ''' bvr.src_el.setStyle("opacity", 0.85) //new Fx.Tween(bvr.src_el).start('height', "30px"); ''' }) div.add_behavior({ 'type': 'mouseout', 'cbjs_action': ''' bvr.src_el.setStyle("opacity", 0.7) //new Fx.Tween(bvr.src_el).start('height', "15px"); ''' }) project_code = Project.get_project_code() div.add_behavior({ 'type': 'click_up', 'cbjs_action': ''' var url = "/tactic/%s/admin/link/_startup"; window.open(url); ''' % project_code }) # Add the script editor listener load_div = DivWdg() top.add(load_div) load_div.add_behavior({ 'type': 'listen', 'event_name': 'show_script_editor', 'cbjs_action': ''' var js_popup_id = "TACTIC Script Editor"; var js_popup = $(js_popup_id); if( js_popup ) { spt.popup.toggle_display( js_popup_id, false ); } else { spt.panel.load_popup(js_popup_id, "tactic.ui.app.ShelfEditWdg", {}, {"load_once": true} ); } ''' }) # deal with the palette defined in /index which can override the palette if my.kwargs.get("hash") == (): key = "index" search = Search("config/url") search.add_filter("url", "/%s/%%" % key, "like") search.add_filter("url", "/%s" % key) search.add_where("or") url = search.get_sobject() if url: xml = url.get_xml_value("widget") palette_key = xml.get_value("element/@palette") # look up palette the expression for index from pyasm.web import Palette palette = Palette.get() palette.set_palette(palette_key) colors = palette.get_colors() colors = jsondumps(colors) script = HtmlElement.script(''' var env = spt.Environment.get(); env.set_colors(%s); env.set_palette('%s'); ''' % (colors, palette_key)) top.add(script) env = Environment.get() client_handoff_dir = env.get_client_handoff_dir(include_ticket=False, no_exception=True) client_asset_dir = env.get_client_repo_dir() login = Environment.get_login() user_name = login.get_value("login") user_id = login.get_id() login_groups = Environment.get_group_names() # add environment information script = HtmlElement.script(''' var env = spt.Environment.get(); env.set_project('%s'); env.set_user('%s'); env.set_user_id('%s'); var login_groups = '%s'.split('|'); env.set_login_groups(login_groups); env.set_client_handoff_dir('%s'); env.set_client_repo_dir('%s'); ''' % (Project.get_project_code(), user_name, user_id, '|'.join(login_groups), client_handoff_dir, client_asset_dir)) top.add(script) # add a global container for commonly used widgets div = DivWdg() top.add(div) div.set_id("global_container") # add in the app busy widget # find out if there is an override for this search = Search("config/url") search.add_filter("url", "/app_busy") url = search.get_sobject() if url: busy_div = DivWdg() div.add(busy_div) busy_div.add_class("SPT_PUW") busy_div.add_styles( "display: none; position: absolute; z-index: 1000") busy_div.add_class("app_busy_msg_block") busy_div.add_style("width: 300px") busy_div.add_style("height: 100px") busy_div.add_style("padding: 20px") busy_div.add_color("background", "background3") busy_div.add_border() busy_div.set_box_shadow() busy_div.set_round_corners(20) busy_div.set_attr("id", "app_busy_msg_block") # put the custom url here title_wdg = DivWdg() busy_div.add(title_wdg) title_wdg.add_style("font-size: 20px") title_wdg.add_class("spt_app_busy_title") busy_div.add("<hr/>") msg_div = DivWdg() busy_div.add(msg_div) msg_div.add_class("spt_app_busy_msg") else: from page_header_wdg import AppBusyWdg div.add(AppBusyWdg()) # popup parent popup = DivWdg() popup.set_id("popup") div.add(popup) # create another general popup popup_div = DivWdg() popup_div.set_id("popup_container") popup_div.add_class("spt_panel") popup = PopupWdg(id="popup_template", destroy_on_close=True) popup_div.add(popup) div.add(popup_div) inner_html_div = DivWdg() inner_html_div.set_id("inner_html") div.add(inner_html_div) # add in a global color from tactic.ui.input import ColorWdg color = ColorWdg() div.add(color) # add in a global notify wdg from notify_wdg import NotifyWdg widget.add(NotifyWdg()) return widget
def get_display(my): login = Environment.get_login() this_user = login.get_login() groups = Environment.get_group_names() my.get_stub() show_save = False for g in groups: if 'qc' in g or 'edeliveries' in g: show_save = True if this_user == 'admin': show_save = True this_timestamp = str(datetime.datetime.now()).split('.')[0] code = my.kwargs.get('code') original_code = code widget = DivWdg() if 'TITLE' in code: wos = my.server.eval("@GET(twog/work_order['title_code','%s'].code)" % code) if len(wos) > 0: code = wos[0] else: none_msg = 'THERE ARE NO WORK ORDERS IN THIS TITLE' none_tbl = Table() none_tbl.add_row() none_tbl.add_cell(none_msg) widget.add(none_tbl) return widget work_order = my.server.eval("@SOBJECT(twog/work_order['code','%s'])" % code)[0] title = my.server.eval("@SOBJECT(twog/title['code','%s'])" % work_order.get('title_code'))[0] tech_code = '' tech = { 'code': '', 'description': '', 'timestamp': this_timestamp, 'login': this_user, 'barcode': '', 'client_code': '', 'client_name': '', 'title': title.get('title'), 'title_code': title.get('code'), 'episode': '', 'type': '', 'trt': '', 'part': '', 'label_date': '', 'capture_or_layoff': '', 'date': this_timestamp, 'order_code': work_order.get('order_code'), 'source_deck': '', 'record_deck': '', 'aspect_ratio': '', 'format': '', 'standard': '', 'timecode': '', 'text': '', 'vitc_lines': '', 'horiz_blank': '', 'active_video_lines': '', 'title_safe': '', 'error_logger': '', 'audio_ch01': '', 'audio_ch02': '', 'audio_ch03': '', 'audio_ch04': '', 'audio_ch05': '', 'audio_ch06': '', 'audio_ch07': '', 'audio_ch08': '', 'audio_ch09': '', 'audio_ch10': '', 'audio_ch11': '', 'audio_ch12': '', 'peak_ch01': '', 'peak_ch02': '', 'peak_ch03': '', 'peak_ch04': '', 'peak_ch05': '', 'peak_ch06': '', 'peak_ch07': '', 'peak_ch08': '', 'peak_ch09': '', 'peak_ch10': '', 'peak_ch11': '', 'peak_ch12': '', 'in_phase_0102': '', 'in_phase_0304': '', 'in_phase_0506': '', 'in_phase_0708': '', 'in_phase_0910': '', 'in_phase_1112': '', 'first_cut': '', 'first_cut_field': '', 'last_cut': '', 'last_cut_field': '', 'tc_verify': '', 'error_logger_messages': '', 'general_comments': '', 'operator': this_user, 'source_code': '', 'work_order_code': work_order.get('code'), 'wo_name': work_order.get('process') } if 'tech_code' in my.kwargs.keys(): tech_code = str(my.kwargs.get('tech_code')) if tech_code not in [None,'']: tech = my.server.eval("@SOBJECT(twog/tech_eval['code','%s'])" % tech_code)[0] else: tech_code = '' wo_evals = my.server.eval("@SOBJECT(twog/tech_eval['work_order_code','%s']['code','!=','%s'])" % (code, tech_code)) title_evals = my.server.eval("@SOBJECT(twog/tech_eval['title_code','%s']['work_order_code','!=','%s']['code','!=','%s'])" % (work_order.get('title_code'), work_order.get('code'), tech_code)) others = Table() others.add_style('background-color: #528B8B; width: 100%;') cols = ['#537072', '#518A1A'] colsct = 0 if len(title_evals) > 0: trrr = others.add_row() trrr.add_style('background-color: #50EDA1;') others.add_cell('<b>Other Tech Evals for Title</b>') for t in title_evals: click_row = others.add_row() click_row.add_attr('tech_code', t.get('code')) click_row.add_attr('work_order_code', t.get('work_order_code')) click_row.set_style('cursor: pointer; background-color: %s;' % cols[colsct % 2]) click_row.add_behavior(my.get_click_row(t.get('work_order_code'), t.get('code'))) others.add_cell('<b>WO:</b> %s, <b>CODE:</b> %s' % (t.get('wo_name'), t.get('work_order_code'))) others.add_cell('<b>OPERATOR:</b> %s' % t.get('operator')) others.add_cell('<b>DATETIME:</b> %s' % fix_date(t.get('date'))) colsct += 1 if len(wo_evals) > 0: wrrr = others.add_row() wrrr.add_style('background-color: #50EDA1;') others.add_cell('<b>Other Tech Evals for Work Order</b>') for w in wo_evals: click_row = others.add_row() click_row.add_attr('tech_code', w.get('code')) click_row.add_attr('work_order_code', w.get('work_order_code')) click_row.set_style('cursor: pointer; background-color: %s;' % cols[colsct % 2]) click_row.add_behavior(my.get_click_row(w.get('work_order_code'), w.get('code'))) others.add_cell('<b>WO:</b> %s, <b>CODE:</b> %s' % (w.get('wo_name'), w.get('work_order_code'))) others.add_cell('<b>OPERATOR:</b> %s' % w.get('operator')) others.add_cell('<b>DATETIME:</b> %s' % fix_date(w.get('date'))) colsct += 1 widget.add_attr('class', 'big_ol_tech_wdg_%s' % code) widget.add_attr('tech_code', tech.get('code')) table = Table() table.add_attr('class', 'printable_tech_form_%s' % code) table.add_attr('tech_code', tech.get('code')) table.add_attr('work_order_code', tech.get('work_order_code')) table.add_style('font-family: Calibri, sans-serif;') img_tbl = Table() img_tbl.add_row() i2 = Table() i2.add_row() i2.add_cell('<img src="/source_labels/2GLogo_small4.png"/>') img_tbl.add_cell(i2) ad = Table() ad.add_row() address = ad.add_cell('<b>2G Digital Post, Inc.</b><br/>280 E. Magnolia Blvd.<br/>Burbank, CA 91502<br/>310-840-0600<br/>www.2gdigitalpost.com') address.add_attr('nowrap', 'nowrap') address.add_style('font-size', '9px') img_tbl.add_cell(ad) rtbl = Table() rtbl.add_row() big = rtbl.add_cell("<b>LOAD/LAY-OFF TECH EVALUATION</b>") big.add_attr('nowrap', 'nowrap') big.add_attr('align', 'center') big.add_attr('valign', 'center') big.add_style('font-size', '40px') rtbl.add_cell('') toptbl = Table() toptbl.add_row() toptbl = Table() toptbl.add_row() toptbl.add_cell(img_tbl) toptbl.add_cell(rtbl) printtbl = Table() printtbl.add_style('background-color: #528B8B; width: 100%;') printtbl.add_row() p1 = printtbl.add_cell(' ') p1.add_style('width', '40%') p2 = printtbl.add_cell('<u><b>Print This Report</b></u>') p2.add_attr('nowrap','nowrap') p2.add_style('cursor: pointer;') p2.add_behavior(my.get_print_bvr(code, tech.get('code'), 'tech')) p3 = printtbl.add_cell(' ') p3.add_style('width', '40%') qcd = CalendarInputWdg("timestamp") qcd.set_option('show_activator', True) qcd.set_option('show_confirm', False) qcd.set_option('show_text', True) qcd.set_option('show_today', False) qcd.set_option('read_only', False) qcd.set_option('width', '120px') qcd.set_option('id', 'timestamp') if tech.get('timestamp') not in [None,'']: qcd.set_option('default', fix_date(tech.get('timestamp'))) qcd.get_top().add_attr('id','timestamp') qcd.set_persist_on_submit() lbld = CalendarInputWdg("label_date") lbld.set_option('show_activator', True) lbld.set_option('show_confirm', False) lbld.set_option('show_text', True) lbld.set_option('show_today', False) lbld.set_option('read_only', False) lbld.set_option('width', '120px') lbld.set_option('id', 'label_date') if tech.get('label_date') not in [None,'']: lbld.set_option('default', fix_date(tech.get('label_date'))) lbld.get_top().add_attr('id', 'label_date') lbld.set_persist_on_submit() majtbl = Table() majtbl.add_row() mt = majtbl.add_cell('2G BARCODE') mt.add_attr('align', 'left') mt.add_attr('nowrap', 'nowrap') mc = majtbl.add_cell('CLIENT') mc.add_attr('align', 'left') mc.add_attr('nowrap', 'nowrap') mp = majtbl.add_cell('ENTRY DATE') mp.add_attr('align', 'left') mp.add_attr('nowrap', 'nowrap') majtbl.add_row() majtbl.add_cell('<input type="text" value="%s" class="tech_r_var" id="barcode" style="width: 240px;"/>' % tech.get('barcode')) majtbl.add_cell('<input type="text" value="%s" class="tech_r_var" id="client_name" style="width: 340px;"/>' % tech.get('client_name')) majtbl.add_cell(qcd) titbl = Table() titbl.add_row() t1 = titbl.add_cell('TITLE') t1.add_attr('align', 'left') t2 = titbl.add_cell('EPISODE') t2.add_attr('align', 'left') titbl.add_row() titbl.add_cell('<input type="text" value="%s" class="tech_r_var" id="title" style="width: 340px;"/>' % tech.get('title')) titbl.add_cell('<input type="text" value="%s" class="tech_r_var" id="episode" style="width: 240px;"/>' % tech.get('episode')) majtbl.add_row() titc = majtbl.add_cell(titbl) titc.add_attr('colspan', '3') trtbl = Table() trtbl.add_row() tr1 = trtbl.add_cell('TYPE') tr1.add_attr('align', 'left') tr2 = trtbl.add_cell('TRT') tr2.add_attr('align', 'left') trtbl.add_row() trtbl.add_cell('<input type="text" value="%s" class="tech_r_var" id="type" style="width: 340px;"/>' % tech.get('type')) trtbl.add_cell('<input type="text" value="%s" class="tech_r_var" id="trt" style="width: 240px;"/>' % tech.get('trt')) majtbl.add_row() titr = majtbl.add_cell(trtbl) titr.add_attr('colspan', '3') dtbl = Table() dtbl.add_row() d1 = dtbl.add_cell('DESCRIPTION') d1.add_attr('valign', 'top') d2 = dtbl.add_cell('<textarea cols="100" rows="3" class="metadata_r_var" id="description">%s</textarea>' % tech.get('description')) d2tbl = Table() d2tbl.add_row() d2tbl.add_cell('PART') d2tbl.add_cell('<input type="text" value="%s" class="tech_r_var" id="part" style="width: 140px;"/>' % tech.get('part')) d2tbl.add_row() d21 = d2tbl.add_cell('LABEL DATE') d21.add_attr('nowrap', 'nowrap') d2tbl.add_cell(lbld) dtbl.add_cell(d2tbl) majtbl.add_row() titr = majtbl.add_cell(dtbl) titr.add_attr('colspan','3') radio = '<form class="navbar-form pull-right"><label><input type="radio" name="capture_or_layoff" value="capture" /> Capture</label><label><input type="radio" name="sex" value="layoff" /> Layoff</label></form>' ltbl = Table() ltbl.add_style('background-color: #4a4a4a;') ltbl.add_style('font-size: 15px;') ltbl.add_row() ltbl.add_cell(radio) majtbl.add_row() titr = majtbl.add_cell(ltbl) titr.add_attr('colspan', '3') table.add_row() table.add_cell(toptbl) table.add_row() table.add_cell(majtbl) stbl = Table() stbl.add_row() s1 = stbl.add_cell(' ') s1.add_style('width: 40%s;' % '%') s2 = stbl.add_cell('<input type="button" value="Save"/>') s2.add_behavior(my.get_save_bvr(code, tech.get('code'))) s3 = stbl.add_cell(' ') s3.add_style('width: 40%s;' % '%') if tech.get('code') not in [None,'']: s4 = stbl.add_cell('<input type="button" value="Delete This Report"/>') s4.add_behavior(my.get_delete_eval(code, tech.get('code'))) ttbl = Table() ttbl.add_style('background-color: #528B8B; width: 100%;') ttbl.add_row() tt1 = ttbl.add_cell(others) tt1.add_attr('width','100%') ttbl.add_row() tt2 = ttbl.add_cell(printtbl) tt2.add_attr('width','100%') widget.add(ttbl) widget.add(table) if show_save and 'TITLE' not in original_code: widget.add(stbl) widget.add(table) return widget