Commit 5ac2e9b7efb77aa53a97b7bcf4ad1c31357c79ef
1 parent
b520ed5e
Exists in
master
and in
29 other branches
ActionItem40: display name of role in manage organizations
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@1893 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
40 additions
and
1 deletions
Show diff stats
app/helpers/application_helper.rb
... | ... | @@ -600,4 +600,22 @@ module ApplicationHelper |
600 | 600 | ) |
601 | 601 | end |
602 | 602 | |
603 | + def rolename_for(profile, resource) | |
604 | + role = profile.role_assignments.find_by_resource_id(resource.id).role | |
605 | + content_tag('span', role.name, :style => "color: #{role_color(role)}") | |
606 | + end | |
607 | + | |
608 | + def role_color(role) | |
609 | + case role | |
610 | + when Profile::Roles.admin | |
611 | + 'blue' | |
612 | + when Profile::Roles.member | |
613 | + 'green' | |
614 | + when Profile::Roles.moderator | |
615 | + 'gray' | |
616 | + else | |
617 | + 'black' | |
618 | + end | |
619 | + end | |
620 | + | |
603 | 621 | end | ... | ... |
app/views/memberships/index.rhtml
... | ... | @@ -9,7 +9,8 @@ |
9 | 9 | <tr> |
10 | 10 | <td> <%= image_tag(profile_icon(membership)) %> </td> |
11 | 11 | <td> |
12 | - <%= _('Name: %s:') % link_to(membership.name, membership.url) %> <br/> | |
12 | + <%= _('Name: %s') % link_to(membership.name, membership.url) %> <br/> | |
13 | + <%= _('Role: %s') % rolename_for(profile, membership) %> <br/> | |
13 | 14 | <%= _('Type: %s') % _(membership.class.name) %> <br/> |
14 | 15 | <%= _('Description: %s') % membership.description + '<br/>' if membership.kind_of?(Community) %> |
15 | 16 | <%= _('Members: %s') % membership.members.size.to_s %> <br/> | ... | ... |
test/unit/application_helper_test.rb
... | ... | @@ -100,6 +100,26 @@ class ApplicationHelperTest < Test::Unit::TestCase |
100 | 100 | assert_not_nil theme_javascript |
101 | 101 | end |
102 | 102 | |
103 | + should 'role color for admin role' do | |
104 | + assert_equal 'blue', role_color(Profile::Roles.admin) | |
105 | + end | |
106 | + should 'role color for member role' do | |
107 | + assert_equal 'green', role_color(Profile::Roles.member) | |
108 | + end | |
109 | + should 'role color for moderator role' do | |
110 | + assert_equal 'gray', role_color(Profile::Roles.moderator) | |
111 | + end | |
112 | + should 'default role color' do | |
113 | + assert_equal 'black', role_color('none') | |
114 | + end | |
115 | + | |
116 | + should 'rolename for' do | |
117 | + person = create_user('usertest').person | |
118 | + community = Community.create!(:name => 'new community', :identifier => 'new-community', :environment => Environment.default) | |
119 | + community.add_member(person) | |
120 | + assert_equal 'Profile Member', rolename_for(person, community) | |
121 | + end | |
122 | + | |
103 | 123 | protected |
104 | 124 | |
105 | 125 | def content_tag(tag, content, options) | ... | ... |