diff --git a/app/controllers/admin/edit_template_controller.rb b/app/controllers/admin/edit_template_controller.rb
index bcb5f6d..f130b10 100644
--- a/app/controllers/admin/edit_template_controller.rb
+++ b/app/controllers/admin/edit_template_controller.rb
@@ -4,7 +4,8 @@ class EditTemplateController < AdminController
def block_types
%w[
- FavoriteLinksProfile
+ FavoriteLinks
+ ListBlock
]
end
diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index f71ff90..35d20d4 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -42,7 +42,8 @@ class ApplicationController < ActionController::Base
def render_not_found(path = nil)
@path ||= request.path
- render(:file => File.join(RAILS_ROOT, 'app', 'views', 'shared', 'not_found.rhtml'), :layout => 'not_found', :status => 404) && false
+ raise "#{@path} not found"
+# render(:file => File.join(RAILS_ROOT, 'app', 'views', 'shared', 'not_found.rhtml'), :layout => 'not_found', :status => 404) && false
end
def load_admin_controller
diff --git a/app/controllers/my_profile/profile_editor_controller.rb b/app/controllers/my_profile/profile_editor_controller.rb
index 54719be..88961e2 100644
--- a/app/controllers/my_profile/profile_editor_controller.rb
+++ b/app/controllers/my_profile/profile_editor_controller.rb
@@ -11,7 +11,7 @@ class ProfileEditorController < MyProfileController
%w[
FavoriteLinksProfile
ListBlock
- EnterprisesBlock
+ ProfileInfoBlock
]
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
deleted file mode 100644
index e3b24fc..0000000
--- a/app/design_blocks/enterprises_block/controllers/enterprises_block_controller.rb
+++ /dev/null
@@ -1,51 +0,0 @@
-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
deleted file mode 100644
index cc629c1..0000000
--- a/app/design_blocks/enterprises_block/helpers/enterprises_block_helper.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-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
deleted file mode 100644
index 6887d0f..0000000
--- a/app/design_blocks/enterprises_block/helpers/list_block_helper.rb
+++ /dev/null
@@ -1,3 +0,0 @@
-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
deleted file mode 100644
index 0f1b321..0000000
--- a/app/design_blocks/enterprises_block/models/enterprises_block.rb
+++ /dev/null
@@ -1,15 +0,0 @@
-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
deleted file mode 100644
index b147bb0..0000000
--- a/app/design_blocks/enterprises_block/views/index.rhtml
+++ /dev/null
@@ -1,5 +0,0 @@
-
- <% @enterprises.each do |e| %>
- - <%= link_to_homepage(content_tag('span', e.name), e.identifier) %>
- <% end %>
-
diff --git a/app/design_blocks/list_block/controllers/list_block_controller.rb b/app/design_blocks/list_block/controllers/list_block_controller.rb
index 75b8704..1f83b3a 100644
--- a/app/design_blocks/list_block/controllers/list_block_controller.rb
+++ b/app/design_blocks/list_block/controllers/list_block_controller.rb
@@ -5,7 +5,7 @@ class ListBlockController < ApplicationController
# this object.
needs_profile
-
+
acts_as_design_block
# You must have a hash on format:
@@ -30,8 +30,8 @@ class ListBlockController < ApplicationController
###########################
def index
- @people = @design_block.people
- design_render
+ @elements = @design_block.elements
+ design_render :action => @design_block.view
end
###########################
@@ -40,6 +40,7 @@ class ListBlockController < ApplicationController
def edit
+ @elements_types = @design_block.elements_types
design_render_on_edit :controller => 'list_block', :action => 'edit'
end
diff --git a/app/design_blocks/list_block/models/list_block.rb b/app/design_blocks/list_block/models/list_block.rb
index f37258c..20e47f8 100644
--- a/app/design_blocks/list_block/models/list_block.rb
+++ b/app/design_blocks/list_block/models/list_block.rb
@@ -20,8 +20,26 @@ class ListBlock < Design::Block
self.settings[:limit_number]
end
- def people
- Person.find(:all, :limit => limit_number)
+ def elements_types
+ ['Person', 'Enterprise']
+ end
+
+ def element_type
+ self.settings[:element_type]
+ end
+
+ def element_type= value
+ return nil unless elements_types.include?(value)
+ self.settings[:element_type] = value
+ end
+
+ def elements
+ return nil unless element_type
+ self.element_type.constantize.find(:all, :limit => limit_number)
+ end
+
+ def view
+ element_type.to_s.underscore
end
end
diff --git a/app/design_blocks/list_block/views/edit.rhtml b/app/design_blocks/list_block/views/edit.rhtml
index 2dda4db..f113014 100644
--- a/app/design_blocks/list_block/views/edit.rhtml
+++ b/app/design_blocks/list_block/views/edit.rhtml
@@ -4,10 +4,15 @@
<%= text_field 'design_block', 'title'%>
+
+
+
+
+ <%= select 'design_block', 'element_type', @elements_types %>
-
+
<%= text_field 'design_block', 'limit_number'%>
diff --git a/app/design_blocks/list_block/views/enterprise.rhtml b/app/design_blocks/list_block/views/enterprise.rhtml
new file mode 100644
index 0000000..eed5b71
--- /dev/null
+++ b/app/design_blocks/list_block/views/enterprise.rhtml
@@ -0,0 +1,5 @@
+
+ <% @elements.each do |p| %>
+ - <%= link_to_homepage(content_tag('span',p.name) + (p.image ? image_tag(p.image.public_filename :portrait) : ''), p.identifier) %>
+ <% end %>
+
diff --git a/app/design_blocks/list_block/views/index.rhtml b/app/design_blocks/list_block/views/index.rhtml
deleted file mode 100644
index aef8595..0000000
--- a/app/design_blocks/list_block/views/index.rhtml
+++ /dev/null
@@ -1,5 +0,0 @@
-
- <% @people.each do |p| %>
- - <%= link_to_homepage(content_tag('span',p.name) + (p.image ? image_tag(p.image.public_filename :portrait) : ''), p.identifier) %>
- <% end %>
-
diff --git a/app/design_blocks/list_block/views/person.rhtml b/app/design_blocks/list_block/views/person.rhtml
new file mode 100644
index 0000000..f6be13d
--- /dev/null
+++ b/app/design_blocks/list_block/views/person.rhtml
@@ -0,0 +1,5 @@
+
+ <% @elements.each do |p| %>
+ - <%= link_to_homepage(content_tag('span',p.name) + (p.image ? image_tag(p.image.public_filename :portrait) : ''), p.identifier) %>
+ <% end %>
+
diff --git a/app/design_blocks/profile_info_block/controllers/profile_info_block_controller.rb b/app/design_blocks/profile_info_block/controllers/profile_info_block_controller.rb
new file mode 100644
index 0000000..d35fddc
--- /dev/null
+++ b/app/design_blocks/profile_info_block/controllers/profile_info_block_controller.rb
@@ -0,0 +1,51 @@
+class ProfileInfoBlockController < 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
+ @info = @profile.info
+ 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/profile_info_block/helpers/profile_info_block_helper.rb b/app/design_blocks/profile_info_block/helpers/profile_info_block_helper.rb
new file mode 100644
index 0000000..9d0344f
--- /dev/null
+++ b/app/design_blocks/profile_info_block/helpers/profile_info_block_helper.rb
@@ -0,0 +1,3 @@
+module ProfileInfoBlockHelper
+
+end
diff --git a/app/design_blocks/profile_info_block/models/profile_info_block.rb b/app/design_blocks/profile_info_block/models/profile_info_block.rb
new file mode 100644
index 0000000..50f9737
--- /dev/null
+++ b/app/design_blocks/profile_info_block/models/profile_info_block.rb
@@ -0,0 +1,15 @@
+class ProfileInfoBlock < 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
+ 'ProfileInfoBlock'
+ end
+
+end
diff --git a/app/design_blocks/profile_info_block/views/index.rhtml b/app/design_blocks/profile_info_block/views/index.rhtml
new file mode 100644
index 0000000..3ec0b96
--- /dev/null
+++ b/app/design_blocks/profile_info_block/views/index.rhtml
@@ -0,0 +1,3 @@
+<%= image_tag @profile.image.public_filename(:thumb) if @profile.image %>
+<%= @profile.name %>
+<%= n_('1 years', '%{num} years', @info.age) % {:num => @info.age} %>
diff --git a/app/models/person_info.rb b/app/models/person_info.rb
index b8dffd5..aefb611 100644
--- a/app/models/person_info.rb
+++ b/app/models/person_info.rb
@@ -1,15 +1,16 @@
class PersonInfo < ActiveRecord::Base
- # FIXME: add file_column :photo
-
belongs_to :person
def summary
- [
- [ PersonInfo.columns_hash['name'].human_name, self.name ],
- [ PersonInfo.columns_hash['address'].human_name, self.address ],
- [ PersonInfo.columns_hash['contact_information'].human_name, self.contact_information ],
- ]
+ ['name', 'sex', 'birth_date', 'address', 'city', 'state', 'country'].map do |col|
+ [ PersonInfo.columns_hash[col] && PersonInfo.columns_hash[col].human_name, self.send(col) ]
+ end
+ end
+
+ def age
+ a = Date.today.year - birth_date.year
+ Date.today.yday > birth_date.yday ? a : a-1
end
end
diff --git a/app/models/profile.rb b/app/models/profile.rb
index 2e77dbf..75363bf 100644
--- a/app/models/profile.rb
+++ b/app/models/profile.rb
@@ -34,6 +34,7 @@ class Profile < ActiveRecord::Base
not_found
cat
tag
+ environment
]
belongs_to :user
diff --git a/app/views/category/_product_category.rhtml b/app/views/category/_product_category.rhtml
index 861465a..8c6ee8d 100644
--- a/app/views/category/_product_category.rhtml
+++ b/app/views/category/_product_category.rhtml
@@ -1,3 +1,4 @@
+<%= link_to(_('I consume this'), {:profile => current_user.login, :controller => 'consumed_products', :action => 'new', 'consumption[product_category_id]' => @category.id }, :method => :post) %>
- <%= n_("One product in this category.", "%{num} products in this category.", @products.size) % { :num => @products.size } %>
- <%= n_("One enterprise sells products in this category.", "%{num} enterprises sells products in this category.", @enterprises.size) % { :num => @enterprises.size} %>
diff --git a/app/views/profile_editor/enterprise_info.rhtml b/app/views/profile_editor/enterprise_info.rhtml
new file mode 100644
index 0000000..9f333f5
--- /dev/null
+++ b/app/views/profile_editor/enterprise_info.rhtml
@@ -0,0 +1,32 @@
+
+<%= text_field 'enterprise', 'name', 'size' => 20, 'class' => 'formfield text_field' %>
+
+
+<%= text_field 'enterprise', 'address', 'size' => 50 %>
+
+
+<%= text_field 'enterprise', 'contact_phone', 'size' => 20 %>
+
+
+<%= text_field 'organization_info', 'contact_person', 'size' => 20 %>
+
+
+<%= text_field 'organization_info', 'acronym', 'size' => 20 %>
+
+
+<%= text_field 'organization_info', 'foundation_year', 'size' => 20 %>
+
+
+<%= text_field 'organization_info', 'legal_form', 'size' => 20 %>
+
+
+<%= text_field 'organization_info', 'economic_activity', 'size' => 20 %>
+
+
+<%= text_area 'organization_info', 'management_information', 'cols' => 40, 'rows' => 20 %>
+
+
+<%= select 'validation_entity', 'id', @validation_entities.map{|v| [v.name, v.id]}, :include_blank => true %>
+
+
+<%= text_field 'enterprise', 'tag_list', 'size' => 20 %>
diff --git a/app/views/profile_editor/person_info.rhtml b/app/views/profile_editor/person_info.rhtml
index 982a7b4..c46d482 100644
--- a/app/views/profile_editor/person_info.rhtml
+++ b/app/views/profile_editor/person_info.rhtml
@@ -4,9 +4,16 @@
<%= display_form_field(_('Name'), f.text_field(:name)) %>
- <%= display_form_field(_('Address'), f.text_area(:address, :rows => 5)) %>
-
<%= display_form_field(_('Contact Information'), f.text_area(:contact_information, :rows => 5)) %>
+ <%= display_form_field(_('Birth day'), f.date_select(:birth_date, :start_year => 1930, :use_month_numbers => true, :order => [:day, :month, :year])) %>
+
+ <%= _('Sex: ') %>
+ <%= display_form_field(_('Male'), f.radio_button(:sex, 'male')) %>
+ <%= display_form_field(_('Female'), f.radio_button(:sex, 'female')) %>
+ <%= display_form_field(_('Address'), f.text_area(:address, :rows => 3)) %>
+ <%= display_form_field(_('City'), f.text_field(:city)) %>
+ <%= display_form_field(_('State'), f.text_field(:state)) %>
+ <%= display_form_field(_('Country'), f.text_field(:country)) %>
<%= submit_tag _('Save') %>
diff --git a/db/migrate/003_create_profiles.rb b/db/migrate/003_create_profiles.rb
index f1f26b5..915c3f8 100644
--- a/db/migrate/003_create_profiles.rb
+++ b/db/migrate/003_create_profiles.rb
@@ -5,7 +5,7 @@ class CreateProfiles < ActiveRecord::Migration
t.column :type, :string
t.column :identifier, :string
t.column :environment_id, :integer
- t.column :design_data, :text
+ t.column :design_data, :text
t.column :active, :boolean, :default => true
t.column :address, :string
diff --git a/db/migrate/010_create_person_infos.rb b/db/migrate/010_create_person_infos.rb
index 79a56b2..1e67d66 100644
--- a/db/migrate/010_create_person_infos.rb
+++ b/db/migrate/010_create_person_infos.rb
@@ -1,12 +1,19 @@
class CreatePersonInfos < ActiveRecord::Migration
def self.up
create_table :person_infos do |t|
- t.column :name, :string
- t.column :photo, :text
- t.column :address, :text
+ t.column :name, :string
+ t.column :photo, :text
t.column :contact_information, :text
+ t.column :birth_date, :date
+ t.column :sex, :string
+ t.column :address, :text
+ t.column :city, :string
+ t.column :state, :string
+ t.column :country, :string
- t.column :person_id, :integer
+ t.column :created_at, :datetime
+ t.column :updated_at, :datetime
+ t.column :person_id, :integer
end
end
diff --git a/test/integration/routing_test.rb b/test/integration/routing_test.rb
index 0209658..c5b0f6e 100644
--- a/test/integration/routing_test.rb
+++ b/test/integration/routing_test.rb
@@ -83,6 +83,9 @@ class RoutingTest < ActionController::IntegrationTest
def test_routing_to_controllers_inside_design_blocks_directory
assert_routing('/block/cojones/favorite_links_profile/show/1', :profile => 'cojones', :controller => 'favorite_links_profile', :action => 'show', :id => '1')
assert_routing('/block/cojones/favorite_links_profile/save', :profile => 'cojones', :controller => 'favorite_links_profile', :action => 'save')
+ assert_routing('/block/environment/favorite_links_profile/design_editor_destroy_block', :controller => 'favorite_links_profile', :action => 'design_editor_destroy_block' )
+
+ assert_routing('/block/cojones/list_block/show/1', :profile => 'cojones', :controller => 'list_block', :action => 'show', :id => '1')
end
def test_tag_viewing
--
libgit2 0.21.2