From aaebddf21a7c799c87b6b53ea1a9fd4c2fd2b958 Mon Sep 17 00:00:00 2001 From: MoisesMachado Date: Tue, 27 Nov 2007 21:51:23 +0000 Subject: [PATCH] ActionItem28: various changes due to utilization of attachment_fu plugin and initial implementation of category view functionaluty still withou route. fixed the list_block and enterprises_block to work with the new block system --- app/controllers/my_profile/manage_products_controller.rb | 3 ++- app/controllers/my_profile/profile_editor_controller.rb | 14 ++++++++++++++ app/design_blocks/enterprises_block/controllers/enterprises_block_controller.rb | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ app/design_blocks/enterprises_block/helpers/enterprises_block_helper.rb | 3 +++ app/design_blocks/enterprises_block/helpers/list_block_helper.rb | 3 +++ app/design_blocks/enterprises_block/models/enterprises_block.rb | 15 +++++++++++++++ app/design_blocks/enterprises_block/views/index.rhtml | 5 +++++ app/design_blocks/list_block/controllers/list_block_controller.rb | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ app/design_blocks/list_block/helpers/list_block_helper.rb | 3 +++ app/design_blocks/list_block/models/list_block.rb | 15 +++++++++++++++ app/design_blocks/list_block/views/index.rhtml | 5 +++++ app/helpers/application_helper.rb | 6 +++++- app/models/enterprises_block.rb | 20 -------------------- app/models/image.rb | 11 +++++++++++ app/models/list_block.rb | 20 -------------------- app/models/product.rb | 16 ++++++++++++++++ app/models/profile.rb | 2 ++ app/views/account/signup.rhtml | 2 +- app/views/categories/_form.rhtml | 2 +- app/views/environment_role_manager/change_role.rhtml | 2 +- app/views/environment_role_manager/make_admin.rhtml | 2 +- app/views/manage_products/_form.rhtml | 13 +++++++------ app/views/manage_products/show.rhtml | 1 + app/views/profile_editor/change_image.rhtml | 4 ++++ app/views/profile_editor/index.rhtml | 2 ++ app/views/profile_members/change_role.rhtml | 2 +- app/views/role/_form.rhtml | 2 +- config/routes.rb | 2 +- db/migrate/016_create_products.rb | 1 + db/migrate/017_create_images.rb | 20 ++++++++++++++++++++ po/noosfero.pot | 652 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- po/pt_BR/noosfero.po | 899 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ public/designs/templates/default/stylesheets/style.css | 6 ++++++ test/fixtures/images.yml | 5 +++++ test/unit/image_test.rb | 10 ++++++++++ 35 files changed, 1103 insertions(+), 767 deletions(-) create mode 100644 app/design_blocks/enterprises_block/controllers/enterprises_block_controller.rb create mode 100644 app/design_blocks/enterprises_block/helpers/enterprises_block_helper.rb create mode 100644 app/design_blocks/enterprises_block/helpers/list_block_helper.rb create mode 100644 app/design_blocks/enterprises_block/models/enterprises_block.rb create mode 100644 app/design_blocks/enterprises_block/views/index.rhtml create mode 100644 app/design_blocks/list_block/controllers/list_block_controller.rb create mode 100644 app/design_blocks/list_block/helpers/list_block_helper.rb create mode 100644 app/design_blocks/list_block/models/list_block.rb create mode 100644 app/design_blocks/list_block/views/index.rhtml delete mode 100644 app/models/enterprises_block.rb create mode 100644 app/models/image.rb delete mode 100644 app/models/list_block.rb create mode 100644 app/views/profile_editor/change_image.rhtml create mode 100644 db/migrate/017_create_images.rb create mode 100644 test/fixtures/images.yml create mode 100644 test/unit/image_test.rb diff --git a/app/controllers/my_profile/manage_products_controller.rb b/app/controllers/my_profile/manage_products_controller.rb index 9782432..d802362 100644 --- a/app/controllers/my_profile/manage_products_controller.rb +++ b/app/controllers/my_profile/manage_products_controller.rb @@ -1,7 +1,7 @@ class ManageProductsController < ApplicationController needs_profile - protect 'manage_products', :profile +# protect 'manage_products', :profile def index @products = @profile.products @@ -13,6 +13,7 @@ class ManageProductsController < ApplicationController def new @product = @profile.products.build(params[:product]) + @product.build_image unless @product.image if request.post? if @product.save flash[:notice] = _('Product succesfully created') diff --git a/app/controllers/my_profile/profile_editor_controller.rb b/app/controllers/my_profile/profile_editor_controller.rb index 08ca1a4..45f7b35 100644 --- a/app/controllers/my_profile/profile_editor_controller.rb +++ b/app/controllers/my_profile/profile_editor_controller.rb @@ -11,6 +11,7 @@ class ProfileEditorController < MyProfileController %w[ FavoriteLinksProfile ListBlock + EnterprisesBlock ] end @@ -34,5 +35,18 @@ class ProfileEditorController < MyProfileController render :action => @info.class.name.underscore end end + + def change_image + @image = @profile.image ? @profile.image : @profile.build_image + if request.post? + if @profile.image.update_attributes(params[:image]) + flash[:notice] = _('Image successfully uploaded') + redirect_to :action => 'index' + else + flash[:notice] = _('Could not upload image') + render :action => 'change_imange' + end + end + end end diff --git a/app/design_blocks/enterprises_block/controllers/enterprises_block_controller.rb b/app/design_blocks/enterprises_block/controllers/enterprises_block_controller.rb new file mode 100644 index 0000000..e3b24fc --- /dev/null +++ b/app/design_blocks/enterprises_block/controllers/enterprises_block_controller.rb @@ -0,0 +1,51 @@ +class EnterprisesBlockController < ApplicationController + + # This controller always has the object @design_block available to it. + # The method acts_as_design_block load a before_filter that always load + # this object. + + needs_profile + + acts_as_design_block + + # You must have a hash on format: + # { + # 'action name' => 'How the action will be displayed on menu' + # } + # + # EX: + # CONTROL_ACTION_OPTIONS = { + # 'design_edit' => _('Edit'), + # 'manage_links' => _('Manage Links') + # } + # + # This hash will define the options menu on edit mode. + CONTROL_ACTION_OPTIONS = { +# 'edit' => _('Edit') + } + + + ########################### + # Mandatory methods + ########################### + + def index + @enterprises = Enterprise.find(:all) + design_render + end + + ########################### + # Other Sample of methods + ########################### + +# def edit +# design_render_on_edit +# end + +# def save +# @design_block.update_attributes(params[:design_block]) +# design_render_on_edit :nothing => true +# end + + +end diff --git a/app/design_blocks/enterprises_block/helpers/enterprises_block_helper.rb b/app/design_blocks/enterprises_block/helpers/enterprises_block_helper.rb new file mode 100644 index 0000000..cc629c1 --- /dev/null +++ b/app/design_blocks/enterprises_block/helpers/enterprises_block_helper.rb @@ -0,0 +1,3 @@ +module EnterprisesBlockHelper + +end diff --git a/app/design_blocks/enterprises_block/helpers/list_block_helper.rb b/app/design_blocks/enterprises_block/helpers/list_block_helper.rb new file mode 100644 index 0000000..6887d0f --- /dev/null +++ b/app/design_blocks/enterprises_block/helpers/list_block_helper.rb @@ -0,0 +1,3 @@ +module ListBlockHelper + +end diff --git a/app/design_blocks/enterprises_block/models/enterprises_block.rb b/app/design_blocks/enterprises_block/models/enterprises_block.rb new file mode 100644 index 0000000..0f1b321 --- /dev/null +++ b/app/design_blocks/enterprises_block/models/enterprises_block.rb @@ -0,0 +1,15 @@ +class EnterprisesBlock < Design::Block + + # Define an specific method using the settings hash serialized + # variable to keep the value desired by method. + # + # EX: + # def max_number_of_element= value + # self.settings[:limit_number] = value + # end + + def self.description + _('Enterprises Block') + end + +end diff --git a/app/design_blocks/enterprises_block/views/index.rhtml b/app/design_blocks/enterprises_block/views/index.rhtml new file mode 100644 index 0000000..b147bb0 --- /dev/null +++ b/app/design_blocks/enterprises_block/views/index.rhtml @@ -0,0 +1,5 @@ + diff --git a/app/design_blocks/list_block/controllers/list_block_controller.rb b/app/design_blocks/list_block/controllers/list_block_controller.rb new file mode 100644 index 0000000..597d20f --- /dev/null +++ b/app/design_blocks/list_block/controllers/list_block_controller.rb @@ -0,0 +1,51 @@ +class ListBlockController < ApplicationController + + # This controller always has the object @design_block available to it. + # The method acts_as_design_block load a before_filter that always load + # this object. + + needs_profile + + acts_as_design_block + + # You must have a hash on format: + # { + # 'action name' => 'How the action will be displayed on menu' + # } + # + # EX: + # CONTROL_ACTION_OPTIONS = { + # 'design_edit' => _('Edit'), + # 'manage_links' => _('Manage Links') + # } + # + # This hash will define the options menu on edit mode. + CONTROL_ACTION_OPTIONS = { +# 'edit' => _('Edit') + } + + + ########################### + # Mandatory methods + ########################### + + def index + @people = Person.find(:all) + design_render + end + + ########################### + # Other Sample of methods + ########################### + +# def edit +# design_render_on_edit +# end + +# def save +# @design_block.update_attributes(params[:design_block]) +# design_render_on_edit :nothing => true +# end + + +end diff --git a/app/design_blocks/list_block/helpers/list_block_helper.rb b/app/design_blocks/list_block/helpers/list_block_helper.rb new file mode 100644 index 0000000..6887d0f --- /dev/null +++ b/app/design_blocks/list_block/helpers/list_block_helper.rb @@ -0,0 +1,3 @@ +module ListBlockHelper + +end diff --git a/app/design_blocks/list_block/models/list_block.rb b/app/design_blocks/list_block/models/list_block.rb new file mode 100644 index 0000000..d22c154 --- /dev/null +++ b/app/design_blocks/list_block/models/list_block.rb @@ -0,0 +1,15 @@ +class ListBlock < Design::Block + + # Define an specific method using the settings hash serialized + # variable to keep the value desired by method. + # + # EX: + # def max_number_of_element= value + # self.settings[:limit_number] = value + # end + + def self.description + _('List Block') + end + +end diff --git a/app/design_blocks/list_block/views/index.rhtml b/app/design_blocks/list_block/views/index.rhtml new file mode 100644 index 0000000..a267a59 --- /dev/null +++ b/app/design_blocks/list_block/views/index.rhtml @@ -0,0 +1,5 @@ + diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b728c30..0e1122a 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -244,7 +244,11 @@ module ApplicationHelper # Current implementation generates a