Commit 7569b3e963c266bdaced95c4ea3b47162973d591
1 parent
6117f4ed
Exists in
master
and in
29 other branches
ActionItem556: added button 'Manage groups' in control panel
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@2288 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
11 changed files
with
133 additions
and
71 deletions
Show diff stats
app/models/profile.rb
| @@ -244,6 +244,10 @@ class Profile < ActiveRecord::Base | @@ -244,6 +244,10 @@ class Profile < ActiveRecord::Base | ||
| 244 | self.kind_of?(Organization) | 244 | self.kind_of?(Organization) |
| 245 | end | 245 | end |
| 246 | 246 | ||
| 247 | + def community? | ||
| 248 | + self.kind_of?(Community) | ||
| 249 | + end | ||
| 250 | + | ||
| 247 | # returns false. | 251 | # returns false. |
| 248 | def is_validation_entity? | 252 | def is_validation_entity? |
| 249 | false | 253 | false |
app/views/memberships/index.rhtml
| 1 | -<h1><%= _("%s's groups") % profile.name %></h1> | 1 | +<div id="memberships-index"> |
| 2 | 2 | ||
| 3 | -<p> | ||
| 4 | -<%= _('%s is a member of the following groups:') % profile.name %> | ||
| 5 | -</p> | 3 | +<h1><%= _('Manage my groups') %></h1> |
| 6 | 4 | ||
| 7 | -<table> | 5 | +<ul> |
| 8 | <% for membership in @memberships %> | 6 | <% for membership in @memberships %> |
| 9 | - <tr> | ||
| 10 | - <td> <%= image_tag(profile_icon(membership)) %> </td> | ||
| 11 | - <td> | ||
| 12 | - <%= _('Name: %s') % link_to(membership.name, membership.url) %> <br/> | 7 | + <li> |
| 8 | + <div class='common-profile-list-block'> | ||
| 9 | + <%= profile_image_link(membership, :portrait, 'div') %> | ||
| 10 | + </div> | ||
| 11 | + <span class='profile-details'> | ||
| 12 | + <strong><%= membership.display_name %></strong><br/> | ||
| 13 | <%= _('Role: %s') % rolename_for(profile, membership) %> <br/> | 13 | <%= _('Role: %s') % rolename_for(profile, membership) %> <br/> |
| 14 | <%= _('Type: %s') % _(membership.class.name) %> <br/> | 14 | <%= _('Type: %s') % _(membership.class.name) %> <br/> |
| 15 | <%= _('Description: %s') % membership.description + '<br/>' if membership.kind_of?(Community) %> | 15 | <%= _('Description: %s') % membership.description + '<br/>' if membership.kind_of?(Community) %> |
| 16 | <%= _('Members: %s') % membership.members.size.to_s %> <br/> | 16 | <%= _('Members: %s') % membership.members.size.to_s %> <br/> |
| 17 | <%= _('Created at: %s') % show_date(membership.created_at) %> <br/> | 17 | <%= _('Created at: %s') % show_date(membership.created_at) %> <br/> |
| 18 | - <%= _('Actions: %s') % link_to(_('Manage'), membership.admin_url) + ', ' + link_to(_('Leave'), { :profile => profile.identifier, :controller => 'memberships', :action => 'leave', :id => membership.id }) %> <br/> | ||
| 19 | - | ||
| 20 | - </td> | ||
| 21 | - </tr> | 18 | + <%= [ link_to(_('Manage'), membership.admin_url), |
| 19 | + link_to(_('Leave'), { :profile => profile.identifier, :controller => 'memberships', :action => 'leave', :id => membership.id }), | ||
| 20 | + link_to(_('Destroy'), { :profile => profile.identifier, :controller => 'memberships', :action => 'destroy', :id => membership.id }) | ||
| 21 | + ].join(', ') | ||
| 22 | + %> | ||
| 23 | + </span> | ||
| 24 | + </li> | ||
| 22 | <% end %> | 25 | <% end %> |
| 23 | -</table> | 26 | +</ul> |
| 24 | 27 | ||
| 25 | <% button_bar do %> | 28 | <% button_bar do %> |
| 26 | - <%= button :add, _('Register a new Enterprise'), :controller => 'enterprise_registration' %> | ||
| 27 | - <%= button :add, _('Create a new community'), :action => 'new_community' %> | 29 | + <%= button(:add, _('Create a new community'), :controller => 'memberships', :action => 'new_community') %> |
| 30 | + <%= button(:add, _('Register a new Enterprise'), :controller => 'enterprise_registration') if environment.regions.any?{|i| i.has_validator?} %> | ||
| 28 | <%= button :back, _('Go back'), :controller => 'profile_editor' %> | 31 | <%= button :back, _('Go back'), :controller => 'profile_editor' %> |
| 29 | <% end %> | 32 | <% end %> |
| 33 | + | ||
| 34 | +</div> |
app/views/profile_editor/index.rhtml
| @@ -38,26 +38,7 @@ | @@ -38,26 +38,7 @@ | ||
| 38 | <% end %> | 38 | <% end %> |
| 39 | <% end %> | 39 | <% end %> |
| 40 | 40 | ||
| 41 | -<% end %> | ||
| 42 | - | ||
| 43 | -<% if @profile.person? %> | ||
| 44 | - | ||
| 45 | - <hr /> | ||
| 46 | - | ||
| 47 | - <h2><%= _('Manage my groups') %></h2> | ||
| 48 | - | ||
| 49 | - <% button_bar do %> | ||
| 50 | - <%= button(:add, _('Create a new community'), :controller => 'memberships', :action => 'new_community') %> | ||
| 51 | - <%= button(:add, _('Register a new Enterprise'), :controller => 'enterprise_registration') if environment.regions.any?{|i| i.has_validator?} %> | ||
| 52 | - <% end %> | ||
| 53 | - | ||
| 54 | - <% file_manager do %> | ||
| 55 | - | ||
| 56 | - <% @profile.memberships.each do |group| %> | ||
| 57 | - <%= file_manager_button(group.name, profile_icon(group) , :profile => group.identifier, :controller => 'profile_editor' ) %> | ||
| 58 | - <% end %> | ||
| 59 | - | ||
| 60 | - <% end %> | 41 | + <%= file_manager_button(_('Manage my groups'), 'icons-app/groups.png', :controller => 'memberships') if profile.person? %> |
| 61 | 42 | ||
| 62 | <% end %> | 43 | <% end %> |
| 63 | 44 |
public/designs/themes/ecosol/stylesheets/controller_memberships.css
0 → 100644
public/images/icons-app/README
| 1 | dlg-neu icons in Noosfero | 1 | dlg-neu icons in Noosfero |
| 2 | ========================= | 2 | ========================= |
| 3 | 3 | ||
| 4 | -The icons in this directory are taken from the icon themes for GNOME, | ||
| 5 | -section "apps/". We take the SVG files and convert to 64x64 PNG images, so | ||
| 6 | -these icons are in fact derived works based on dlg-neu's SVG files. | 4 | +The icons in this directory are taken from the icon themes for GNOME. |
| 5 | +We take the SVG files and convert to 64x64 PNG images. | ||
| 7 | 6 | ||
| 8 | Structure | 7 | Structure |
| 9 | ========= | 8 | ========= |
| @@ -19,7 +18,7 @@ Use the fantastic script get-icon.sh! Suppose you want to add a new icon for | @@ -19,7 +18,7 @@ Use the fantastic script get-icon.sh! Suppose you want to add a new icon for | ||
| 19 | the "favorites". You find that dlg-neu theme has a nice button under apps, | 18 | the "favorites". You find that dlg-neu theme has a nice button under apps, |
| 20 | called gtk-open.svg. You call the script as follows: | 19 | called gtk-open.svg. You call the script as follows: |
| 21 | 20 | ||
| 22 | -$ sh get-icon.sh favorites epiphany-bookmarks.svg | 21 | +$ sh get-icon.sh favorites dlg-neu apps/epiphany-bookmarks.svg |
| 23 | 22 | ||
| 24 | The script generates the PNG and create symbolic link from PNG using ICON name. | 23 | The script generates the PNG and create symbolic link from PNG using ICON name. |
| 25 | 24 | ||
| @@ -44,6 +43,7 @@ epiphany-bookmarks.png dlg-neu | @@ -44,6 +43,7 @@ epiphany-bookmarks.png dlg-neu | ||
| 44 | mozilla-mail.png dlg-neu | 43 | mozilla-mail.png dlg-neu |
| 45 | gtk-cancel.png dlg-neu | 44 | gtk-cancel.png dlg-neu |
| 46 | emblem-important.png dlg-neu | 45 | emblem-important.png dlg-neu |
| 46 | +gnome-globe.png gnome | ||
| 47 | ### END OF ICONS LISTING ### | 47 | ### END OF ICONS LISTING ### |
| 48 | 48 | ||
| 49 | Icons rasterization | 49 | Icons rasterization |
| @@ -57,8 +57,12 @@ $ rsvg -w 64 -h 64 user_icon.svg user_icon.png | @@ -57,8 +57,12 @@ $ rsvg -w 64 -h 64 user_icon.svg user_icon.png | ||
| 57 | Licensing | 57 | Licensing |
| 58 | ========= | 58 | ========= |
| 59 | 59 | ||
| 60 | +dlg-neu and Nuovo | ||
| 61 | +----------------- | ||
| 62 | + | ||
| 60 | Their License is as follows (taken from | 63 | Their License is as follows (taken from |
| 61 | -/usr/share/doc/gnome-icon-theme-dlg-neu/copyright on a Debian system): | 64 | +/usr/share/doc/gnome-icon-theme-dlg-neu/copyright and |
| 65 | +/usr/share/doc/gnome-icon-theme-nuovo/copyright on a Debian system): | ||
| 62 | 66 | ||
| 63 | This package is free software; you can redistribute it and/or modify | 67 | This package is free software; you can redistribute it and/or modify |
| 64 | it under the terms of the GNU General Public License as published by | 68 | it under the terms of the GNU General Public License as published by |
| @@ -78,3 +82,25 @@ Their License is as follows (taken from | @@ -78,3 +82,25 @@ Their License is as follows (taken from | ||
| 78 | On Debian systems, the complete text of the GNU General | 82 | On Debian systems, the complete text of the GNU General |
| 79 | Public License can be found in `/usr/share/common-licenses/GPL'. | 83 | Public License can be found in `/usr/share/common-licenses/GPL'. |
| 80 | 84 | ||
| 85 | +gnome | ||
| 86 | +----- | ||
| 87 | + | ||
| 88 | +Their License is as follows (taken from | ||
| 89 | +/usr/share/doc/gnome-icon-theme/copyright on a Debian system): | ||
| 90 | + | ||
| 91 | + This package is free software; you can redistribute it and/or modify | ||
| 92 | + it under the terms of the GNU General Public License as published by | ||
| 93 | + the Free Software Foundation; version 2 dated June, 1991. | ||
| 94 | + | ||
| 95 | + This package is distributed in the hope that it will be useful, | ||
| 96 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 97 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 98 | + GNU General Public License for more details. | ||
| 99 | + | ||
| 100 | + You should have received a copy of the GNU General Public License | ||
| 101 | + along with this package; if not, write to the Free Software | ||
| 102 | + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, | ||
| 103 | + USA. | ||
| 104 | + | ||
| 105 | +On Debian GNU/Linux systems, the complete text of the GNU General | ||
| 106 | +Public License can be found in `/usr/share/common-licenses/GPL'. |
public/images/icons-app/get-icon.sh
| @@ -4,17 +4,15 @@ ICON=$1 | @@ -4,17 +4,15 @@ ICON=$1 | ||
| 4 | THEME=$2 | 4 | THEME=$2 |
| 5 | SVG=$3 | 5 | SVG=$3 |
| 6 | 6 | ||
| 7 | -SECTION='apps' | ||
| 8 | - | ||
| 9 | if [ -z $ICON ] || [ -z $THEME ] || [ -z $SVG ]; then | 7 | if [ -z $ICON ] || [ -z $THEME ] || [ -z $SVG ]; then |
| 10 | - echo "use: $0 <ICON> <THEME> <ICON>" | 8 | + echo "use: $0 <ICON> <THEME> <SVG>" |
| 11 | echo "example:" | 9 | echo "example:" |
| 12 | - echo " $0 favorites dlg-neu epiphany-bookmarks.svg" | 10 | + echo " $0 favorites dlg-neu emblems/epiphany-bookmarks.svg" |
| 13 | exit 1 | 11 | exit 1 |
| 14 | fi | 12 | fi |
| 15 | 13 | ||
| 16 | PNG=$(basename $SVG | sed -e 's/\.svg/\.png/') | 14 | PNG=$(basename $SVG | sed -e 's/\.svg/\.png/') |
| 17 | -SVGFILE=/usr/share/icons/$THEME/scalable/$SECTION/$SVG | 15 | +SVGFILE=/usr/share/icons/$THEME/scalable/$SVG |
| 18 | 16 | ||
| 19 | if [ ! -f $SVGFILE ]; then | 17 | if [ ! -f $SVGFILE ]; then |
| 20 | echo "$SVGFILE not found, stopping." | 18 | echo "$SVGFILE not found, stopping." |
5.82 KB
| @@ -0,0 +1,41 @@ | @@ -0,0 +1,41 @@ | ||
| 1 | +@import url(profile-list-block.css); | ||
| 2 | + | ||
| 3 | +#memberships-index ul { | ||
| 4 | + width: 100%; | ||
| 5 | + padding: 0px; | ||
| 6 | + margin: 0px; | ||
| 7 | + display: table; | ||
| 8 | + border-spacing: 10px | ||
| 9 | +} | ||
| 10 | + | ||
| 11 | +#memberships-index li { | ||
| 12 | + display: table-row; | ||
| 13 | + list-style: none; | ||
| 14 | +} | ||
| 15 | + | ||
| 16 | +#memberships-index li { | ||
| 17 | + background-color: #B8CFE7; | ||
| 18 | +} | ||
| 19 | + | ||
| 20 | +#memberships-index li .vcard { | ||
| 21 | + float: right; | ||
| 22 | + padding: 4% 20px 4% 0px; | ||
| 23 | +} | ||
| 24 | + | ||
| 25 | +#memberships-index li .profile-details { | ||
| 26 | + display: block; | ||
| 27 | + padding: 3% 0px 3% 30px; | ||
| 28 | +} | ||
| 29 | + | ||
| 30 | +#memberships-index li .vcard a.profile_link.url { | ||
| 31 | + border: 2px solid #729FCF; | ||
| 32 | + background-color: #ABC; | ||
| 33 | +} | ||
| 34 | + | ||
| 35 | +#memberships-index li .vcard a.profile_link.url:hover { | ||
| 36 | + border: 2px solid #2A5896; | ||
| 37 | +} | ||
| 38 | + | ||
| 39 | +#memberships-index li .vcard span.org { | ||
| 40 | + display: none; | ||
| 41 | +} |
test/functional/memberships_controller_test.rb
| @@ -89,28 +89,28 @@ class MembershipsControllerTest < Test::Unit::TestCase | @@ -89,28 +89,28 @@ class MembershipsControllerTest < Test::Unit::TestCase | ||
| 89 | community = Community.create!(:name => 'my test community') | 89 | community = Community.create!(:name => 'my test community') |
| 90 | community.add_member(profile) | 90 | community.add_member(profile) |
| 91 | get :index, :profile => profile.identifier | 91 | get :index, :profile => profile.identifier |
| 92 | - assert_tag :tag => 'td', :content => /Members: 1/ | 92 | + assert_tag :tag => 'li', :content => /Members: 1/ |
| 93 | end | 93 | end |
| 94 | 94 | ||
| 95 | should 'show created at on list' do | 95 | should 'show created at on list' do |
| 96 | community = Community.create!(:name => 'my test community') | 96 | community = Community.create!(:name => 'my test community') |
| 97 | community.add_member(profile) | 97 | community.add_member(profile) |
| 98 | get :index, :profile => profile.identifier | 98 | get :index, :profile => profile.identifier |
| 99 | - assert_tag :tag => 'td', :content => /Created at: #{show_date(community.created_at)}/ | 99 | + assert_tag :tag => 'li', :content => /Created at: #{show_date(community.created_at)}/ |
| 100 | end | 100 | end |
| 101 | 101 | ||
| 102 | should 'show description on list' do | 102 | should 'show description on list' do |
| 103 | community = Community.create!(:name => 'my test community', :description => 'description test') | 103 | community = Community.create!(:name => 'my test community', :description => 'description test') |
| 104 | community.add_member(profile) | 104 | community.add_member(profile) |
| 105 | get :index, :profile => profile.identifier | 105 | get :index, :profile => profile.identifier |
| 106 | - assert_tag :tag => 'td', :content => /Description: description test/ | 106 | + assert_tag :tag => 'li', :content => /Description: description test/ |
| 107 | end | 107 | end |
| 108 | 108 | ||
| 109 | should 'not show description to enterprises on list' do | 109 | should 'not show description to enterprises on list' do |
| 110 | enterprise = Enterprise.create!(:identifier => 'enterprise-test', :name => 'my test enterprise') | 110 | enterprise = Enterprise.create!(:identifier => 'enterprise-test', :name => 'my test enterprise') |
| 111 | enterprise.add_member(profile) | 111 | enterprise.add_member(profile) |
| 112 | get :index, :profile => profile.identifier | 112 | get :index, :profile => profile.identifier |
| 113 | - assert_no_tag :tag => 'td', :content => /Description:/ | 113 | + assert_no_tag :tag => 'li', :content => /Description:/ |
| 114 | end | 114 | end |
| 115 | 115 | ||
| 116 | should 'show link to leave from community' do | 116 | should 'show link to leave from community' do |
| @@ -154,4 +154,21 @@ class MembershipsControllerTest < Test::Unit::TestCase | @@ -154,4 +154,21 @@ class MembershipsControllerTest < Test::Unit::TestCase | ||
| 154 | assert_equal Profile::Roles.admin, profile.find_roles(Community.find_by_identifier('my-shiny-new-community')).first.role | 154 | assert_equal Profile::Roles.admin, profile.find_roles(Community.find_by_identifier('my-shiny-new-community')).first.role |
| 155 | end | 155 | end |
| 156 | 156 | ||
| 157 | + should 'display button to create community' do | ||
| 158 | + get :index, :profile => 'testuser' | ||
| 159 | + assert_tag :tag => 'a', :attributes => { :href => "/myprofile/testuser/memberships/new_community" } | ||
| 160 | + end | ||
| 161 | + | ||
| 162 | + should 'not display link to register new enterprise if there is no validators' do | ||
| 163 | + get :index, :profile => 'testuser' | ||
| 164 | + assert_no_tag :tag => 'a', :content => 'Register a new Enterprise' | ||
| 165 | + end | ||
| 166 | + | ||
| 167 | + should 'display link to register new enterprise' do | ||
| 168 | + reg = Environment.default.regions.create!(:name => 'Region test') | ||
| 169 | + reg.validators.create!(:name => 'Validator test', :identifier => 'validator-test') | ||
| 170 | + get :index, :profile => 'testuser' | ||
| 171 | + assert_tag :tag => 'a', :content => 'Register a new Enterprise' | ||
| 172 | + end | ||
| 173 | + | ||
| 157 | end | 174 | end |
test/functional/profile_editor_controller_test.rb
| @@ -415,26 +415,6 @@ class ProfileEditorControllerTest < Test::Unit::TestCase | @@ -415,26 +415,6 @@ class ProfileEditorControllerTest < Test::Unit::TestCase | ||
| 415 | assert assigns(:to_disable).enabled? | 415 | assert assigns(:to_disable).enabled? |
| 416 | end | 416 | end |
| 417 | 417 | ||
| 418 | - should 'link to create community' do | ||
| 419 | - profile = Person['ze'] | ||
| 420 | - get :index, :profile => profile.identifier | ||
| 421 | - assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/memberships/new_community" } | ||
| 422 | - end | ||
| 423 | - | ||
| 424 | - should 'not display link to register new enterprise if there is no validators' do | ||
| 425 | - person = create_user('testuser').person | ||
| 426 | - get :index, :profile => 'testuser' | ||
| 427 | - assert_no_tag :tag => 'a', :content => 'Register a new Enterprise' | ||
| 428 | - end | ||
| 429 | - | ||
| 430 | - should 'display link to register new enterprise' do | ||
| 431 | - reg = Environment.default.regions.create!(:name => 'Region test') | ||
| 432 | - reg.validators.create!(:name => 'Validator test', :identifier => 'validator-test') | ||
| 433 | - person = create_user('testuser').person | ||
| 434 | - get :index, :profile => 'testuser' | ||
| 435 | - assert_tag :tag => 'a', :content => 'Register a new Enterprise' | ||
| 436 | - end | ||
| 437 | - | ||
| 438 | should 'update categories' do | 418 | should 'update categories' do |
| 439 | env = Environment.default | 419 | env = Environment.default |
| 440 | top = env.categories.create!(:display_in_menu => true, :name => 'Top-Level category') | 420 | top = env.categories.create!(:display_in_menu => true, :name => 'Top-Level category') |
| @@ -445,5 +425,11 @@ class ProfileEditorControllerTest < Test::Unit::TestCase | @@ -445,5 +425,11 @@ class ProfileEditorControllerTest < Test::Unit::TestCase | ||
| 445 | assert_equal top, assigns(:current_category) | 425 | assert_equal top, assigns(:current_category) |
| 446 | assert_equal [c1, c2], assigns(:categories) | 426 | assert_equal [c1, c2], assigns(:categories) |
| 447 | end | 427 | end |
| 448 | - | 428 | + |
| 429 | + should 'display manage my groups button for person' do | ||
| 430 | + person = create_user('testuser').person | ||
| 431 | + get :index, :profile => 'testuser' | ||
| 432 | + assert_tag :tag => 'a', :content => 'Manage my groups' | ||
| 433 | + end | ||
| 434 | + | ||
| 449 | end | 435 | end |