Module:RFX report: Difference between revisions

Content deleted Content added
Merge code by ProcrastinatingReader from sandbox
update from /sandbox. Implements support for RRfAs
 
(9 intermediate revisions by 7 users not shown)
Line 48:
return nil
end
local style = ''
local styleInline = ''
local status = rfxObject:getStatus()
if status == 'pending closure' then
style = ' style="background: #f8cdc6;" |'
styleInline = ' background: #f8cdc6;'
end
local page = rfxObject:getTitleObject().prefixedText
local user = rfxObject.user or rfxObject:getTitleObject().subpageText
Line 66 ⟶ 60:
end
colour = colour or ''
 
local stylepercentStr = mw.ustring.format( '%d', percent )
if percent == 0 and supports == 0 and opposes == 0 and neutrals == 0 then
percentStr = 'N/A'
elseif percent == 100 and opposes ~= 0 then
percentStr = '>99'
end
 
local votes
if supports and opposes and neutrals and percent then
votes = mw.ustring.format( [==[
| styleclass="textrfx-align: right;%sreport-number" | [[%s#Support|%d]]
| styleclass="textrfx-align: right;%sreport-number" | [[%s#Oppose|%d]]
| styleclass="textrfx-align: right;%sreport-number" | [[%s#Neutral|%d]]
| styleclass="textrfx-align:report-number right;rfx-report-percent" style="background: #%s; color: #202122" | %ds]==],
styleInline, page, supports,
styleInline, page, opposes,
styleInline, page, neutrals,
colour, percentpercentStr
)
else
votes = '\n| colspan="4" styleclass="background: #f8cdc6;rfx-report-error" | Error parsing votes'
end
if status then
Line 87 ⟶ 89:
status = 'Pending closure...'
end
status = mw.ustring.format( '\n| %s %s', style,.. status )
else
status = '\n| styleclass="background: #f8cdc6;rfx-report-error" | Error getting status'
end
local endTime = rfxObject.endTime
Line 96 ⟶ 98:
local time
if endTime and timeLeft then
time = mw.ustring.format( '\n| %s %s\n| %s %s', style, endTime, style, timeLeft )
else
time = '\n| colspan="2" styleclass="background: #f8cdc6;rfx-report-error" | Error parsing end time'
end
local dupes = rfxObject:dupesExist()
if dupes then
dupes = '<span class="'''rfx-report-dupes-yes">yes</span>'''"
elseif dupes == false then
dupes = 'no'
Line 110 ⟶ 112:
local report = rfxObject:getReport()
if report then
report = mw.ustring.format( '\n|%s [%s report]', style, tostring( report ) )
else
report = '\n| styleclass="background: #f8cdc6;rfx-report-error" | Report not found'
)end
local styleInlinepending_class = ''
if status == 'pending closure' then
pending_class = 'class="rfx-report-pending"'
end
return mw.ustring.format(
'\n|-%s\n|%s [[%s|%s]]%s%s%s\n| styleclass="textrfx-align: center;%sreport-dupes" | %s%s',
stylepending_class, page, user, votes, status, time, styleInline, dupes, report
)
end
Line 127 ⟶ 133:
elseif rfxType == 'rfb' then
rfxCaps = 'RfB'
elseif rfxType == 'rrfa' then
rfxCaps = 'RRfA'
else
return nil
end
return mw.ustring.format(
'\n|-\n! scope="col" | %s candidate !! scope="col" | <abbr title="Support">S</abbr> !! scope="col" | <abbr title="Oppose">O</abbr> !! scope="col" | <abbr title="Neutral">N</abbr> !! scope="col" | <abbr title="Support percentage (%% Support)">S %%</abbr> !! scope="col" | Status !! scope="col" | Ending (UTC) !! scope="col" | Time left !! scope="col" | <abbr title="Has duplicate votes?">Dups?</abbr> !! scope="col" | Report',
rfxCaps
)
Line 144 ⟶ 152:
local rfas = {}
local rfbs = {}
local rrfas = {}
for i, rfxPage in ipairs( rfxes ) do
local rfxObject = rfx.new( rfxPage )
Line 151 ⟶ 160:
elseif rfxObject.type == 'rfb' then
table.insert( rfbs, rfxObject )
elseif rfxObject.type == 'rrfa' then
table.insert( rrfas, rfxObject)
end
end
end
return rfas, rfbs, rrfas
end
 
local function makeReportRows()
local rfas, rfbs, rrfas = getRfasRfbsSeparate()
 
local ret = {}
if #rfas + #rrfas > 0 then
table.insert( ret, makeHeading( 'rfa' ) )
for i, rfaObject in ipairs( rfas ) do
table.insert( ret, makeRow( rfaObject ) )
end clear, float
for i, rrfaObject in ipairs( rrfas ) do
table.insert( ret, makeRow( rrfaObject ) )
end
end
if #rfbs > 0 then
table.insert( ret, makeHeading( 'rfb' ) )
Line 180 ⟶ 195:
local purgeLink = mw.title.getCurrentTitle():fullUrl( 'action=purge' )
local header = mw.ustring.format(
'\n|+ Requests for [[Wikipedia:Requests for adminship|adminship]] and [[Wikipedia:Requests for bureaucratship|bureaucratship]] <span class="rfx-report-purge plainlinks" style="float: right;"><small>[%s update]</small></span>',
purgeLink
)
local rows = makeReportRows() or ''
if rows == '' then
rows = '\n|-\n| colspan="10" | No current discussions. <smallspan class="rfx-report-recent">Recent RfAs: ([[WikipediaWP:Successful requestsRequests for adminship|successful]], [[Wikipedia:Unsuccessfulby adminshipyear|Recent candidacies (Chronological)|unsuccessfulRfAs]]), Recentrecent RfBs: ([[Wikipedia:Successful bureaucratship candidacies|successful]], [[Wikipedia:Unsuccessful bureaucratship candidacies|unsuccessful]])</smallspan>'
end
local style = args.style
local clearfloat = args.clearfloat or 'left'args.align
if not style then
if localnot float =or argsmw.text.trim(float) or args.align or== 'right' then
float = nil
local clear = args.clear or 'left'
style = mw.ustring.format(
'style="white-space:wrap; clear: %s; margin-top: 0em; margin-bottom: .5em; float: %s; padding: .5em 0em 0em 1.4em; background: #ffffff; border-collapse: collapse; border-spacing: 0;"',
clear, float
)
end
local styleclear = args.styleclear
return mw.ustring.format( '\n{| class="wikitable" %s%s%s\n|-\n|}', style, header, rows )
if not clear or mw.text.trim(clear) == '' then
clear = nil
end
local style = ''
if notfloat styleor clear then
style = string.format(
'style="%s%s"',
clear and ('clear: ' .. clear .. ';') or '',
float and ('float: ' .. float .. ';') or ''
)
end
 
return mw.getCurrentFrame():extensionTag{
name = 'templatestyles', args = { src = 'Module:RFX report/styles.css' }
} .. mw.ustring.format(
return mw.ustring.format( '\n{| class="wikitable rfx-report" %s%s%s\n|-\n|}', style, header, rows )
style,
header,
rows
)
end
 
function p.countRfas()
local rfas, rfbs, rrfas = getRfasRfbsSeparate()
return getTableLength(rfas)
end