liquid_feedback_frontend
view app/main/member/_area_list.lua @ 417:2570b9fff7e0
Fix displaying wrong delegation (again)
author | bsw |
---|---|
date | Sat Mar 10 17:41:55 2012 +0100 (2012-03-10) |
parents | 5a50d566f040 |
children | a31fce559540 |
line source
1 local member = param.get("member", "table")
2 local units = member.units_with_voting_right
4 for i, unit in ipairs(units) do
5 local trustee_member = Member:new_selector()
6 :join("delegation", nil, { "delegation.scope = 'unit' AND delegation.unit_id = ? AND delegation.trustee_id = member.id AND delegation.truster_id = ?", unit.id, member.id })
7 :optional_object_mode()
8 :exec()
10 local areas_selector = Area:new_selector()
11 :join("membership", nil, { "membership.area_id = area.id AND membership.member_id = ?", member.id })
12 :add_where{ "area.unit_id = ?", unit.id }
13 :add_order_by("area.member_weight DESC")
15 local area_count = areas_selector:count()
17 ui.container{ attr = { class = "member_area_list" }, content = function()
18 ui.container{ attr = { class = "unit_head" }, content = function()
19 ui.link{
20 text = unit.name,
21 module = "unit", view = "show", id = unit.id
22 }
24 if trustee_member then
25 local text = _("Unit delegated to '#{name}'", { name = trustee_member.name })
26 ui.image{
27 attr = { class = "delegation_arrow", alt = text, title = text },
28 static = "delegation_arrow_24_horizontal.png"
29 }
30 execute.view{
31 module = "member_image",
32 view = "_show",
33 params = {
34 member = trustee_member,
35 image_type = "avatar",
36 show_dummy = true,
37 class = "micro_avatar",
38 popup_text = text
39 }
40 }
41 end
42 end }
44 if area_count > 0 then
45 execute.view{
46 module = "area", view = "_list",
47 params = { areas_selector = areas_selector, hide_membership = true }
48 }
49 else
50 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." }
51 end
52 ui.container{ content = function()
53 ui.link{ content = _"Show all areas of unit", module = "unit", view = "show", id = unit.id }
54 end }
56 end }
58 end