liquid_feedback_frontend

changeset 571:63eda58a870e

Fixed for loop in member home page
author bsw
date Tue Jun 19 23:21:34 2012 +0200 (2012-06-19)
parents b904fc12cc1a
children 1b799fcdae31
files app/main/index/_member_home.lua
line diff
     1.1 --- a/app/main/index/_member_home.lua	Tue Jun 19 23:18:39 2012 +0200
     1.2 +++ b/app/main/index/_member_home.lua	Tue Jun 19 23:21:34 2012 +0200
     1.3 @@ -36,81 +36,79 @@
     1.4  local units = Unit:new_selector():exec()
     1.5  
     1.6  for i, unit in ipairs(units) do
     1.7 -  if not member:has_voting_right_for_unit_id(unit.id) then
     1.8 -    break
     1.9 -  end
    1.10 -  local trustee_member = Member:new_selector()
    1.11 -    :join("delegation", nil, { "delegation.scope = 'unit' AND delegation.unit_id = ? AND delegation.trustee_id = member.id AND delegation.truster_id = ?", unit.id, member.id })
    1.12 -    :optional_object_mode()
    1.13 -    :exec()
    1.14 -  
    1.15 -  local areas_selector = Area:new_selector()
    1.16 -    :join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id })
    1.17 -    :add_where{ "area.unit_id = ?", unit.id }
    1.18 -    :add_where{ "area.active" }
    1.19 -    :add_order_by("area.member_weight DESC")
    1.20 -  
    1.21 -  local area_count = areas_selector:count()
    1.22 -  
    1.23 -  ui.container{ attr = { class = "member_area_list" }, content = function()
    1.24 -    ui.container{ attr = { class = "unit_head" }, content = function()
    1.25 -      ui.link{
    1.26 -        text = unit.name,
    1.27 -        module = "unit", view = "show", id = unit.id
    1.28 -      }
    1.29 +  if member:has_voting_right_for_unit_id(unit.id) then
    1.30 +    local trustee_member = Member:new_selector()
    1.31 +      :join("delegation", nil, { "delegation.scope = 'unit' AND delegation.unit_id = ? AND delegation.trustee_id = member.id AND delegation.truster_id = ?", unit.id, member.id })
    1.32 +      :optional_object_mode()
    1.33 +      :exec()
    1.34 +    
    1.35 +    local areas_selector = Area:new_selector()
    1.36 +      :join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id })
    1.37 +      :add_where{ "area.unit_id = ?", unit.id }
    1.38 +      :add_where{ "area.active" }
    1.39 +      :add_order_by("area.member_weight DESC")
    1.40 +    
    1.41 +    local area_count = areas_selector:count()
    1.42 +    
    1.43 +    ui.container{ attr = { class = "member_area_list" }, content = function()
    1.44 +      ui.container{ attr = { class = "unit_head" }, content = function()
    1.45 +        ui.link{
    1.46 +          text = unit.name,
    1.47 +          module = "unit", view = "show", id = unit.id
    1.48 +        }
    1.49  
    1.50 -      if trustee_member then
    1.51 -        local text = _("Unit delegated to '#{name}'", { name = trustee_member.name })
    1.52 -        ui.image{
    1.53 -          attr = { class = "delegation_arrow", alt = text, title = text },
    1.54 -          static = "delegation_arrow_24_horizontal.png"
    1.55 -        }
    1.56 +        if trustee_member then
    1.57 +          local text = _("Unit delegated to '#{name}'", { name = trustee_member.name })
    1.58 +          ui.image{
    1.59 +            attr = { class = "delegation_arrow", alt = text, title = text },
    1.60 +            static = "delegation_arrow_24_horizontal.png"
    1.61 +          }
    1.62 +          execute.view{
    1.63 +            module = "member_image",
    1.64 +            view = "_show",
    1.65 +            params = {
    1.66 +              member = trustee_member,
    1.67 +              image_type = "avatar",
    1.68 +              show_dummy = true,
    1.69 +              class = "micro_avatar",
    1.70 +              popup_text = text
    1.71 +            }
    1.72 +          }
    1.73 +        end
    1.74 +      end }
    1.75 +
    1.76 +      if area_count > 0 then
    1.77          execute.view{
    1.78 -          module = "member_image",
    1.79 -          view = "_show",
    1.80 -          params = {
    1.81 -            member = trustee_member,
    1.82 -            image_type = "avatar",
    1.83 -            show_dummy = true,
    1.84 -            class = "micro_avatar",
    1.85 -            popup_text = text
    1.86 -          }
    1.87 +          module = "area", view = "_list",
    1.88 +          params = { areas_selector = areas_selector, hide_membership = true }
    1.89          }
    1.90 +      elseif member:has_voting_right_for_unit_id(unit.id) then
    1.91 +        if for_member then
    1.92 +          ui.container{ attr = { class = "voting_priv_info" }, content = _"This member has voting privileges for this unit, but you ist not member of any of its areas." }
    1.93 +        else
    1.94 +          ui.container{ attr = { class = "voting_priv_info" }, content = _"You have voting privileges for this unit, but you are not member of any of its areas." }
    1.95 +        end
    1.96 +      end
    1.97 +      local max_area_count = Area:new_selector()
    1.98 +        :add_where{ "area.unit_id = ?", unit.id }
    1.99 +        :add_where{ "area.active" }
   1.100 +        :count()
   1.101 +      local more_area_count = max_area_count - area_count
   1.102 +      local delegated_count = Area:new_selector()
   1.103 +        :add_where{ "area.unit_id = ?", unit.id }
   1.104 +        :add_where{ "area.active" }
   1.105 +        :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id } )
   1.106 +        :add_where{ "membership.member_id ISNULL" }
   1.107 +        :join("delegation", nil, { "delegation.area_id = area.id AND delegation.truster_id = ?", member.id } )
   1.108 +        :count()
   1.109 +      if more_area_count > 0 then
   1.110 +        slot.put("<br />")
   1.111 +        ui.container{ attr = { class = "more_areas" }, content = function()
   1.112 +          ui.link{ content = _("#{count} more areas in this unit, #{delegated_count} of them are delegated", { count = more_area_count, delegated_count = delegated_count }), module = "unit", view = "show", id = unit.id }
   1.113 +        end }
   1.114        end
   1.115      end }
   1.116 -
   1.117 -    if area_count > 0 then
   1.118 -      execute.view{
   1.119 -        module = "area", view = "_list",
   1.120 -        params = { areas_selector = areas_selector, hide_membership = true }
   1.121 -      }
   1.122 -    elseif member:has_voting_right_for_unit_id(unit.id) then
   1.123 -      if for_member then
   1.124 -        ui.container{ attr = { class = "voting_priv_info" }, content = _"This member has voting privileges for this unit, but you ist not member of any of its areas." }
   1.125 -      else
   1.126 -        ui.container{ attr = { class = "voting_priv_info" }, content = _"You have voting privileges for this unit, but you are not member of any of its areas." }
   1.127 -      end
   1.128 -    end
   1.129 -    local max_area_count = Area:new_selector()
   1.130 -      :add_where{ "area.unit_id = ?", unit.id }
   1.131 -      :add_where{ "area.active" }
   1.132 -      :count()
   1.133 -    local more_area_count = max_area_count - area_count
   1.134 -    local delegated_count = Area:new_selector()
   1.135 -      :add_where{ "area.unit_id = ?", unit.id }
   1.136 -      :add_where{ "area.active" }
   1.137 -      :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id } )
   1.138 -      :add_where{ "membership.member_id ISNULL" }
   1.139 -      :join("delegation", nil, { "delegation.area_id = area.id AND delegation.truster_id = ?", member.id } )
   1.140 -      :count()
   1.141 -    if more_area_count > 0 then
   1.142 -      slot.put("<br />")
   1.143 -      ui.container{ attr = { class = "more_areas" }, content = function()
   1.144 -        ui.link{ content = _("#{count} more areas in this unit, #{delegated_count} of them are delegated", { count = more_area_count, delegated_count = delegated_count }), module = "unit", view = "show", id = unit.id }
   1.145 -      end }
   1.146 -    end
   1.147 -  end }
   1.148 -
   1.149 +  end
   1.150  end
   1.151  
   1.152  

Impressum / About Us