# HG changeset patch # User bsw # Date 1340920622 -7200 # Node ID a3eb6ca344841fd8efc294eeb122ff7e86db2ebb # Parent ea4c1b3a443c6f193e4a8fefe12d60d70bb14e7a Completed membership/privilege tab in member page diff -r ea4c1b3a443c -r a3eb6ca34484 app/main/area/_head.lua --- a/app/main/area/_head.lua Thu Jun 28 23:44:09 2012 +0200 +++ b/app/main/area/_head.lua Thu Jun 28 23:57:02 2012 +0200 @@ -1,4 +1,5 @@ local area = param.get("area", "table") +local member = param.get("member", "table") local show_content = param.get("show_content", atom.boolean) @@ -10,7 +11,7 @@ ui.container{ attr = { class = "area_head" }, content = function() - execute.view{ module = "delegation", view = "_info", params = { area = area } } + execute.view{ module = "delegation", view = "_info", params = { area = area, member = member } } ui.container{ attr = { class = "title" }, content = function() -- area name @@ -28,36 +29,37 @@ if app.session.member_id then -- membership - local membership = Membership:by_pk(area.id, app.session.member.id) + local membership = Membership:by_pk(area.id, member.id) if membership then - ui.tag{ content = _"You are participating in this area" } - - slot.put(" ") - - ui.tag{ content = function() - slot.put("(") - ui.link{ - text = _"Withdraw", - module = "membership", - action = "update", - params = { area_id = area.id, delete = true }, - routing = { - default = { - mode = "redirect", - module = request.get_module(), - view = request.get_view(), - id = param.get_id_cgi(), - params = param.get_all_cgi() + if app.session.member_id == member.id then + ui.tag{ content = _"You are participating in this area" } + ui.tag{ content = function() + slot.put("(") + ui.link{ + text = _"Withdraw", + module = "membership", + action = "update", + params = { area_id = area.id, delete = true }, + routing = { + default = { + mode = "redirect", + module = request.get_module(), + view = request.get_view(), + id = param.get_id_cgi(), + params = param.get_all_cgi() + } } } - } - slot.put(")") - end } - + slot.put(")") + end } + else + ui.tag{ content = _"Member is participating in this area" } + end + slot.put(" ") - elseif app.session.member:has_voting_right_for_unit_id(area.unit_id) then + elseif app.session.member_id == member.id and member:has_voting_right_for_unit_id(area.unit_id) then ui.link{ text = _"Participate in this area", module = "membership", @@ -75,7 +77,7 @@ } end - if app.session.member:has_voting_right_for_unit_id(area.unit_id) then + if app.session.member_id == member.id and app.session.member:has_voting_right_for_unit_id(area.unit_id) then slot.put(" · ") if area.delegation_info.own_delegation_scope ~= "area" then diff -r ea4c1b3a443c -r a3eb6ca34484 app/main/area/_list_entry.lua --- a/app/main/area/_list_entry.lua Thu Jun 28 23:44:09 2012 +0200 +++ b/app/main/area/_list_entry.lua Thu Jun 28 23:57:02 2012 +0200 @@ -1,8 +1,9 @@ local area = param.get("area", "table") +local member = param.get("member", "table") ui.container{ attr = { class = "area" }, content = function() - execute.view{ module = "area", view = "_head", params = { area = area, hide_unit = true, show_content = true } } + execute.view{ module = "area", view = "_head", params = { area = area, hide_unit = true, show_content = true, member = member } } ui.container{ attr = { class = "content" }, content = function() ui.tag{ content = _"Issues:" } diff -r ea4c1b3a443c -r a3eb6ca34484 app/main/delegation/_info.lua --- a/app/main/delegation/_info.lua Thu Jun 28 23:44:09 2012 +0200 +++ b/app/main/delegation/_info.lua Thu Jun 28 23:57:02 2012 +0200 @@ -2,6 +2,8 @@ return end +local member = param.get("member", "table") or app.session.member + local unit = param.get("unit", "table") local area = param.get("area", "table") local issue = param.get("issue", "table") @@ -19,15 +21,13 @@ end if area then - area:load_delegation_info_once_for_member_id(app.session.member_id) + area:load_delegation_info_once_for_member_id(member.id) info = area.delegation_info delegation_text = _"Delegate area" end if issue then - if app.session.member_id then - info = issue.member_info - end + info = issue.member_info delegation_text = _"Delegate issue" end @@ -53,7 +53,7 @@ end execute.view{ module = "member_image", view = "_show", params = { - member = app.session.member, class = class, popup_text = app.session.member.name, + member = member, class = class, popup_text = member.name, image_type = "avatar", show_dummy = true, } } @@ -139,7 +139,7 @@ } execute.view{ module = "member_image", view = "_show", params = { - member = app.session.member, class = "micro_avatar", popup_text = app.session.member.name, + member = member, class = "micro_avatar", popup_text = member.name, image_type = "avatar", show_dummy = true, } } diff -r ea4c1b3a443c -r a3eb6ca34484 app/main/index/_member_home.lua --- a/app/main/index/_member_home.lua Thu Jun 28 23:44:09 2012 +0200 +++ b/app/main/index/_member_home.lua Thu Jun 28 23:57:02 2012 +0200 @@ -106,7 +106,7 @@ end ui.container{ attr = { class = "area_list" }, content = function() - execute.view{ module = "unit", view = "_head", params = { unit = unit, show_content = true } } + execute.view{ module = "unit", view = "_head", params = { unit = unit, show_content = true, member = member } } if area_count > 0 then local areas = areas_selector:exec() @@ -116,7 +116,7 @@ for i, area in ipairs(areas) do execute.view{ module = "area", view = "_list_entry", params = { - area = area + area = area, member = member } } end diff -r ea4c1b3a443c -r a3eb6ca34484 app/main/member/_show.lua --- a/app/main/member/_show.lua Thu Jun 28 23:44:09 2012 +0200 +++ b/app/main/member/_show.lua Thu Jun 28 23:57:02 2012 +0200 @@ -20,7 +20,7 @@ local areas_selector = member:get_reference_selector("areas") tabs[#tabs+1] = { name = "areas", - label = _"Units", + label = _"Units and areas", icon = { static = "icons/16/package.png" }, module = "index", view = "_member_home", diff -r ea4c1b3a443c -r a3eb6ca34484 app/main/unit/_head.lua --- a/app/main/unit/_head.lua Thu Jun 28 23:44:09 2012 +0200 +++ b/app/main/unit/_head.lua Thu Jun 28 23:57:02 2012 +0200 @@ -1,4 +1,5 @@ local unit = param.get("unit", "table") +local member = param.get("member", "table") local show_content = param.get("show_content", atom.boolean) @@ -6,7 +7,7 @@ ui.container{ attr = { class = "unit_head" }, content = function() - execute.view{ module = "delegation", view = "_info", params = { unit = unit } } + execute.view{ module = "delegation", view = "_info", params = { unit = unit, member = member } } ui.container{ attr = { class = "title" }, content = function() if not config.single_unit_id then @@ -25,13 +26,17 @@ if show_content then ui.container{ attr = { class = "content" }, content = function() - if app.session.member_id and app.session.member:has_voting_right_for_unit_id(unit.id) then - ui.tag{ content = _"You have voting privileges for this unit" } - slot.put(" · ") - if unit.delegation_info.first_trustee_id == nil then - ui.link{ text = _"Delegate unit", module = "delegation", view = "show", params = { unit_id = unit.id } } + if member and member:has_voting_right_for_unit_id(unit.id) then + if app.session.member_id == member.id then + ui.tag{ content = _"You have voting privileges for this unit" } + slot.put(" · ") + if unit.delegation_info.first_trustee_id == nil then + ui.link{ text = _"Delegate unit", module = "delegation", view = "show", params = { unit_id = unit.id } } + else + ui.link{ text = _"Change unit delegation", module = "delegation", view = "show", params = { unit_id = unit.id } } + end else - ui.link{ text = _"Change unit delegation", module = "delegation", view = "show", params = { unit_id = unit.id } } + ui.tag{ content = _"Member has voting privileges for this unit" } end end end }