rev |
line source |
bsw@301
|
1 local unit_id = config.single_unit_id or param.get_id()
|
bsw@301
|
2
|
bsw@301
|
3 local unit = Unit:by_id(unit_id)
|
bsw@301
|
4
|
bsw@301
|
5 if not config.single_unit_id then
|
bsw@301
|
6 slot.put_into("title", unit.name)
|
bsw@301
|
7 else
|
bsw@301
|
8 slot.put_into("title", encode.html(config.app_title))
|
bsw@301
|
9 end
|
bsw@301
|
10
|
bsw@301
|
11 if config.single_unit_id and not app.session.member_id and config.motd_public then
|
bsw@301
|
12 local help_text = config.motd_public
|
bsw@301
|
13 ui.container{
|
bsw@301
|
14 attr = { class = "wiki motd" },
|
bsw@301
|
15 content = function()
|
bsw@301
|
16 slot.put(format.wiki_text(help_text))
|
bsw@301
|
17 end
|
bsw@301
|
18 }
|
bsw@301
|
19 end
|
bsw@301
|
20
|
bsw@301
|
21 util.help("unit.show", _"Unit")
|
bsw@301
|
22
|
bsw@301
|
23 if app.session.member_id then
|
bsw@301
|
24 execute.view{
|
bsw@301
|
25 module = "delegation",
|
bsw@301
|
26 view = "_show_box",
|
bsw@301
|
27 params = { unit_id = unit_id }
|
bsw@301
|
28 }
|
bsw@301
|
29 end
|
bsw@301
|
30
|
bsw@301
|
31
|
bsw@301
|
32 local areas_selector = Area:build_selector{ active = true, unit_id = unit_id }
|
bsw@301
|
33 areas_selector:add_order_by("member_weight DESC")
|
bsw@301
|
34
|
bsw@301
|
35 local members_selector = Member:build_selector{
|
bsw@301
|
36 active = true,
|
bsw@301
|
37 voting_right_for_unit_id = unit.id
|
bsw@301
|
38 }
|
bsw@301
|
39
|
bsw@301
|
40 local delegations_selector = Delegation:new_selector()
|
bsw@301
|
41 :join("member", "truster", "truster.id = delegation.truster_id AND truster.active")
|
bsw@302
|
42 :join("privilege", "truster_privilege", "truster_privilege.member_id = truster.id AND truster_privilege.unit_id = delegation.unit_id AND truster_privilege.voting_right")
|
bsw@301
|
43 :join("member", "trustee", "trustee.id = delegation.trustee_id AND truster.active")
|
bsw@302
|
44 :join("privilege", "trustee_privilege", "trustee_privilege.member_id = trustee.id AND trustee_privilege.unit_id = delegation.unit_id AND trustee_privilege.voting_right")
|
bsw@301
|
45 :add_where{ "delegation.unit_id = ?", unit.id }
|
bsw@301
|
46
|
bsw@301
|
47 local issues_selector = Issue:new_selector()
|
bsw@301
|
48 :join("area", nil, "area.id = issue.area_id")
|
bsw@301
|
49 :add_where{ "area.unit_id = ?", unit.id }
|
bsw@301
|
50
|
bsw@301
|
51
|
bsw@301
|
52 local tabs = {
|
bsw@301
|
53 module = "unit",
|
bsw@301
|
54 view = "show",
|
bsw@301
|
55 id = unit.id
|
bsw@301
|
56 }
|
bsw@301
|
57
|
bsw@301
|
58 tabs[#tabs+1] = {
|
bsw@301
|
59 name = "areas",
|
bsw@301
|
60 label = _"Areas",
|
bsw@301
|
61 module = "area",
|
bsw@301
|
62 view = "_list",
|
bsw@301
|
63 params = { areas_selector = areas_selector }
|
bsw@301
|
64 }
|
bsw@301
|
65
|
bsw@301
|
66 tabs[#tabs+1] = {
|
bsw@301
|
67 name = "issues",
|
bsw@301
|
68 label = _"Issues",
|
bsw@301
|
69 module = "issue",
|
bsw@301
|
70 view = "_list",
|
bsw@301
|
71 params = { issues_selector = issues_selector }
|
bsw@301
|
72 }
|
bsw@301
|
73
|
bsw@301
|
74 if app.session.member_id then
|
bsw@301
|
75 tabs[#tabs+1] = {
|
bsw@301
|
76 name = "members",
|
bsw@301
|
77 label = _"Members",
|
bsw@301
|
78 module = "member",
|
bsw@301
|
79 view = "_list",
|
bsw@301
|
80 params = { members_selector = members_selector }
|
bsw@301
|
81 }
|
bsw@301
|
82
|
bsw@301
|
83 tabs[#tabs+1] = {
|
bsw@301
|
84 name = "delegations",
|
bsw@301
|
85 label = _"Delegations",
|
bsw@301
|
86 module = "delegation",
|
bsw@301
|
87 view = "_list",
|
bsw@301
|
88 params = { delegations_selector = delegations_selector }
|
bsw@301
|
89 }
|
bsw@301
|
90 end
|
bsw@301
|
91
|
bsw@301
|
92 ui.tabs(tabs) |