From e519a05dbd8a7fe2d5c94cf6786d2bc396ddc40c Mon Sep 17 00:00:00 2001 From: Ted Trask Date: Mon, 28 Jun 2010 08:55:13 +0000 Subject: Added lastchange timestamp to definition table. --- did-editdefinition-html.lsp | 3 ++- did-html.lsp | 1 - did-model.lua | 9 +++++---- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/did-editdefinition-html.lsp b/did-editdefinition-html.lsp index 330f6bb..74b13bc 100644 --- a/did-editdefinition-html.lsp +++ b/did-editdefinition-html.lsp @@ -132,9 +132,10 @@ else %>

<%= html.html_escape(form.label) %>

<% displayformstart(form, page_info) %> <% - local order = {"did", "description", "identification", "department", "rules"} + local order = {"did", "description", "identification", "department", "lastchange", "rules"} if page_info.action == "editdefinition" then form.value.did.readonly = true + form.value.lastchange.readonly = true end form.value.rules.type = "hidden" for i,name in ipairs(order) do diff --git a/did-html.lsp b/did-html.lsp index c94d023..08adb01 100644 --- a/did-html.lsp +++ b/did-html.lsp @@ -2,7 +2,6 @@ require("viewfunctions") %> -<% -- local subdata, pagedata = paginate(data.value.definitions.value, page_info.clientdata, 15) %> <% local subdata = data.value.definitions.value %> <% local pagedata = data.value.pagedata.value %> diff --git a/did-model.lua b/did-model.lua index 121fbf5..42d81f8 100644 --- a/did-model.lua +++ b/did-model.lua @@ -25,7 +25,7 @@ local con local database_creation_script = { "CREATE AGGREGATE array_accum(anyelement) (SFUNC = array_append, STYPE = anyarray, INITCOND = '{}')", "CREATE TABLE dbhistlog (logdatetime timestamp(3) without time zone NOT NULL, msgtext text, userid text)", - "CREATE TABLE definition (did character varying(40) NOT NULL, identification character varying(7), department character varying(40), description character varying(255))", + "CREATE TABLE definition (did character varying(40) NOT NULL, identification character varying(7), department character varying(40), description character varying(255), lastchange timestamp without time zone)", "CREATE TABLE pubdid (did character varying(40), extension character varying(40), starttime time without time zone, endtime time without time zone, stale boolean)", "CREATE TABLE rule (did character varying(40) NOT NULL, extension character varying(40) NOT NULL, starttime time without time zone, endtime time without time zone, startdate date, enddate date, dayofweek bit(7))", "ALTER TABLE ONLY definition ADD CONSTRAINT definition_pkey PRIMARY KEY (did)", @@ -222,7 +222,7 @@ local getdefinitionentries = function(sql) cur = assert (con:execute(sql)) row = cur:fetch ({}, "a") while row do - entries[#entries+1] = {did=row.did, identification=row.identification, department=row.department, description=row.description, extension=row.extension} + entries[#entries+1] = {did=row.did, identification=row.identification, department=row.department, description=row.description, extension=row.extension,lastchange=row.lastchange} row = cur:fetch (row, "a") end -- close everything @@ -337,9 +337,9 @@ local findunuseddefinition = function(exchange) end local updatedefinitionentry = function(definition) - local sql = string.format("UPDATE definition SET identification='%s', department='%s', description='%s' WHERE did='%s'", + local sql = string.format("UPDATE definition SET identification='%s', department='%s', description='%s', lastchange='%s' WHERE did='%s'", escape(definition.identification), escape(definition.department), - escape(definition.description), escape(definition.did)) + escape(definition.description), os.date("%Y-%m-%d %H:%M:%S"), escape(definition.did)) local res = assert (con:execute(sql)) -- logme("Updated DID "..definition.did) return res @@ -845,6 +845,7 @@ function getdefinition(did) group.did = cfe({ value=stripdash(did) or "", label="DID" }) group.identification = cfe({ label="Identification Number" }) group.department = cfe({ label="Department" }) + group.lastchange = cfe({ label="Last Change" }) group.description = cfe({ label="Description" }) group.rules = cfe({ type="longtext", label="Rules", descr="One entry (extension, starttime, endtime, startdate, enddate, dayofweek) per line"}) if did then -- cgit v1.2.3