diff --git a/app/controllers/application.rb b/app/controllers/application.rb
index 35d20d4..2960a75 100644
--- a/app/controllers/application.rb
+++ b/app/controllers/application.rb
@@ -42,8 +42,8 @@ class ApplicationController < ActionController::Base
def render_not_found(path = nil)
@path ||= request.path
- raise "#{@path} not found"
-# 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/design_blocks/profile_info_block/controllers/profile_info_block_controller.rb b/app/design_blocks/profile_info_block/controllers/profile_info_block_controller.rb
index d35fddc..6e1784b 100644
--- 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
@@ -31,6 +31,7 @@ class ProfileInfoBlockController < ApplicationController
def index
@info = @profile.info
+ @can_edit = current_user.person.has_permission?('edit_profile', @profile)
design_render
end
diff --git a/app/design_blocks/profile_info_block/views/index.rhtml b/app/design_blocks/profile_info_block/views/index.rhtml
index 3ec0b96..9f03d83 100644
--- a/app/design_blocks/profile_info_block/views/index.rhtml
+++ b/app/design_blocks/profile_info_block/views/index.rhtml
@@ -1,3 +1,6 @@
<%= image_tag @profile.image.public_filename(:thumb) if @profile.image %>
-<%= @profile.name %>
-<%= n_('1 years', '%{num} years', @info.age) % {:num => @info.age} %>
+<%= link_to_myprofile(_('Change photo'), {:action => 'change_image'}, @profile.identifier ) %>
+<%= _('User since %d') % @profile.created_at.year if @profile.created_at %>
+<%= @info.name ? @info.name : @profile.name if @profile.name %>
+<%= n_('1 year', '%{num} years', @info.age) % {:num => @info.age} if @info.birth_date%>
+
diff --git a/app/design_blocks/view_article/controllers/view_article_controller.rb b/app/design_blocks/view_article/controllers/view_article_controller.rb
new file mode 100644
index 0000000..e5f57e4
--- /dev/null
+++ b/app/design_blocks/view_article/controllers/view_article_controller.rb
@@ -0,0 +1,50 @@
+class ViewArticleController < 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
+ 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/view_article/helpers/view_article_helper.rb b/app/design_blocks/view_article/helpers/view_article_helper.rb
new file mode 100644
index 0000000..43f50a2
--- /dev/null
+++ b/app/design_blocks/view_article/helpers/view_article_helper.rb
@@ -0,0 +1,3 @@
+module ViewArticleHelper
+
+end
diff --git a/app/design_blocks/view_article/models/view_article.rb b/app/design_blocks/view_article/models/view_article.rb
new file mode 100644
index 0000000..1e2018b
--- /dev/null
+++ b/app/design_blocks/view_article/models/view_article.rb
@@ -0,0 +1,31 @@
+class ViewArticle < 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
+ 'ViewArticle'
+ end
+
+ def page
+ self.settings[:page]
+ end
+
+ def page= value
+ self.settings[:page] = value
+ end
+
+ def profile
+ self.settings[:page]
+ end
+
+ def profile= value
+ self.settings[:page] = value
+ end
+
+end
diff --git a/app/design_blocks/view_article/views/edit.rhtml b/app/design_blocks/view_article/views/edit.rhtml
new file mode 100644
index 0000000..a913754
--- /dev/null
+++ b/app/design_blocks/view_article/views/edit.rhtml
@@ -0,0 +1,15 @@
+
+ + <%= text_field 'design_block', 'title'%> +
+ ++ + <%= text_field 'design_block', 'page'%> +
+ + <%= submit_tag _('Save') %> +<% end %> diff --git a/app/design_blocks/view_article/views/index.rhtml b/app/design_blocks/view_article/views/index.rhtml new file mode 100644 index 0000000..232e36a --- /dev/null +++ b/app/design_blocks/view_article/views/index.rhtml @@ -0,0 +1 @@ +<%= render_component(:controller => 'content_viewer', :action => 'view_page', :params => {:profile => @profile.identifier, :page => [@design_block.page], :no_layout => true}) %> diff --git a/app/models/person_info.rb b/app/models/person_info.rb index aefb611..c7c6bb1 100644 --- a/app/models/person_info.rb +++ b/app/models/person_info.rb @@ -10,7 +10,7 @@ class PersonInfo < ActiveRecord::Base def age a = Date.today.year - birth_date.year - Date.today.yday > birth_date.yday ? a : a-1 + Date.today.yday >= birth_date.yday ? a : a-1 end end diff --git a/app/views/profile_editor/change_image.rhtml b/app/views/profile_editor/change_image.rhtml index 71a63a9..cbcb5ea 100644 --- a/app/views/profile_editor/change_image.rhtml +++ b/app/views/profile_editor/change_image.rhtml @@ -1,4 +1,4 @@ -<% form_for :image, @image, :html => { :multipart => true }, :url => { :action => 'change_image'} do |f| %> +<% form_for :image, @image, :html => { :multipart => true }, :url => { :action => 'edit_image_preview'} do |f| %> <%= display_form_field(_('Image'), f.file_field( :uploaded_data ) ) %> <%= display_submit_tag(_('Upload')) %> <%= link_to _('Cancel'), :action => 'index' %> diff --git a/db/migrate/003_create_profiles.rb b/db/migrate/003_create_profiles.rb index 915c3f8..8f5eab9 100644 --- a/db/migrate/003_create_profiles.rb +++ b/db/migrate/003_create_profiles.rb @@ -19,6 +19,7 @@ class CreateProfiles < ActiveRecord::Migration #enterprise fields t.column :region_id, :integer + t.column :created_at, :datetime end end -- libgit2 0.21.2