diff --git a/app/controllers/environment_admin/admin_panel_controller.rb b/app/controllers/environment_admin/admin_panel_controller.rb index 3e6c33a..79e9458 100644 --- a/app/controllers/environment_admin/admin_panel_controller.rb +++ b/app/controllers/environment_admin/admin_panel_controller.rb @@ -1,2 +1,4 @@ class AdminPanelController < EnvironmentAdminController + protect [:index], 'view_environment_admin_panel' + end diff --git a/app/controllers/environment_admin/categories_controller.rb b/app/controllers/environment_admin/categories_controller.rb index 2debba4..b695923 100644 --- a/app/controllers/environment_admin/categories_controller.rb +++ b/app/controllers/environment_admin/categories_controller.rb @@ -1,5 +1,7 @@ class CategoriesController < EnvironmentAdminController + protect [:index, :new, :edit, :remove], 'manage_environment_categories', environment + helper :categories def index diff --git a/app/controllers/environment_admin/edit_template_controller.rb b/app/controllers/environment_admin/edit_template_controller.rb index 33a5c29..434997b 100644 --- a/app/controllers/environment_admin/edit_template_controller.rb +++ b/app/controllers/environment_admin/edit_template_controller.rb @@ -1,5 +1,5 @@ class EditTemplateController < EnvironmentAdminController - + design_editor :holder => 'environment', :autosave => true, :block_types => :block_types def block_types diff --git a/app/controllers/environment_admin/environment_role_manager_controller.rb b/app/controllers/environment_admin/environment_role_manager_controller.rb index 7a41891..1de5016 100644 --- a/app/controllers/environment_admin/environment_role_manager_controller.rb +++ b/app/controllers/environment_admin/environment_role_manager_controller.rb @@ -1,4 +1,6 @@ class EnvironmentRoleManagerController < ApplicationController + protect [:index, :change_roles, :update_roles, :change_role, :add_role, :remove_role, :unassociate, :make_admin], 'manage_environment_roles', environment + def index @admins = Person.find(:all, :conditions => ['role_assignments.resource_type = ?', 'Environment'], :include => :role_assignments ) end diff --git a/app/controllers/environment_admin/features_controller.rb b/app/controllers/environment_admin/features_controller.rb index 3213242..f85fdf2 100644 --- a/app/controllers/environment_admin/features_controller.rb +++ b/app/controllers/environment_admin/features_controller.rb @@ -1,5 +1,6 @@ class FeaturesController < EnvironmentAdminController - + protect [:index, :update], 'edit_environment_features', environment + acts_as_environment_admin_controller def index diff --git a/app/controllers/profile_admin/cms_controller.rb b/app/controllers/profile_admin/cms_controller.rb index 2fa4dc2..48cabad 100644 --- a/app/controllers/profile_admin/cms_controller.rb +++ b/app/controllers/profile_admin/cms_controller.rb @@ -4,7 +4,7 @@ class CmsController < ComatoseAdminController ApplicationController.needs_profile define_option :page_class, Article - + # not yet # protect [:edit, :new, :reorder, :delete], :post_content, :profile end diff --git a/app/controllers/profile_admin/membership_editor_controller.rb b/app/controllers/profile_admin/membership_editor_controller.rb index ac53cbb..2301b1f 100644 --- a/app/controllers/profile_admin/membership_editor_controller.rb +++ b/app/controllers/profile_admin/membership_editor_controller.rb @@ -4,6 +4,8 @@ class MembershipEditorController < ProfileAdminController needs_profile +# protect [:index, :new_enterprise, :create_enterprise ], 'edit_profile', profile + def index @memberships = current_user.person.memberships end diff --git a/app/controllers/profile_admin/profile_editor_controller.rb b/app/controllers/profile_admin/profile_editor_controller.rb index db59239..faff76c 100644 --- a/app/controllers/profile_admin/profile_editor_controller.rb +++ b/app/controllers/profile_admin/profile_editor_controller.rb @@ -3,6 +3,9 @@ class ProfileEditorController < ProfileAdminController design_editor :holder => 'profile', :autosave => true, :block_types => :block_types +# protect [:edit], 'edit_profile', profile +# protect [] + def block_types { 'ListBlock' => _("List Block"), diff --git a/app/controllers/profile_admin/profile_members_controller.rb b/app/controllers/profile_admin/profile_members_controller.rb index 60d2e7c..37d1e81 100644 --- a/app/controllers/profile_admin/profile_members_controller.rb +++ b/app/controllers/profile_admin/profile_members_controller.rb @@ -1,5 +1,7 @@ class ProfileMembersController < ProfileAdminController +# protect [:index, :change_roles, :update_roles, :change_role, :add_role, :remove_role, :unassociate], 'manage_memberships', profile + def index @members = profile.people.uniq end diff --git a/app/models/environment.rb b/app/models/environment.rb index 410b3b7..c7da88e 100644 --- a/app/models/environment.rb +++ b/app/models/environment.rb @@ -4,6 +4,7 @@ class Environment < ActiveRecord::Base PERMISSIONS[:environment] = { + 'view_environment_admin_panel' => N_('View environment admin panel'), 'edit_environment_features' => N_('Edit environment features'), 'edit_environment_design' => N_('Edit environment design'), 'manage_environment_categories' => N_('Manage environment categories'), diff --git a/app/models/profile.rb b/app/models/profile.rb index 7ed6016..9258652 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -28,7 +28,8 @@ class Profile < ActiveRecord::Base acts_as_design - acts_as_ferret :fields => [ :name ] + # FIXME: ferret is causing a strange bug + # acts_as_ferret :fields => [ :name ] # Valid identifiers must match this format. IDENTIFIER_FORMAT = /^[a-z][a-z0-9_]*[a-z0-9]$/ @@ -120,6 +121,10 @@ class Profile < ActiveRecord::Base homepage.children.find(:all, :limit => limit, :order => 'created_on desc') end + def superior_instance + environment + end + # def affiliate(person, roles) # roles = [roles] unless roles.kind_of?(Array) # roles.map do |role| diff --git a/app/views/profile_editor/index.rhtml b/app/views/profile_editor/index.rhtml index e55df58..9b6e4f0 100644 --- a/app/views/profile_editor/index.rhtml +++ b/app/views/profile_editor/index.rhtml @@ -2,7 +2,13 @@ <%= display_profile_info(profile) %> -
<%= link_to _('Edit'), :action => 'edit' %>
+<% if @profile.class == Person %> +<%= link_to _('Edit'), :action => 'edit' %>
+<% elsif @profile.class == Enterprise %> +<%= link_to _('Edit'), :controller => 'enterprise_editor'%>
+<% else %> + +<% end %><%= link_to _('Edit Visual Design'), :action => 'design_editor' %>
diff --git a/script/anhetegua b/script/anhetegua index f607a29..db2a1ee 100644 --- a/script/anhetegua +++ b/script/anhetegua @@ -48,3 +48,20 @@ new_validator(df, 'Forum Brasileiro de Economia Solidaria', 'fbes') new_validator(rs, 'Associacao Software Livre.Org', 'asl') new_validator(rs, 'Forum Gaucho de Economia Solidaria', 'ecosolrs') +# Profile for exibition of homepage and creations of sytem articles such as about and accessibility +noosfero = Profile.create!(:name => 'noosfero', :identifier => 'noosfero') + +# Role for own things +owner_role = Role.create!(:name => 'owner', :permissions => ['edit_profile', 'destroy_profile', 'manage_memberships', 'post_content', 'edit_profile_design']) + +# root user of the system, admin_role for him, the assignment of the role for him and the ownership of the system homepage +root = User.create!(:login => 'root', :email => 'root@noosfero.org', :password => 'root', :password_confirmation => 'root').person +admin_role = Role.create!(:name => 'admin', :permissions => ['edit_environment_features', 'edit_environment_design', 'manage_environment_categories', 'manage_environment_roles', 'manage_environment_validators']) +RoleAssignment.create!(:accessor => root, :role => admin_role, :resource => nil) +RoleAssignment.create!(:accessor => root, :role => owner_role, :resource => noosfero) + +# Sample user and sample enterprise owned by him +ze= User.create!(:login => 'ze', :email => 'ze@localhost.localdomain', :password => 'test', :password_confirmation => 'test') +empa = Enterprise.create!(:name => 'Empreendimento A', :identifier => 'empreendimento_a') +RoleAssignment.create!(:accessor => ze, :role => owner_role, :resource => empa) + -- libgit2 0.21.2