Commit 3263ed31c0988874234135cf43309c4a65dc521e
1 parent
c48431c0
Exists in
master
and in
22 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 | 39 | @profile |
40 | 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 | 52 | def self.acts_as_environment_admin_controller |
43 | 53 | before_filter :load_admin_controller |
44 | 54 | end | ... | ... |
app/controllers/profile_admin/cms_controller.rb
1 | 1 | class CmsController < ComatoseAdminController |
2 | 2 | extend PermissionCheck |
3 | + | |
4 | + needs_profile | |
3 | 5 | |
4 | 6 | define_option :page_class, Article |
5 | 7 | |
6 | 8 | # not yet |
7 | 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 | 10 | end | ... | ... |
app/controllers/profile_admin/enterprise_editor_controller.rb
1 | 1 | class EnterpriseEditorController < ProfileAdminController |
2 | 2 | |
3 | - before_filter :logon, :check_enterprise | |
3 | + before_filter :login_required, :check_enterprise | |
4 | + | |
4 | 5 | protect [:edit, :update], :edit_profile, :profile |
5 | 6 | protect [:destroy], :destroy_profile, :profile |
6 | 7 | |
8 | + needs_profile | |
7 | 9 | |
8 | 10 | # Show details about an enterprise |
9 | 11 | def index |
... | ... | @@ -45,13 +47,6 @@ class EnterpriseEditorController < ProfileAdminController |
45 | 47 | |
46 | 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 | 50 | def check_enterprise |
56 | 51 | redirect_to '/' unless @profile.is_a?(Enterprise) |
57 | 52 | @enterprise = @profile | ... | ... |
app/controllers/profile_admin/membership_editor_controller.rb
1 | 1 | class MembershipEditorController < ProfileAdminController |
2 | - | |
3 | - before_filter :logon | |
4 | 2 | |
3 | + before_filter :login_required | |
4 | + | |
5 | + needs_profile | |
6 | + | |
5 | 7 | def index |
6 | 8 | @memberships = current_user.person.memberships |
7 | 9 | end |
... | ... | @@ -30,9 +32,4 @@ class MembershipEditorController < ProfileAdminController |
30 | 32 | @tagged_enterprises = Enterprise.search(params[:query]) |
31 | 33 | end |
32 | 34 | |
33 | - protected | |
34 | - | |
35 | - def logon | |
36 | - redirect_to :controller => :account unless logged_in? | |
37 | - end | |
38 | 35 | end | ... | ... |
app/controllers/profile_admin/profile_editor_controller.rb
1 | 1 | class ProfileEditorController < ProfileAdminController |
2 | 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 | 15 | # edits the profile info (posts back) |
5 | 16 | def edit |
6 | 17 | if request.post? | ... | ... |
app/controllers/public/content_viewer_controller.rb
app/models/profile.rb
app/views/profile_editor/index.rhtml
... | ... | @@ -4,7 +4,7 @@ |
4 | 4 | |
5 | 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 | 9 | <p> <%= link_to _('Menage content'), :controller => 'cms' %> </p> |
10 | 10 | ... | ... |
db/migrate/003_create_profiles.rb