def get_checkboxes_section(outer_div): checkboxes_div = DivWdg() bigboard_wdg = CheckboxWdg('bigboard', 'Hot Title?') no_charge_wdg = CheckboxWdg('no_charge', 'No Charge') redo_wdg = CheckboxWdg('redo', 'Redo') repurpose_wdg = CheckboxWdg('repurpose', 'Repurpose') bigboard_wdg.get_value() checkboxes_div.add(bigboard_wdg) checkboxes_div.add(no_charge_wdg) checkboxes_div.add(redo_wdg) checkboxes_div.add(repurpose_wdg) outer_div.add(checkboxes_div)
class ArtistViewWdg(SpanWdg): def init(self): self.add("Show assigned only: ") self.checkbox = CheckboxWdg("show_assigned_only") self.checkbox.set_option("value", "on") self.checkbox.set_persistence() self.checkbox.add_event("onclick", "document.form.submit()") self.add(self.checkbox) self.add_class("med") def is_supervisor(self): # if the user is a supervisor, look at all of the assets project = Project.get_project_name() security = Environment.get_security() return security.check_access("prod/%s" % project, "model/supervisor", "true") def is_artist(self): # if the user is a artist, look at all of the assets project = Project.get_project_name() security = Environment.get_security() return security.check_access("prod/%s" % project, "model/artist", "true") def alter_search(self, search): # get all of the relevant tasks to the user task_search = Search("sthpw/task") task_search.add_column("search_id") # only look at this project project = Project.get_project_name() task_search.add_filter("search_type", search.get_search_type()) # figure out who the user is security = Environment.get_security() login = security.get_login() user = login.get_value("login") print "is_artist: ", self.is_artist() print "is_supervisor: ", self.is_supervisor() # do some filtering web = WebContainer.get_web() show_assigned_only = self.checkbox.get_value() show_process = web.get_form_values("process") if not show_process or show_process[0] == '': show_process = [] show_task_status = web.get_form_values("task_status") if not show_task_status or show_task_status[0] == '': show_task_status = [] if show_assigned_only == "on": task_search.add_filter("assigned", user) if show_process: where = "process in (%s)" % ", ".join( ["'%s'" % x for x in show_process]) task_search.add_where(where) if show_task_status: where = "status in (%s)" % ", ".join( ["'%s'" % x for x in show_task_status]) task_search.add_where(where) else: task_search.add_where("NULL") # record the tasks self.tasks = task_search.get_sobjects() # get all of the sobject ids sobject_ids = ["'%s'" % x.get_value("search_id") for x in self.tasks] # get all of the sobjects related to this task if sobject_ids: search.add_where("id in (%s)" % ", ".join(sobject_ids))
class ArtistViewWdg(SpanWdg): def init(self): self.add("Show assigned only: ") self.checkbox = CheckboxWdg("show_assigned_only") self.checkbox.set_option("value", "on") self.checkbox.set_persistence() self.checkbox.add_event("onclick", "document.form.submit()") self.add(self.checkbox) self.add_class("med") def is_supervisor(self): # if the user is a supervisor, look at all of the assets project = Project.get_project_name() security = Environment.get_security() return security.check_access("prod/%s" % project, "model/supervisor", "true") def is_artist(self): # if the user is a artist, look at all of the assets project = Project.get_project_name() security = Environment.get_security() return security.check_access("prod/%s" % project, "model/artist", "true") def alter_search(self, search): # get all of the relevant tasks to the user task_search = Search("sthpw/task") task_search.add_column("search_id") # only look at this project project = Project.get_project_name() task_search.add_filter("search_type", search.get_search_type()) # figure out who the user is security = Environment.get_security() login = security.get_login() user = login.get_value("login") print "is_artist: ", self.is_artist() print "is_supervisor: ", self.is_supervisor() # do some filtering web = WebContainer.get_web() show_assigned_only = self.checkbox.get_value() show_process = web.get_form_values("process") if not show_process or show_process[0] == '': show_process = [] show_task_status = web.get_form_values("task_status") if not show_task_status or show_task_status[0] == '': show_task_status = [] if show_assigned_only == "on": task_search.add_filter("assigned", user) if show_process: where = "process in (%s)" % ", ".join( ["'%s'" % x for x in show_process] ) task_search.add_where(where) if show_task_status: where = "status in (%s)" % ", ".join( ["'%s'" % x for x in show_task_status] ) task_search.add_where(where) else: task_search.add_where("NULL") # record the tasks self.tasks = task_search.get_sobjects() # get all of the sobject ids sobject_ids = ["'%s'" % x.get_value("search_id") for x in self.tasks] # get all of the sobjects related to this task if sobject_ids: search.add_where( "id in (%s)" % ", ".join(sobject_ids) )