public
Fork of stevenbristol/lovd-by-less
Description: Open Source Social Network written in Ruby on Rail by Less Everything
Homepage: http://lovdbyless.com
Clone URL: git://github.com/ayb/lovd-by-less.git
Improve the :owner permissions for allow_to
Matthew Peychich (author)
Thu May 01 11:52:59 -0700 2008
commit  e279286807cb7b8691ca25bac323e5572e315e17
tree    6355e04fe288ece9a6694c0e4516e3369b835b20
parent  9ca0a5271fd97e9128fcaa6a10fdd514b1fa1674
...
70
71
72
73
 
74
75
76
...
70
71
72
 
73
74
75
76
0
@@ -70,7 +70,7 @@ class ApplicationController < ActionController::Base
0
       next unless (l[0] == :all) ||
0
         (l[0] == :non_user && !@u) ||
0
         (l[0] == :user && @u) ||
0
- (l[0] == :owner && @p && @p.id==(params[:profile_id] || params[:id]).to_i)
0
+ (l[0] == :owner && @p && @profile && @p == @profile)
0
       args = l[1]
0
       @level = [] and return true if args[:all] == true
0
       
...
1
2
 
3
4
5
...
70
71
72
73
 
74
 
 
 
75
76
77
...
1
2
3
4
5
6
...
71
72
73
 
74
75
76
77
78
79
80
81
0
@@ -1,5 +1,6 @@
0
 class BlogsController < ApplicationController
0
   skip_filter :login_required, :only => [:index, :show]
0
+ prepend_before_filter :get_profile
0
   before_filter :setup
0
   
0
   
0
@@ -70,8 +71,11 @@ class BlogsController < ApplicationController
0
 
0
   protected
0
   
0
- def setup
0
+ def get_profile
0
     @profile = Profile[params[:profile_id]]
0
+ end
0
+
0
+ def setup
0
     @user = @profile.user
0
     @blogs = @profile.blogs.paginate(:page => @page, :per_page => @per_page)
0
     
...
1
2
 
3
4
5
...
54
55
56
 
 
 
57
58
59
60
61
62
...
1
2
3
4
5
6
...
55
56
57
58
59
60
61
62
 
63
64
65
0
@@ -1,5 +1,6 @@
0
 class PhotosController < ApplicationController
0
   skip_filter :login_required
0
+ prepend_before_filter :get_profile
0
   before_filter :setup
0
   
0
   
0
@@ -54,9 +55,11 @@ class PhotosController < ApplicationController
0
     super :all, :only => [:index, :show]
0
   end
0
   
0
+ def get_profile
0
+ @profile = Profile[params[:profile_id] || params[:id]]
0
+ end
0
   
0
   def setup
0
- @profile = Profile[params[:profile_id] || params[:id]]
0
     @user = @profile.user
0
     @photos = @profile.photos.paginate(:all, :page => @page, :per_page => @per_page)
0
     @photo = Photo.new
...
1
2
3
 
4
5
6
...
106
107
108
109
 
110
 
 
 
111
112
113
...
1
2
 
3
4
5
6
...
106
107
108
 
109
110
111
112
113
114
115
116
0
@@ -1,6 +1,6 @@
0
 class ProfilesController < ApplicationController
0
   include ApplicationHelper
0
-
0
+ prepend_before_filter :get_profile, :except => [:new, :create, :index, :search]
0
   before_filter :setup, :except => [:index, :search]
0
   before_filter :search_results, :only => [:index, :search]
0
   skip_filter :login_required, :only=>[:show, :index, :feed, :search]
0
@@ -106,8 +106,11 @@ class ProfilesController < ApplicationController
0
     super :all, :only => [:show, :index, :search]
0
   end
0
   
0
- def setup
0
+ def get_profile
0
     @profile = Profile[params[:id]]
0
+ end
0
+
0
+ def setup
0
     @user = @profile.user
0
   end
0
   
...
54
55
56
57
58
59
60
...
54
55
56
 
57
58
59
0
@@ -54,7 +54,6 @@ class ProfilesControllerTest < ActionController::TestCase
0
     end
0
 
0
     should_not_assign_to :user
0
- should_not_assign_to :profile
0
     should_respond_with :redirect
0
     should_redirect_to 'login_path'
0
     should_not_set_the_flash

Comments

    No one has commented yet.