liquid_feedback_frontend

diff app/main/unit/show.lua @ 301:22e4e26717ac

Show issues, members and delegations for units
author bsw
date Sun Feb 26 14:15:27 2012 +0100 (2012-02-26)
parents
children 12a578e75f3e
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/app/main/unit/show.lua	Sun Feb 26 14:15:27 2012 +0100
     1.3 @@ -0,0 +1,92 @@
     1.4 +local unit_id = config.single_unit_id or param.get_id()
     1.5 +
     1.6 +local unit = Unit:by_id(unit_id)
     1.7 +
     1.8 +if not config.single_unit_id then
     1.9 +  slot.put_into("title", unit.name)
    1.10 +else
    1.11 +  slot.put_into("title", encode.html(config.app_title))
    1.12 +end
    1.13 +
    1.14 +if config.single_unit_id and not app.session.member_id and config.motd_public then
    1.15 +  local help_text = config.motd_public
    1.16 +  ui.container{
    1.17 +    attr = { class = "wiki motd" },
    1.18 +    content = function()
    1.19 +      slot.put(format.wiki_text(help_text))
    1.20 +    end
    1.21 +  }
    1.22 +end
    1.23 +
    1.24 +util.help("unit.show", _"Unit")
    1.25 +
    1.26 +if app.session.member_id then
    1.27 +  execute.view{
    1.28 +    module = "delegation",
    1.29 +    view = "_show_box",
    1.30 +    params = { unit_id = unit_id }
    1.31 +  }
    1.32 +end
    1.33 +
    1.34 +
    1.35 +local areas_selector = Area:build_selector{ active = true, unit_id = unit_id }
    1.36 +areas_selector:add_order_by("member_weight DESC")
    1.37 +
    1.38 +local members_selector = Member:build_selector{
    1.39 +  active = true,
    1.40 +  voting_right_for_unit_id = unit.id
    1.41 +}
    1.42 +
    1.43 +local delegations_selector = Delegation:new_selector()
    1.44 +  :join("member", "truster", "truster.id = delegation.truster_id AND truster.active")
    1.45 +  :join("privilege", "truster_privilege", "truster_privilege.member_id = truster.id AND truster_privilege.voting_right")
    1.46 +  :join("member", "trustee", "trustee.id = delegation.trustee_id AND truster.active")
    1.47 +  :join("privilege", "trustee_privilege", "trustee_privilege.member_id = trustee.id AND trustee_privilege.voting_right")
    1.48 +  :add_where{ "delegation.unit_id = ?", unit.id }
    1.49 +
    1.50 +local issues_selector = Issue:new_selector()
    1.51 +  :join("area", nil, "area.id = issue.area_id")
    1.52 +  :add_where{ "area.unit_id = ?", unit.id }
    1.53 +  
    1.54 +
    1.55 +local tabs = {
    1.56 +  module = "unit",
    1.57 +  view = "show",
    1.58 +  id = unit.id
    1.59 +}
    1.60 +
    1.61 +tabs[#tabs+1] = {
    1.62 +  name = "areas",
    1.63 +  label = _"Areas",
    1.64 +  module = "area",
    1.65 +  view = "_list",
    1.66 +  params = { areas_selector = areas_selector }
    1.67 +}
    1.68 +
    1.69 +tabs[#tabs+1] = {
    1.70 +  name = "issues",
    1.71 +  label = _"Issues",
    1.72 +  module = "issue",
    1.73 +  view = "_list",
    1.74 +  params = { issues_selector = issues_selector }
    1.75 +}
    1.76 +
    1.77 +if app.session.member_id then
    1.78 +  tabs[#tabs+1] = {
    1.79 +    name = "members",
    1.80 +    label = _"Members",
    1.81 +    module = "member",
    1.82 +    view = "_list",
    1.83 +    params = { members_selector = members_selector }
    1.84 +  }
    1.85 +
    1.86 +  tabs[#tabs+1] = {
    1.87 +    name = "delegations",
    1.88 +    label = _"Delegations",
    1.89 +    module = "delegation",
    1.90 +    view = "_list",
    1.91 +    params = { delegations_selector = delegations_selector }
    1.92 +  }
    1.93 +end
    1.94 +
    1.95 +ui.tabs(tabs)
    1.96 \ No newline at end of file

Impressum / About Us