Module:Article history/config: Difference between revisions

Content deleted Content added
use "code" param suffix instead of "id" - there is a one-one relationship of IDs to objects, but there can be multiple codes
move FFA detection from the main module, and put double statuses in the statuses table with an "isDouble" field, for simplicity of looking up codes
Line 765:
id = 'FFLC',
image = 'Cscr-former.svg'
},
['FFA/GA'] = {
id = 'FFA/GA',
isDouble = true,
statuses = {'FFA', 'GA'}
},
GA = {
Line 800 ⟶ 805:
image = 'Cscr-former.svg'
},
},
 
doubleStatuses = {
['FFA/GA'] = {
id = 'FFA/GA',
statuses = {'FFA', 'GA'}
}
},
 
Line 825 ⟶ 823:
},
},
 
getStatusIdFunction = function (articleHistoryObj)
-- Get the status ID. The status code is the code passed in from the
-- arguments, and the ID is the value contained in the config.
local statuses = articleHistoryObj.cfg.statuses
local statusCode = articleHistoryObj.args.currentstatus
local statusId = articleHistoryObj:getStatusId(statusCode)
 
-- Check for former featured articles.
if statusId ~= 'FA'
and statusId ~= 'FL'
and statusId ~= 'FFA'
and statusId ~= 'FFL'
and statusId ~= 'FFA/GA'
then
local ffaObj
for i = #articleHistoryObj.actions, 1, -1 do
local actionObj = articleHistoryObj.actions[i]
if actionObj.id == 'FAR' and actionObj:getResult() == 'demoted' then
ffaObj = actionObj
break
end
end
if ffaObj then
if not statusId then
-- @TODO: Error
elseif statusId == 'GA' then
statusId = 'FFA/GA'
elseif statusId ~= 'FFA' then
-- @TODO: Error -
end
end
end
 
return statusId
end,
 
-------------------------------------------------------------------------------