diff --git a/app/controllers/my_profile/cms_controller.rb b/app/controllers/my_profile/cms_controller.rb index 86124d9..45bc0a4 100644 --- a/app/controllers/my_profile/cms_controller.rb +++ b/app/controllers/my_profile/cms_controller.rb @@ -4,7 +4,22 @@ class CmsController < MyProfileController # protect 'post_content', :profile, :only => [:edit, :new, :reorder, :delete] def view - @document = profile.documents.find(params[:id]) + @article = profile.articles.find(params[:id]) + @subitems = @article.children + end + + def index + @article = profile.home_page + @subitems = profile.top_level_articles + render :action => 'view' + end + + post_only :set_home_page + def set_home_page + @article = profile.articles.find(params[:id]) + profile.home_page = @article + profile.save! + redirect_to :back end protected diff --git a/app/models/profile.rb b/app/models/profile.rb index 606d29f..ea905c3 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -43,6 +43,7 @@ class Profile < ActiveRecord::Base has_many :role_assignments, :as => :resource has_many :articles + belongs_to :home_page, :class_name => Article.name, :foreign_key => 'home_page_id' def top_level_articles(reload = false) if reload @@ -78,11 +79,6 @@ class Profile < ActiveRecord::Base find_tagged_with(term) + find_all_by_name(term) end - def homepage(reload = false) - # FIXME - raise 'needs to be implemented' - end - # Returns information about the profile's owner that was made public by # him/her. # diff --git a/app/views/cms/view.rhtml b/app/views/cms/view.rhtml index 4584344..b676991 100644 --- a/app/views/cms/view.rhtml +++ b/app/views/cms/view.rhtml @@ -1,3 +1,35 @@ -<%# FIXME %> +<% if @article %> +