Commit 3263ed31c0988874234135cf43309c4a65dc521e
1 parent
c48431c0
Exists in
staging
and in
42 other branches
ActionItem77: Adding design support to profile object
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@712 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
9 changed files
with
36 additions
and
21 deletions
Show diff stats
app/controllers/application.rb
@@ -39,6 +39,16 @@ class ApplicationController < ActionController::Base | @@ -39,6 +39,16 @@ class ApplicationController < ActionController::Base | ||
39 | @profile | 39 | @profile |
40 | end | 40 | end |
41 | 41 | ||
42 | + def self.needs_profile | ||
43 | + before_filter :load_profile | ||
44 | + design :holder => 'profile' | ||
45 | + end | ||
46 | + | ||
47 | + def load_profile | ||
48 | + @profile = Profile.find_by_identifier(params[:profile]) | ||
49 | + raise "There is no profile with identifier %s" % params[:profile] if @profile.nil? | ||
50 | + end | ||
51 | + | ||
42 | def self.acts_as_environment_admin_controller | 52 | def self.acts_as_environment_admin_controller |
43 | before_filter :load_admin_controller | 53 | before_filter :load_admin_controller |
44 | end | 54 | end |
app/controllers/profile_admin/cms_controller.rb
1 | class CmsController < ComatoseAdminController | 1 | class CmsController < ComatoseAdminController |
2 | extend PermissionCheck | 2 | extend PermissionCheck |
3 | + | ||
4 | + needs_profile | ||
3 | 5 | ||
4 | define_option :page_class, Article | 6 | define_option :page_class, Article |
5 | 7 | ||
6 | # not yet | 8 | # not yet |
7 | # protect [:edit, :new, :reorder, :delete], :post_content, :profile | 9 | # protect [:edit, :new, :reorder, :delete], :post_content, :profile |
8 | - | ||
9 | - protected | ||
10 | - def profile | ||
11 | - Profile.find_by_identifier(params[:profile]) | ||
12 | - end | ||
13 | end | 10 | end |
app/controllers/profile_admin/enterprise_editor_controller.rb
1 | class EnterpriseEditorController < ProfileAdminController | 1 | class EnterpriseEditorController < ProfileAdminController |
2 | 2 | ||
3 | - before_filter :logon, :check_enterprise | 3 | + before_filter :login_required, :check_enterprise |
4 | + | ||
4 | protect [:edit, :update], :edit_profile, :profile | 5 | protect [:edit, :update], :edit_profile, :profile |
5 | protect [:destroy], :destroy_profile, :profile | 6 | protect [:destroy], :destroy_profile, :profile |
6 | 7 | ||
8 | + needs_profile | ||
7 | 9 | ||
8 | # Show details about an enterprise | 10 | # Show details about an enterprise |
9 | def index | 11 | def index |
@@ -45,13 +47,6 @@ class EnterpriseEditorController < ProfileAdminController | @@ -45,13 +47,6 @@ class EnterpriseEditorController < ProfileAdminController | ||
45 | 47 | ||
46 | protected | 48 | protected |
47 | 49 | ||
48 | - def logon | ||
49 | - if logged_in? | ||
50 | - @user = current_user | ||
51 | - @person = @user.person | ||
52 | - end | ||
53 | - end | ||
54 | - | ||
55 | def check_enterprise | 50 | def check_enterprise |
56 | redirect_to '/' unless @profile.is_a?(Enterprise) | 51 | redirect_to '/' unless @profile.is_a?(Enterprise) |
57 | @enterprise = @profile | 52 | @enterprise = @profile |
app/controllers/profile_admin/membership_editor_controller.rb
1 | class MembershipEditorController < ProfileAdminController | 1 | class MembershipEditorController < ProfileAdminController |
2 | - | ||
3 | - before_filter :logon | ||
4 | 2 | ||
3 | + before_filter :login_required | ||
4 | + | ||
5 | + needs_profile | ||
6 | + | ||
5 | def index | 7 | def index |
6 | @memberships = current_user.person.memberships | 8 | @memberships = current_user.person.memberships |
7 | end | 9 | end |
@@ -30,9 +32,4 @@ class MembershipEditorController < ProfileAdminController | @@ -30,9 +32,4 @@ class MembershipEditorController < ProfileAdminController | ||
30 | @tagged_enterprises = Enterprise.search(params[:query]) | 32 | @tagged_enterprises = Enterprise.search(params[:query]) |
31 | end | 33 | end |
32 | 34 | ||
33 | - protected | ||
34 | - | ||
35 | - def logon | ||
36 | - redirect_to :controller => :account unless logged_in? | ||
37 | - end | ||
38 | end | 35 | end |
app/controllers/profile_admin/profile_editor_controller.rb
1 | class ProfileEditorController < ProfileAdminController | 1 | class ProfileEditorController < ProfileAdminController |
2 | helper :profile | 2 | helper :profile |
3 | 3 | ||
4 | + design_editor :holder => 'profile', :autosave => true, :block_types => :block_types | ||
5 | + | ||
6 | + def block_types | ||
7 | + { | ||
8 | + 'ListBlock' => _("List Block"), | ||
9 | + 'LinkBlock' => _("Link Block"), | ||
10 | + 'Design::MainBlock' => _('Main content block'), | ||
11 | + } | ||
12 | + end | ||
13 | + | ||
14 | + | ||
4 | # edits the profile info (posts back) | 15 | # edits the profile info (posts back) |
5 | def edit | 16 | def edit |
6 | if request.post? | 17 | if request.post? |
app/controllers/public/content_viewer_controller.rb
app/models/profile.rb
@@ -25,6 +25,8 @@ class Profile < ActiveRecord::Base | @@ -25,6 +25,8 @@ class Profile < ActiveRecord::Base | ||
25 | 25 | ||
26 | acts_as_accessible | 26 | acts_as_accessible |
27 | 27 | ||
28 | + acts_as_design | ||
29 | + | ||
28 | acts_as_ferret :fields => [ :name ] | 30 | acts_as_ferret :fields => [ :name ] |
29 | 31 | ||
30 | # Valid identifiers must match this format. | 32 | # Valid identifiers must match this format. |
app/views/profile_editor/index.rhtml
@@ -4,7 +4,7 @@ | @@ -4,7 +4,7 @@ | ||
4 | 4 | ||
5 | <p> <%= link_to _('Edit'), :action => 'edit' %> </p> | 5 | <p> <%= link_to _('Edit'), :action => 'edit' %> </p> |
6 | 6 | ||
7 | -<p> <%= link_to _('Manage members'), :controller => 'profile_members' %> </p> | 7 | +<p> <%= link_to _('Edit Visual Design'), :action => 'design_editor' %> </p> |
8 | 8 | ||
9 | <p> <%= link_to _('Menage content'), :controller => 'cms' %> </p> | 9 | <p> <%= link_to _('Menage content'), :controller => 'cms' %> </p> |
10 | 10 |
db/migrate/003_create_profiles.rb
@@ -5,6 +5,7 @@ class CreateProfiles < ActiveRecord::Migration | @@ -5,6 +5,7 @@ class CreateProfiles < ActiveRecord::Migration | ||
5 | t.column :type, :string | 5 | t.column :type, :string |
6 | t.column :identifier, :string | 6 | t.column :identifier, :string |
7 | t.column :environment_id, :integer | 7 | t.column :environment_id, :integer |
8 | + t.column :design_data, :text | ||
8 | 9 | ||
9 | 10 | ||
10 | t.column :active, :boolean, :default => true | 11 | t.column :active, :boolean, :default => true |