def wmDeleteTemplates(self): sDeleteArray = uiCommon.getAjaxArg("sDeleteArray") if len(sDeleteArray) < 36: raise InfoException("Unable to delete - no selection.") sDeleteArray = uiCommon.QuoteUp(sDeleteArray) # can't delete it if it's referenced. sSQL = """select count(*) from deployment d join deployment_template dt on d.template_id = dt.template_id where dt.template_id in (%s)""" % sDeleteArray iResults = self.db.select_col_noexcep(sSQL) if not iResults: sSQL = "delete from deployment_template where template_id in (" + sDeleteArray + ")" if not self.db.tran_exec_noexcep(sSQL): uiCommon.log_nouser(self.db.error, 0) # if we made it here, save the logs uiCommon.WriteObjectDeleteLog(catocommon.CatoObjectTypes.DeploymentTemplate, "", "", "Templates(s) Deleted [" + sDeleteArray + "]") else: raise InfoException("Unable to delete - %d Deployments are referencing these templates." % iResults) return json.dumps({"result": "success"})
def DrawTableForType(self, sAccountID, sObjectType, dt): sHTML = "" # buld the table sHTML += "<table class=\"jtable\" cellspacing=\"1\" cellpadding=\"1\" width=\"99%\">" sHTML += "<tr>" sHTML += "<th class=\"chkboxcolumn\">" sHTML += "<input type=\"checkbox\" class=\"chkbox\" id=\"chkAll\" />" sHTML += "</th>" # loop column headers (by getting just one item in the dict) for prop in dt.itervalues().next(): sHTML += "<th>" sHTML += prop.Label sHTML += "</th>" sHTML += "</tr>" # loop rows # remember, the properties themselves have the value for sObjectID, props in dt.iteritems(): # crush the spaces... a javascript ID can't have spaces sJSID = sObjectID.strip().replace(" ", "") sHTML += "<tr>" sHTML += "<td class=\"chkboxcolumn\">" # not drawing the checkbox if there's no ID defined if sObjectID: sHTML += "<input type=\"checkbox\" class=\"chkbox\"" \ " id=\"chk_" + sJSID + "\"" \ " object_id=\"" + sObjectID + "\"" \ " tag=\"chk\" />" sHTML += "</td>" # loop data columns for prop in props: uiCommon.log_nouser("%s - %s" % (prop.Name, prop.Value), 3) sValue = (prop.Value if prop.Value else "") sHTML += "<td>" # should we try to show an icon? if prop.HasIcon and sValue: sHTML += "<img class=\"custom_icon\" src=\"static/images/custom/" + prop.Name.replace(" ", "").lower() + "_" + sValue.replace(" ", "").lower() + ".png\" alt=\"\" />" # if this is the "Tags" column, it might contain some xml... break 'em down if prop.Name == "Tags" and sValue: try: xDoc = catocommon.ET.fromstring(sValue) if xDoc is not None: sTags = "" for xeTag in xDoc.findall("item"): sTags += "<b>%s</b> : %s<br />" % (xeTag.findtext("key", ""), xeTag.findtext("value", "")) sHTML += sTags except: # couldn't parse it. hmmm.... uiCommon.log_nouser(traceback.format_exc()) # I guess just stick the value in there, but make it safe sHTML += uiCommon.SafeHTML(sValue) else: sHTML += (sValue if sValue else " ") # we're building a table, empty cells should still have sHTML += "</td>" sHTML += "</tr>" sHTML += "</table>" return sHTML