liquid_feedback_frontend

annotate app/main/index/_member_home.lua @ 595:bc6934411019

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

Impressum / About Us