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@414
|
47 local open_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@414
|
50 :add_where("issue.closed ISNULL")
|
bsw@414
|
51 :add_order_by("coalesce(issue.fully_frozen + issue.voting_time, issue.half_frozen + issue.verification_time, issue.accepted + issue.discussion_time, issue.created + issue.admission_time) - now()")
|
bsw@414
|
52
|
bsw@414
|
53 local closed_issues_selector = Issue:new_selector()
|
bsw@414
|
54 :join("area", nil, "area.id = issue.area_id")
|
bsw@414
|
55 :add_where{ "area.unit_id = ?", unit.id }
|
bsw@414
|
56 :add_where("issue.closed NOTNULL")
|
bsw@414
|
57 :add_order_by("issue.closed DESC")
|
bsw@301
|
58
|
bsw@301
|
59 local tabs = {
|
bsw@301
|
60 module = "unit",
|
bsw@301
|
61 view = "show",
|
bsw@301
|
62 id = unit.id
|
bsw@301
|
63 }
|
bsw@301
|
64
|
bsw@301
|
65 tabs[#tabs+1] = {
|
bsw@301
|
66 name = "areas",
|
bsw@301
|
67 label = _"Areas",
|
bsw@301
|
68 module = "area",
|
bsw@301
|
69 view = "_list",
|
bsw@301
|
70 params = { areas_selector = areas_selector }
|
bsw@301
|
71 }
|
bsw@301
|
72
|
bsw@301
|
73 tabs[#tabs+1] = {
|
bsw@414
|
74 name = "timeline",
|
bsw@414
|
75 label = _"Events",
|
bsw@414
|
76 module = "event",
|
bsw@414
|
77 view = "_list",
|
bsw@414
|
78 params = { for_unit = unit }
|
bsw@414
|
79 }
|
bsw@414
|
80
|
bsw@414
|
81 tabs[#tabs+1] = {
|
bsw@414
|
82 name = "open",
|
bsw@414
|
83 label = _"Open issues",
|
bsw@301
|
84 module = "issue",
|
bsw@301
|
85 view = "_list",
|
bsw@414
|
86 params = {
|
bsw@414
|
87 for_state = "open",
|
bsw@414
|
88 issues_selector = open_issues_selector, for_unit = true
|
bsw@414
|
89 }
|
bsw@414
|
90 }
|
bsw@414
|
91 tabs[#tabs+1] = {
|
bsw@414
|
92 name = "closed",
|
bsw@414
|
93 label = _"Closed issues",
|
bsw@414
|
94 module = "issue",
|
bsw@414
|
95 view = "_list",
|
bsw@414
|
96 params = {
|
bsw@414
|
97 for_state = "closed",
|
bsw@414
|
98 issues_selector = closed_issues_selector, for_unit = true
|
bsw@414
|
99 }
|
bsw@301
|
100 }
|
bsw@301
|
101
|
bsw@301
|
102 if app.session.member_id then
|
bsw@301
|
103 tabs[#tabs+1] = {
|
bsw@301
|
104 name = "members",
|
bsw@301
|
105 label = _"Members",
|
bsw@301
|
106 module = "member",
|
bsw@301
|
107 view = "_list",
|
bsw@301
|
108 params = { members_selector = members_selector }
|
bsw@301
|
109 }
|
bsw@301
|
110
|
bsw@301
|
111 tabs[#tabs+1] = {
|
bsw@301
|
112 name = "delegations",
|
bsw@301
|
113 label = _"Delegations",
|
bsw@301
|
114 module = "delegation",
|
bsw@301
|
115 view = "_list",
|
bsw@301
|
116 params = { delegations_selector = delegations_selector }
|
bsw@301
|
117 }
|
bsw@301
|
118 end
|
bsw@301
|
119
|
bsw@301
|
120 ui.tabs(tabs) |