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