Module:SOM.Page.School District

From SunshinePPS Wiki

Documentation for this module may be created at Module:SOM.Page.School District/doc

require("Module:No globals")

local DBA = require("Module:SOM.meta.DateBoundedAttribute")
local Page = require("Module:SOM.meta.Page")
local StringBuffer = require("Module:SOM.util.StringBuffer")
local util = require("Module:SOM.util")


local FreeWikitext = require("Module:SOM.Simple.FreeWikitext")
-- local HasMotto = require("Module:SOM.DateBounded.HasMotto")
local HasName = require("Module:SOM.DateBounded.HasName")
local HasWebsite = require("Module:SOM.DateBounded.HasWebsite")

-- local Superintendent = require("Module:SOM.DateBounded.Role.OrgPerson.DistrictSuperintendent")
-- local DeputySuperintendent = require("Module:SOM.DateBounded.Role.OrgPerson.DistrictDeputySuperintendent")


return Page.generate_page{
	class_name = "School District",
	parent_categories = { "Public Body" },
	category_description = [==[
A ''School District'' is a XXXXXXXYYYY.
]==],
	attributes = {
		names = {
			arg = "names",
			class = HasName,
			label = "Name"
		},
		websites = {
			arg = "websites",
			class = HasWebsite,
			label = "Website"
		},
--		mottos = {
--			arg = "mottos",
--			class = HasMotto,
--			label = "Motto"
--		},
--		principals = {
--			arg = "principals",
--			class = SchoolPrincipal,
--			label = "Principal",
--			link_to_key = "school"
--		},
		text = {
			arg = "text",
			class = FreeWikitext,
			label = "Article Text"
		},
	},
	form_layout = {
		{ section2 = "Basic Facts" },
--		{ table = {
--			{ attribute = "district" },
--			}
--		},
		{ section4 = "Names" },
		{ attribute = "names" },
		{ section4 = "Websites" },
		{ attribute = "websites" },
--		{ section4 = "Mottos" },
--		{ attribute = "mottos" },
		{ section2 = "Administration" },
--		{ section4 = "Principals" },
--		{ attribute = "principals" },
--		{ section4 = "Assistant Principals" },
--		{ attribute = "assistant_principals" },
		{ section2 = "Article Text" },
		{ attribute = "text" },
	},
	page_layout = {
		{ infobox = {
			{ attribute = "names", render = "render_current" },
			{ attribute = "websites", render = "render_current" },
--			{ attribute = "district" },
--			{ attribute = "mottos", render = "render_current" },
			{ section = "Administration" },
--			{ attribute = "principals", render = "render_current",
--				render_args = { key = "person"} },
--			{ attribute = "assistant_principals", render = "render_current",
--				render_args = { key = "person"} },
			}
		},
		{ attribute = "text" },
		{ references = {} },
		{ section2 = "Schools" },
		{ renderer = function(data, buffer)
			local query = {}
			local pagename = mw.title.getCurrentTitle().fullText
			table.insert(query,
				"[[Category:School]][[SOM/Belongs to school district::" .. pagename .. "]]")
			table.insert(query, "format=ul")
			table.insert(query, "limit=500")
			-- TODO maddog We need an smw.ask/etc wrapper that sanifies the API;
			--             i.e., it should return empty table for empty result set,
			--             not nil!
			local schools = mw.smw.ask(query) or {}
--			buffer:add(mw.dumpObject(schools)):nl():nl()
			for _, entry in ipairs(schools) do
				buffer:add_uformat("* %s", entry[1]):nl()
			end
		end
		},
		{ section2 = "Fact History" },
--		{ section5 = "Names" },
		{ attribute = "names", render = "render_table_and_references",
			render_args = HasName.basic_current_first_table_args() },
--		{ section5 = "Websites" },
		{ attribute = "websites", render = "render_table_and_references",
			render_args = HasWebsite.basic_current_first_table_args() },
--		{ section5 = "Mottos" },
--		{ attribute = "mottos", render = "render_table_and_references",
--			render_args = HasMotto.basic_current_first_table_args() },
--		{ section5 = "Principals" },
--		{ attribute = "principals", render = "render_table_and_references",
--			render_args = {
--				sort = DBA.sort_current_first,
--				columns = {
--					{ label = "Principal", key = "person" },
--					{ label = "Role", key = "role" },
--					{ label = "School", key = "school" },
--					DBA.COLUMN_FROM,
--					DBA.COLUMN_UNTIL,
--				}
--			}
--		},
--		{ section5 = "Assistant Principals" },
--		{ attribute = "assistant_principals", render = "render_table_and_references",
--			render_args = {
--				sort = DBA.sort_current_first,
--				columns = {
--					{ label = "Assistant Principal", key = "person" },
--					{ label = "Role", key = "role" },
--					{ label = "School", key = "school" },
--					DBA.COLUMN_FROM,
--					DBA.COLUMN_UNTIL,
--				}
--			}
--		},
	}
}