diff --git a/app/controllers/application.rb b/app/controllers/application.rb index 02e0df2..ac31829 100644 --- a/app/controllers/application.rb +++ b/app/controllers/application.rb @@ -39,6 +39,16 @@ class ApplicationController < ActionController::Base @profile end + def self.needs_profile + before_filter :load_profile + design :holder => 'profile' + end + + def load_profile + @profile = Profile.find_by_identifier(params[:profile]) + raise "There is no profile with identifier %s" % params[:profile] if @profile.nil? + end + def self.acts_as_environment_admin_controller before_filter :load_admin_controller end diff --git a/app/controllers/profile_admin/cms_controller.rb b/app/controllers/profile_admin/cms_controller.rb index 70b0765..9a4d136 100644 --- a/app/controllers/profile_admin/cms_controller.rb +++ b/app/controllers/profile_admin/cms_controller.rb @@ -1,13 +1,10 @@ class CmsController < ComatoseAdminController extend PermissionCheck + + needs_profile define_option :page_class, Article # not yet # protect [:edit, :new, :reorder, :delete], :post_content, :profile - - protected - def profile - Profile.find_by_identifier(params[:profile]) - end end diff --git a/app/controllers/profile_admin/enterprise_editor_controller.rb b/app/controllers/profile_admin/enterprise_editor_controller.rb index 9dd286d..3243482 100644 --- a/app/controllers/profile_admin/enterprise_editor_controller.rb +++ b/app/controllers/profile_admin/enterprise_editor_controller.rb @@ -1,9 +1,11 @@ class EnterpriseEditorController < ProfileAdminController - before_filter :logon, :check_enterprise + before_filter :login_required, :check_enterprise + protect [:edit, :update], :edit_profile, :profile protect [:destroy], :destroy_profile, :profile + needs_profile # Show details about an enterprise def index @@ -45,13 +47,6 @@ class EnterpriseEditorController < ProfileAdminController protected - def logon - if logged_in? - @user = current_user - @person = @user.person - end - end - def check_enterprise redirect_to '/' unless @profile.is_a?(Enterprise) @enterprise = @profile diff --git a/app/controllers/profile_admin/membership_editor_controller.rb b/app/controllers/profile_admin/membership_editor_controller.rb index 56e3775..ac53cbb 100644 --- a/app/controllers/profile_admin/membership_editor_controller.rb +++ b/app/controllers/profile_admin/membership_editor_controller.rb @@ -1,7 +1,9 @@ class MembershipEditorController < ProfileAdminController - - before_filter :logon + before_filter :login_required + + needs_profile + def index @memberships = current_user.person.memberships end @@ -30,9 +32,4 @@ class MembershipEditorController < ProfileAdminController @tagged_enterprises = Enterprise.search(params[:query]) end - protected - - def logon - redirect_to :controller => :account unless logged_in? - end end diff --git a/app/controllers/profile_admin/profile_editor_controller.rb b/app/controllers/profile_admin/profile_editor_controller.rb index 366aea9..891940b 100644 --- a/app/controllers/profile_admin/profile_editor_controller.rb +++ b/app/controllers/profile_admin/profile_editor_controller.rb @@ -1,6 +1,17 @@ class ProfileEditorController < ProfileAdminController helper :profile + design_editor :holder => 'profile', :autosave => true, :block_types => :block_types + + def block_types + { + 'ListBlock' => _("List Block"), + 'LinkBlock' => _("Link Block"), + 'Design::MainBlock' => _('Main content block'), + } + end + + # edits the profile info (posts back) def edit if request.post? diff --git a/app/controllers/public/content_viewer_controller.rb b/app/controllers/public/content_viewer_controller.rb index 4de5307..f99aa15 100644 --- a/app/controllers/public/content_viewer_controller.rb +++ b/app/controllers/public/content_viewer_controller.rb @@ -1,5 +1,7 @@ class ContentViewerController < PublicController + needs_profile + def view_page path = params[:page].clone path.unshift(params[:profile]) diff --git a/app/models/profile.rb b/app/models/profile.rb index c2b14f8..08f3dc9 100644 --- a/app/models/profile.rb +++ b/app/models/profile.rb @@ -25,6 +25,8 @@ class Profile < ActiveRecord::Base acts_as_accessible + acts_as_design + acts_as_ferret :fields => [ :name ] # Valid identifiers must match this format. diff --git a/app/views/profile_editor/index.rhtml b/app/views/profile_editor/index.rhtml index 6b1fd2d..e55df58 100644 --- a/app/views/profile_editor/index.rhtml +++ b/app/views/profile_editor/index.rhtml @@ -4,7 +4,7 @@

<%= link_to _('Edit'), :action => 'edit' %>

-

<%= link_to _('Manage members'), :controller => 'profile_members' %>

+

<%= link_to _('Edit Visual Design'), :action => 'design_editor' %>

<%= link_to _('Menage content'), :controller => 'cms' %>

diff --git a/db/migrate/003_create_profiles.rb b/db/migrate/003_create_profiles.rb index e90b432..8047c85 100644 --- a/db/migrate/003_create_profiles.rb +++ b/db/migrate/003_create_profiles.rb @@ -5,6 +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 :active, :boolean, :default => true -- libgit2 0.21.2