| 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@1045 | 5 if not unit then | 
| bsw@1045 | 6   execute.view { module = "index", view = "404" } | 
| bsw@1045 | 7   request.set_status("404 Not Found") | 
| bsw@1045 | 8   return | 
| bsw@1045 | 9 end | 
| bsw@301 | 10 | 
| bsw@1045 | 11 | 
| bsw@1045 | 12 unit:load_delegation_info_once_for_member_id(app.session.member_id) | 
| bsw@301 | 13 | 
| bsw@301 | 14 local areas_selector = Area:build_selector{ active = true, unit_id = unit_id } | 
| bsw@301 | 15 areas_selector:add_order_by("member_weight DESC") | 
| bsw@301 | 16 | 
| bsw@301 | 17 local members_selector = Member:build_selector{ | 
| bsw@301 | 18   active = true, | 
| bsw@301 | 19   voting_right_for_unit_id = unit.id | 
| bsw@301 | 20 } | 
| bsw@301 | 21 | 
| bsw@301 | 22 local delegations_selector = Delegation:new_selector() | 
| bsw@301 | 23   :join("member", "truster", "truster.id = delegation.truster_id AND truster.active") | 
| bsw@302 | 24   :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 | 25   :join("member", "trustee", "trustee.id = delegation.trustee_id AND truster.active") | 
| bsw@302 | 26   :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 | 27   :add_where{ "delegation.unit_id = ?", unit.id } | 
| bsw@301 | 28 | 
| bsw@414 | 29 local open_issues_selector = Issue:new_selector() | 
| bsw@301 | 30   :join("area", nil, "area.id = issue.area_id") | 
| bsw@301 | 31   :add_where{ "area.unit_id = ?", unit.id } | 
| bsw@414 | 32   :add_where("issue.closed ISNULL") | 
| bsw@414 | 33   :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 | 34 | 
| bsw@414 | 35 local closed_issues_selector = Issue:new_selector() | 
| bsw@414 | 36   :join("area", nil, "area.id = issue.area_id") | 
| bsw@414 | 37   :add_where{ "area.unit_id = ?", unit.id } | 
| bsw@414 | 38   :add_where("issue.closed NOTNULL") | 
| bsw@414 | 39   :add_order_by("issue.closed DESC") | 
| bsw@301 | 40 | 
| bsw@1045 | 41 | 
| bsw@301 | 42 | 
| bsw@1045 | 43 execute.view { module = "unit", view = "_head", params = { unit = unit } } | 
| bsw@301 | 44 | 
| bsw@414 | 45 | 
| bsw@1045 | 46 execute.view { | 
| bsw@1045 | 47   module = "unit", view = "_sidebar", params = { | 
| bsw@1045 | 48     unit = unit | 
| bsw@414 | 49   } | 
| bsw@301 | 50 } | 
| bsw@301 | 51 | 
| bsw@1045 | 52 execute.view { | 
| bsw@1045 | 53   module = "unit", view = "_sidebar_whatcanido", params = { | 
| bsw@1045 | 54     unit = unit | 
| bsw@1045 | 55   } | 
| bsw@1045 | 56 } | 
| bsw@1045 | 57 | 
| bsw@1045 | 58 execute.view { | 
| bsw@1045 | 59   module = "unit", view = "_sidebar_members", params = { | 
| bsw@1045 | 60     unit = unit | 
| bsw@1045 | 61   } | 
| bsw@1045 | 62 } | 
| bsw@1045 | 63 | 
| bsw@1045 | 64 execute.view { | 
| bsw@1045 | 65   module = "issue", | 
| bsw@1045 | 66   view = "_list2", | 
| bsw@1045 | 67   params = { for_unit = unit, head = function () | 
| bsw@1045 | 68     ui.heading { attr = { class = "left" }, level = 1, content = unit.name } | 
| bsw@1045 | 69   end } | 
| bsw@1045 | 70 } | 
| bsw@1045 | 71 | 
| bsw@1045 | 72 --[[ | 
| bsw@870 | 73 if app.session:has_access("all_pseudonymous") then | 
| bsw@301 | 74   tabs[#tabs+1] = { | 
| bsw@525 | 75     name = "eligible_voters", | 
| bsw@525 | 76     label = _"Eligible voters", | 
| bsw@301 | 77     module = "member", | 
| bsw@301 | 78     view = "_list", | 
| bsw@301 | 79     params = { members_selector = members_selector } | 
| bsw@301 | 80   } | 
| bsw@301 | 81 | 
| bsw@301 | 82   tabs[#tabs+1] = { | 
| bsw@301 | 83     name = "delegations", | 
| bsw@301 | 84     label = _"Delegations", | 
| bsw@301 | 85     module = "delegation", | 
| bsw@301 | 86     view = "_list", | 
| bsw@301 | 87     params = { delegations_selector = delegations_selector } | 
| bsw@301 | 88   } | 
| bsw@301 | 89 end | 
| bsw@301 | 90 | 
| bsw@1045 | 91 ui.tabs(tabs) | 
| bsw@1045 | 92 | 
| bsw@1045 | 93 --]] |