From 7569b3e963c266bdaced95c4ea3b47162973d591 Mon Sep 17 00:00:00 2001 From: JoenioCosta Date: Sat, 19 Jul 2008 14:24:19 +0000 Subject: [PATCH] ActionItem556: added button 'Manage groups' in control panel --- app/models/profile.rb | 4 ++++ app/views/memberships/index.rhtml | 37 +++++++++++++++++++++---------------- app/views/profile_editor/index.rhtml | 21 +-------------------- public/designs/themes/ecosol/stylesheets/controller_memberships.css | 3 +++ public/images/icons-app/README | 36 +++++++++++++++++++++++++++++++----- public/images/icons-app/get-icon.sh | 8 +++----- public/images/icons-app/gnome-globe.png | Bin 0 -> 5960 bytes public/images/icons-app/groups.png | 1 + public/stylesheets/controller_memberships.css | 41 +++++++++++++++++++++++++++++++++++++++++ test/functional/memberships_controller_test.rb | 25 +++++++++++++++++++++---- test/functional/profile_editor_controller_test.rb | 28 +++++++--------------------- 11 files changed, 133 insertions(+), 71 deletions(-) create mode 100644 public/designs/themes/ecosol/stylesheets/controller_memberships.css create mode 100644 public/images/icons-app/gnome-globe.png create mode 120000 public/images/icons-app/groups.png create mode 100644 public/stylesheets/controller_memberships.css diff --git a/app/models/profile.rb b/app/models/profile.rb index 891e250..6767089 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -244,6 +244,10 @@ class Profile < ActiveRecord::Base self.kind_of?(Organization) end + def community? + self.kind_of?(Community) + end + # returns false. def is_validation_entity? false diff --git a/app/views/memberships/index.rhtml b/app/views/memberships/index.rhtml index 02b519a..02eed7a 100644 --- a/app/views/memberships/index.rhtml +++ b/app/views/memberships/index.rhtml @@ -1,29 +1,34 @@ -

<%= _("%s's groups") % profile.name %>

+
-

-<%= _('%s is a member of the following groups:') % profile.name %> -

+

<%= _('Manage my groups') %>

- + - - - + <%= [ link_to(_('Manage'), membership.admin_url), + link_to(_('Leave'), { :profile => profile.identifier, :controller => 'memberships', :action => 'leave', :id => membership.id }), + link_to(_('Destroy'), { :profile => profile.identifier, :controller => 'memberships', :action => 'destroy', :id => membership.id }) + ].join(', ') + %> + + <% end %> -
<%= image_tag(profile_icon(membership)) %> - <%= _('Name: %s') % link_to(membership.name, membership.url) %>
+
  • +
    + <%= profile_image_link(membership, :portrait, 'div') %> +
    + + <%= membership.display_name %>
    <%= _('Role: %s') % rolename_for(profile, membership) %>
    <%= _('Type: %s') % _(membership.class.name) %>
    <%= _('Description: %s') % membership.description + '
    ' if membership.kind_of?(Community) %> <%= _('Members: %s') % membership.members.size.to_s %>
    <%= _('Created at: %s') % show_date(membership.created_at) %>
    - <%= _('Actions: %s') % link_to(_('Manage'), membership.admin_url) + ', ' + link_to(_('Leave'), { :profile => profile.identifier, :controller => 'memberships', :action => 'leave', :id => membership.id }) %>
    - -
  • + <% button_bar do %> - <%= button :add, _('Register a new Enterprise'), :controller => 'enterprise_registration' %> - <%= button :add, _('Create a new community'), :action => 'new_community' %> + <%= button(:add, _('Create a new community'), :controller => 'memberships', :action => 'new_community') %> + <%= button(:add, _('Register a new Enterprise'), :controller => 'enterprise_registration') if environment.regions.any?{|i| i.has_validator?} %> <%= button :back, _('Go back'), :controller => 'profile_editor' %> <% end %> + +
    diff --git a/app/views/profile_editor/index.rhtml b/app/views/profile_editor/index.rhtml index cc407d0..909d14d 100644 --- a/app/views/profile_editor/index.rhtml +++ b/app/views/profile_editor/index.rhtml @@ -38,26 +38,7 @@ <% end %> <% end %> -<% end %> - -<% if @profile.person? %> - -  
    - -

    <%= _('Manage my groups') %>

    - - <% button_bar do %> - <%= button(:add, _('Create a new community'), :controller => 'memberships', :action => 'new_community') %> - <%= button(:add, _('Register a new Enterprise'), :controller => 'enterprise_registration') if environment.regions.any?{|i| i.has_validator?} %> - <% end %> - - <% file_manager do %> - - <% @profile.memberships.each do |group| %> - <%= file_manager_button(group.name, profile_icon(group) , :profile => group.identifier, :controller => 'profile_editor' ) %> - <% end %> - - <% end %> + <%= file_manager_button(_('Manage my groups'), 'icons-app/groups.png', :controller => 'memberships') if profile.person? %> <% end %> diff --git a/public/designs/themes/ecosol/stylesheets/controller_memberships.css b/public/designs/themes/ecosol/stylesheets/controller_memberships.css new file mode 100644 index 0000000..19fac2f --- /dev/null +++ b/public/designs/themes/ecosol/stylesheets/controller_memberships.css @@ -0,0 +1,3 @@ +#memberships-index li { + -moz-border-radius: 25px; +} diff --git a/public/images/icons-app/README b/public/images/icons-app/README index 9f2a57c..b780f39 100644 --- a/public/images/icons-app/README +++ b/public/images/icons-app/README @@ -1,9 +1,8 @@ dlg-neu icons in Noosfero ========================= -The icons in this directory are taken from the icon themes for GNOME, -section "apps/". We take the SVG files and convert to 64x64 PNG images, so -these icons are in fact derived works based on dlg-neu's SVG files. +The icons in this directory are taken from the icon themes for GNOME. +We take the SVG files and convert to 64x64 PNG images. Structure ========= @@ -19,7 +18,7 @@ Use the fantastic script get-icon.sh! Suppose you want to add a new icon for the "favorites". You find that dlg-neu theme has a nice button under apps, called gtk-open.svg. You call the script as follows: -$ sh get-icon.sh favorites epiphany-bookmarks.svg +$ sh get-icon.sh favorites dlg-neu apps/epiphany-bookmarks.svg The script generates the PNG and create symbolic link from PNG using ICON name. @@ -44,6 +43,7 @@ epiphany-bookmarks.png dlg-neu mozilla-mail.png dlg-neu gtk-cancel.png dlg-neu emblem-important.png dlg-neu +gnome-globe.png gnome ### END OF ICONS LISTING ### Icons rasterization @@ -57,8 +57,12 @@ $ rsvg -w 64 -h 64 user_icon.svg user_icon.png Licensing ========= +dlg-neu and Nuovo +----------------- + Their License is as follows (taken from -/usr/share/doc/gnome-icon-theme-dlg-neu/copyright on a Debian system): +/usr/share/doc/gnome-icon-theme-dlg-neu/copyright and +/usr/share/doc/gnome-icon-theme-nuovo/copyright on a Debian system): This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -78,3 +82,25 @@ Their License is as follows (taken from On Debian systems, the complete text of the GNU General Public License can be found in `/usr/share/common-licenses/GPL'. +gnome +----- + +Their License is as follows (taken from +/usr/share/doc/gnome-icon-theme/copyright on a Debian system): + + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; version 2 dated June, 1991. + + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this package; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, + USA. + +On Debian GNU/Linux systems, the complete text of the GNU General +Public License can be found in `/usr/share/common-licenses/GPL'. diff --git a/public/images/icons-app/get-icon.sh b/public/images/icons-app/get-icon.sh index da7071f..2e1d3ba 100644 --- a/public/images/icons-app/get-icon.sh +++ b/public/images/icons-app/get-icon.sh @@ -4,17 +4,15 @@ ICON=$1 THEME=$2 SVG=$3 -SECTION='apps' - if [ -z $ICON ] || [ -z $THEME ] || [ -z $SVG ]; then - echo "use: $0 " + echo "use: $0 " echo "example:" - echo " $0 favorites dlg-neu epiphany-bookmarks.svg" + echo " $0 favorites dlg-neu emblems/epiphany-bookmarks.svg" exit 1 fi PNG=$(basename $SVG | sed -e 's/\.svg/\.png/') -SVGFILE=/usr/share/icons/$THEME/scalable/$SECTION/$SVG +SVGFILE=/usr/share/icons/$THEME/scalable/$SVG if [ ! -f $SVGFILE ]; then echo "$SVGFILE not found, stopping." diff --git a/public/images/icons-app/gnome-globe.png b/public/images/icons-app/gnome-globe.png new file mode 100644 index 0000000..4219a91 Binary files /dev/null and b/public/images/icons-app/gnome-globe.png differ diff --git a/public/images/icons-app/groups.png b/public/images/icons-app/groups.png new file mode 120000 index 0000000..6b68864 --- /dev/null +++ b/public/images/icons-app/groups.png @@ -0,0 +1 @@ +gnome-globe.png \ No newline at end of file diff --git a/public/stylesheets/controller_memberships.css b/public/stylesheets/controller_memberships.css new file mode 100644 index 0000000..1cdf5f6 --- /dev/null +++ b/public/stylesheets/controller_memberships.css @@ -0,0 +1,41 @@ +@import url(profile-list-block.css); + +#memberships-index ul { + width: 100%; + padding: 0px; + margin: 0px; + display: table; + border-spacing: 10px +} + +#memberships-index li { + display: table-row; + list-style: none; +} + +#memberships-index li { + background-color: #B8CFE7; +} + +#memberships-index li .vcard { + float: right; + padding: 4% 20px 4% 0px; +} + +#memberships-index li .profile-details { + display: block; + padding: 3% 0px 3% 30px; +} + +#memberships-index li .vcard a.profile_link.url { + border: 2px solid #729FCF; + background-color: #ABC; +} + +#memberships-index li .vcard a.profile_link.url:hover { + border: 2px solid #2A5896; +} + +#memberships-index li .vcard span.org { + display: none; +} diff --git a/test/functional/memberships_controller_test.rb b/test/functional/memberships_controller_test.rb index d5348a4..0ccb9ab 100644 --- a/test/functional/memberships_controller_test.rb +++ b/test/functional/memberships_controller_test.rb @@ -89,28 +89,28 @@ class MembershipsControllerTest < Test::Unit::TestCase community = Community.create!(:name => 'my test community') community.add_member(profile) get :index, :profile => profile.identifier - assert_tag :tag => 'td', :content => /Members: 1/ + assert_tag :tag => 'li', :content => /Members: 1/ end should 'show created at on list' do community = Community.create!(:name => 'my test community') community.add_member(profile) get :index, :profile => profile.identifier - assert_tag :tag => 'td', :content => /Created at: #{show_date(community.created_at)}/ + assert_tag :tag => 'li', :content => /Created at: #{show_date(community.created_at)}/ end should 'show description on list' do community = Community.create!(:name => 'my test community', :description => 'description test') community.add_member(profile) get :index, :profile => profile.identifier - assert_tag :tag => 'td', :content => /Description: description test/ + assert_tag :tag => 'li', :content => /Description: description test/ end should 'not show description to enterprises on list' do enterprise = Enterprise.create!(:identifier => 'enterprise-test', :name => 'my test enterprise') enterprise.add_member(profile) get :index, :profile => profile.identifier - assert_no_tag :tag => 'td', :content => /Description:/ + assert_no_tag :tag => 'li', :content => /Description:/ end should 'show link to leave from community' do @@ -154,4 +154,21 @@ class MembershipsControllerTest < Test::Unit::TestCase assert_equal Profile::Roles.admin, profile.find_roles(Community.find_by_identifier('my-shiny-new-community')).first.role end + should 'display button to create community' do + get :index, :profile => 'testuser' + assert_tag :tag => 'a', :attributes => { :href => "/myprofile/testuser/memberships/new_community" } + end + + should 'not display link to register new enterprise if there is no validators' do + get :index, :profile => 'testuser' + assert_no_tag :tag => 'a', :content => 'Register a new Enterprise' + end + + should 'display link to register new enterprise' do + reg = Environment.default.regions.create!(:name => 'Region test') + reg.validators.create!(:name => 'Validator test', :identifier => 'validator-test') + get :index, :profile => 'testuser' + assert_tag :tag => 'a', :content => 'Register a new Enterprise' + end + end diff --git a/test/functional/profile_editor_controller_test.rb b/test/functional/profile_editor_controller_test.rb index 199395b..56103c1 100644 --- a/test/functional/profile_editor_controller_test.rb +++ b/test/functional/profile_editor_controller_test.rb @@ -415,26 +415,6 @@ class ProfileEditorControllerTest < Test::Unit::TestCase assert assigns(:to_disable).enabled? end - should 'link to create community' do - profile = Person['ze'] - get :index, :profile => profile.identifier - assert_tag :tag => 'a', :attributes => { :href => "/myprofile/#{profile.identifier}/memberships/new_community" } - end - - should 'not display link to register new enterprise if there is no validators' do - person = create_user('testuser').person - get :index, :profile => 'testuser' - assert_no_tag :tag => 'a', :content => 'Register a new Enterprise' - end - - should 'display link to register new enterprise' do - reg = Environment.default.regions.create!(:name => 'Region test') - reg.validators.create!(:name => 'Validator test', :identifier => 'validator-test') - person = create_user('testuser').person - get :index, :profile => 'testuser' - assert_tag :tag => 'a', :content => 'Register a new Enterprise' - end - should 'update categories' do env = Environment.default top = env.categories.create!(:display_in_menu => true, :name => 'Top-Level category') @@ -445,5 +425,11 @@ class ProfileEditorControllerTest < Test::Unit::TestCase assert_equal top, assigns(:current_category) assert_equal [c1, c2], assigns(:categories) end - + + should 'display manage my groups button for person' do + person = create_user('testuser').person + get :index, :profile => 'testuser' + assert_tag :tag => 'a', :content => 'Manage my groups' + end + end -- libgit2 0.21.2