summaryrefslogtreecommitdiffstats
path: root/gnats-controller.lua
diff options
context:
space:
mode:
authorMika Havela <mika.havela@gmail.com>2008-04-25 13:39:58 +0000
committerMika Havela <mika.havela@gmail.com>2008-04-25 13:39:58 +0000
commitb6269f672717c021e81da02e6332a06b6651612f (patch)
tree83def4abed77e05eb937e2c83606ad4cc7110e34 /gnats-controller.lua
parent61f6393e8cc80635c33a7d77eb5b8208b768d4fa (diff)
downloadacf-gnats-b6269f672717c021e81da02e6332a06b6651612f.tar.bz2
acf-gnats-b6269f672717c021e81da02e6332a06b6651612f.tar.xz
Bugfix on SendBugreport.
Edit configurationfiles starts working. Started to work on EditPR (still not working). git-svn-id: svn://svn.alpinelinux.org/acf/gnats/trunk@1038 ab2d0c66-481e-0410-8bed-d214d4d58bed
Diffstat (limited to 'gnats-controller.lua')
-rw-r--r--gnats-controller.lua107
1 files changed, 92 insertions, 15 deletions
diff --git a/gnats-controller.lua b/gnats-controller.lua
index 57a9d04..d5926ba 100644
--- a/gnats-controller.lua
+++ b/gnats-controller.lua
@@ -98,20 +98,30 @@ local descr = {
}
-- ################################################################################
--- PUBLIC FUNCTIONS
+-- LOCAL FUNCTIONS
+
+local function list_redir(self)
+ self.conf.action = "status"
+ self.conf.type = "redir"
+ error (self.conf)
+end
-default_action = "status"
+
+-- ################################################################################
+-- PUBLIC FUNCTIONS
+mvc = {}
+function mvc.on_load(self, parent)
+ if (self.worker[self.conf.action] == nil ) or ( self.conf.action == "init" ) then
+ self.worker[self.conf.action] = list_redir(self)
+ end
+end
function status(self)
return { status=self.model.getstatus() }
end
---[[
+---[[
function expert(self)
- local modifications = self.clientdata.filecontent or ""
- if ( self.clientdata.cmdsave ) then
- modifications = self.model:update_filecontent(modifications)
- end
local url = ENV["SCRIPT_NAME"] .. self.conf.prefix .. self.conf.controller
local status=self.model.getstatus()
@@ -124,9 +134,6 @@ function expert(self)
value="Apply",
type="submit",
})
- if (self.clientdata.cmdsave) then
- file.cmdsave.descr="* Changes has been saved!"
- end
return ( {
option={ script=ENV["SCRIPT_NAME"],
@@ -144,8 +151,9 @@ function edit(self)
-- Save changes
local modifications = self.clientdata.filecontent or ""
+ local cmdresult, cmdresultmsg
if ( self.clientdata.cmdsave ) then
- modifications = self.model:update_filecontent(modifications,self.clientdata.name)
+ cmdresult, cmdresultmsg = self.model:update_filecontent(modifications,self.clientdata.name)
end
local status = self.model:getstatus(self)
@@ -164,7 +172,8 @@ function edit(self)
value="Save",
type="submit",
})
- if (modifications) then
+
+ if (cmdresult) then
file.cmdsave.descr="* Changes has been saved!"
end
@@ -178,7 +187,6 @@ function edit(self)
modifications = modifications,
file = file,
status = status,
- startstop = startstop,
}
end
--]]
@@ -257,7 +265,7 @@ function queryresult(self)
if (tonumber(pr_id)) then
query.header, query.sfields, query.mfields = self.model:read_pr(pr_id)
else
- redirect(self)
+ list_redir(self)
end
local myform = query.header
@@ -292,6 +300,24 @@ function queryresult(self)
local checkstring2 = 0
table.insert(audit_trail_table, cfe({class="", label=""}))
+ local tags = { "organization", "environment", "description", "how_to_repeat", "fix", "release_note", }
+ for k,val in pairs(tags) do
+ query.mfields[val].type="longtext"
+ end
+
+ local tags = { "category", "severity", "priority", "class", "state", }
+ for k,val in pairs(tags) do
+ query.sfields[val] = cfe({
+ name=val,
+ label=(descr.labels[val] or val),
+ value=query.sfields[val].value,
+ type="select",
+ option=self.model:get_select_opt(val),
+ })
+ -- If there is only a limited amount records, then present as radio buttons.
+ if (#query.sfields[val].option < 6) then query.sfields[val].type="radio" end
+ end
+
for k,v in pairs(format.string_to_table(query.mfields.audit_trail.value, "\n")) do
if (v == "") then
checkstring2 = checkstring2 + 1
@@ -474,7 +500,10 @@ function report(self)
if (noerrorsexists) then
local bugreport = {}
table.insert(bugreport, "To: " .. (bugreportreceiver or ""))
- table.insert(bugreport, "From: " .. (self.clientdata.from or ""))
+ if not (self.clientdata.reporter_name) or (#self.clientdata.reporter_name == 0) then
+ self.clientdata.reporter_name = "unknown"
+ end
+ table.insert(bugreport, "From: " .. self.clientdata.reporter_name .. " <" .. (self.clientdata.from or "") .. ">")
table.insert(bugreport, "Reply-To: " .. (self.clientdata.from or ""))
table.insert(bugreport, "")
for k,v in pairs({"reporter_id", "notify_list", "originator", "synopsis", "confidential", "severity",
@@ -513,3 +542,51 @@ end
function reportsuccess()
-- Just show that the report was successfully sent.
end
+
+function queryeditpr(self)
+ local query = {}
+
+ query.pr = cfe({
+ name="pr",
+ label="Query a specific PR number:",
+ })
+ query.pr_cmd = cfe({
+ name="pr_cmd",
+ label="Submit the query",
+ type="submit",
+ value="Submit",
+ })
+ return {
+ option={ script=ENV["SCRIPT_NAME"],
+ prefix=self.conf.prefix,
+ controller = self.conf.controller,
+ action = "edit",
+ extra = "",
+ },
+ query = query,
+ }
+
+end
+function editpr(self)
+ local queryresult = queryresult(self)
+ local query = queryresult.query
+
+ query.cmdsave = cfe({
+ name="cmdsave",
+ label="Save above changes",
+ type="submit",
+ disabled="yes",
+ errtxt="This button doesn't work. Still don't know howto send this edited information into gnats.",
+ value="Submit",
+ })
+
+ return {
+ option={ script=ENV["SCRIPT_NAME"],
+ prefix=self.conf.prefix,
+ controller = self.conf.controller,
+ action = "edit",
+ extra = "",
+ },
+ query = query,
+ }
+end