liquid_feedback_frontend
view app/main/index/_member_home.lua @ 585:b489613c99d5
Fixed a typo in german translation
| author | bsw | 
|---|---|
| date | Wed Jun 20 21:32:02 2012 +0200 (2012-06-20) | 
| parents | 63eda58a870e | 
| children | 487cca534fbe | 
 line source
     1 local member = param.get("member", "table")
     2 local for_member = param.get("for_member", atom.boolean)
     3 local filter_unit = param.get_all_cgi()["filter_unit"] or "personal"
     6 execute.view{
     7   module = "index", view = "_notifications"
     8 }
    11 ui.container{ attr = { class = "ui_filter_head" }, content = function()
    13   ui.link{
    14     attr = { class = filter_unit == "personal" and "ui_tabs_link active" or nil },
    15     text = _"My units and areas",
    16     module = "index", view = "index", params = { filter_unit = "personal" }
    17   }
    19   slot.put(" ")
    21   ui.link{
    22     attr = { class = filter_unit == "global" and "active" or nil },
    23     text = _"All units",
    24     module = "index", view = "index", params = { filter_unit = "global" }
    25   }
    26 end }
    28 slot.put("<br />")
    31 if filter_unit == "global" then
    32   execute.view{ module = "unit", view = "_list" }
    33   return
    34 end
    36 local units = Unit:new_selector():exec()
    38 for i, unit in ipairs(units) do
    39   if member:has_voting_right_for_unit_id(unit.id) then
    40     local trustee_member = Member:new_selector()
    41       :join("delegation", nil, { "delegation.scope = 'unit' AND delegation.unit_id = ? AND delegation.trustee_id = member.id AND delegation.truster_id = ?", unit.id, member.id })
    42       :optional_object_mode()
    43       :exec()
    45     local areas_selector = Area:new_selector()
    46       :join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id })
    47       :add_where{ "area.unit_id = ?", unit.id }
    48       :add_where{ "area.active" }
    49       :add_order_by("area.member_weight DESC")
    51     local area_count = areas_selector:count()
    53     ui.container{ attr = { class = "member_area_list" }, content = function()
    54       ui.container{ attr = { class = "unit_head" }, content = function()
    55         ui.link{
    56           text = unit.name,
    57           module = "unit", view = "show", id = unit.id
    58         }
    60         if trustee_member then
    61           local text = _("Unit delegated to '#{name}'", { name = trustee_member.name })
    62           ui.image{
    63             attr = { class = "delegation_arrow", alt = text, title = text },
    64             static = "delegation_arrow_24_horizontal.png"
    65           }
    66           execute.view{
    67             module = "member_image",
    68             view = "_show",
    69             params = {
    70               member = trustee_member,
    71               image_type = "avatar",
    72               show_dummy = true,
    73               class = "micro_avatar",
    74               popup_text = text
    75             }
    76           }
    77         end
    78       end }
    80       if area_count > 0 then
    81         execute.view{
    82           module = "area", view = "_list",
    83           params = { areas_selector = areas_selector, hide_membership = true }
    84         }
    85       elseif member:has_voting_right_for_unit_id(unit.id) then
    86         if for_member then
    87           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." }
    88         else
    89           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." }
    90         end
    91       end
    92       local max_area_count = Area:new_selector()
    93         :add_where{ "area.unit_id = ?", unit.id }
    94         :add_where{ "area.active" }
    95         :count()
    96       local more_area_count = max_area_count - area_count
    97       local delegated_count = Area:new_selector()
    98         :add_where{ "area.unit_id = ?", unit.id }
    99         :add_where{ "area.active" }
   100         :left_join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id } )
   101         :add_where{ "membership.member_id ISNULL" }
   102         :join("delegation", nil, { "delegation.area_id = area.id AND delegation.truster_id = ?", member.id } )
   103         :count()
   104       if more_area_count > 0 then
   105         slot.put("<br />")
   106         ui.container{ attr = { class = "more_areas" }, content = function()
   107           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 }
   108         end }
   109       end
   110     end }
   111   end
   112 end
