Commit 7569b3e963c266bdaced95c4ea3b47162973d591

Authored by JoenioCosta
1 parent 6117f4ed

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
app/models/profile.rb
... ... @@ -244,6 +244,10 @@ class Profile < ActiveRecord::Base
244 244 self.kind_of?(Organization)
245 245 end
246 246  
  247 + def community?
  248 + self.kind_of?(Community)
  249 + end
  250 +
247 251 # returns false.
248 252 def is_validation_entity?
249 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 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 13 <%= _('Role: %s') % rolename_for(profile, membership) %> <br/>
14 14 <%= _('Type: %s') % _(membership.class.name) %> <br/>
15 15 <%= _('Description: %s') % membership.description + '<br/>' if membership.kind_of?(Community) %>
16 16 <%= _('Members: %s') % membership.members.size.to_s %> <br/>
17 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 25 <% end %>
23   -</table>
  26 +</ul>
24 27  
25 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 31 <%= button :back, _('Go back'), :controller => 'profile_editor' %>
29 32 <% end %>
  33 +
  34 +</div>
... ...
app/views/profile_editor/index.rhtml
... ... @@ -38,26 +38,7 @@
38 38 <% end %>
39 39 <% end %>
40 40  
41   -<% end %>
42   -
43   -<% if @profile.person? %>
44   -
45   - &nbsp;<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 43 <% end %>
63 44  
... ...
public/designs/themes/ecosol/stylesheets/controller_memberships.css 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +#memberships-index li {
  2 + -moz-border-radius: 25px;
  3 +}
... ...
public/images/icons-app/README
1 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 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 18 the "favorites". You find that dlg-neu theme has a nice button under apps,
20 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 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 43 mozilla-mail.png dlg-neu
45 44 gtk-cancel.png dlg-neu
46 45 emblem-important.png dlg-neu
  46 +gnome-globe.png gnome
47 47 ### END OF ICONS LISTING ###
48 48  
49 49 Icons rasterization
... ... @@ -57,8 +57,12 @@ $ rsvg -w 64 -h 64 user_icon.svg user_icon.png
57 57 Licensing
58 58 =========
59 59  
  60 +dlg-neu and Nuovo
  61 +-----------------
  62 +
60 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 67 This package is free software; you can redistribute it and/or modify
64 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 82 On Debian systems, the complete text of the GNU General
79 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 4 THEME=$2
5 5 SVG=$3
6 6  
7   -SECTION='apps'
8   -
9 7 if [ -z $ICON ] || [ -z $THEME ] || [ -z $SVG ]; then
10   - echo "use: $0 <ICON> <THEME> <ICON>"
  8 + echo "use: $0 <ICON> <THEME> <SVG>"
11 9 echo "example:"
12   - echo " $0 favorites dlg-neu epiphany-bookmarks.svg"
  10 + echo " $0 favorites dlg-neu emblems/epiphany-bookmarks.svg"
13 11 exit 1
14 12 fi
15 13  
16 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 17 if [ ! -f $SVGFILE ]; then
20 18 echo "$SVGFILE not found, stopping."
... ...
public/images/icons-app/gnome-globe.png 0 → 100644

5.82 KB

public/images/icons-app/groups.png 0 → 120000
... ... @@ -0,0 +1 @@
  1 +gnome-globe.png
0 2 \ No newline at end of file
... ...
public/stylesheets/controller_memberships.css 0 → 100644
... ... @@ -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 &lt; Test::Unit::TestCase
89 89 community = Community.create!(:name => 'my test community')
90 90 community.add_member(profile)
91 91 get :index, :profile => profile.identifier
92   - assert_tag :tag => 'td', :content => /Members: 1/
  92 + assert_tag :tag => 'li', :content => /Members: 1/
93 93 end
94 94  
95 95 should 'show created at on list' do
96 96 community = Community.create!(:name => 'my test community')
97 97 community.add_member(profile)
98 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 100 end
101 101  
102 102 should 'show description on list' do
103 103 community = Community.create!(:name => 'my test community', :description => 'description test')
104 104 community.add_member(profile)
105 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 107 end
108 108  
109 109 should 'not show description to enterprises on list' do
110 110 enterprise = Enterprise.create!(:identifier => 'enterprise-test', :name => 'my test enterprise')
111 111 enterprise.add_member(profile)
112 112 get :index, :profile => profile.identifier
113   - assert_no_tag :tag => 'td', :content => /Description:/
  113 + assert_no_tag :tag => 'li', :content => /Description:/
114 114 end
115 115  
116 116 should 'show link to leave from community' do
... ... @@ -154,4 +154,21 @@ class MembershipsControllerTest &lt; Test::Unit::TestCase
154 154 assert_equal Profile::Roles.admin, profile.find_roles(Community.find_by_identifier('my-shiny-new-community')).first.role
155 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 174 end
... ...
test/functional/profile_editor_controller_test.rb
... ... @@ -415,26 +415,6 @@ class ProfileEditorControllerTest &lt; Test::Unit::TestCase
415 415 assert assigns(:to_disable).enabled?
416 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 418 should 'update categories' do
439 419 env = Environment.default
440 420 top = env.categories.create!(:display_in_menu => true, :name => 'Top-Level category')
... ... @@ -445,5 +425,11 @@ class ProfileEditorControllerTest &lt; Test::Unit::TestCase
445 425 assert_equal top, assigns(:current_category)
446 426 assert_equal [c1, c2], assigns(:categories)
447 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 435 end
... ...