DG MS; 404 show pages for objects that don't exist for given user
This commit is contained in:
parent
c630d3db6f
commit
9162a4a168
7 changed files with 41 additions and 29 deletions
|
|
@ -37,9 +37,13 @@ class AlbumsController < ApplicationController
|
||||||
def show
|
def show
|
||||||
@photo = Photo.new
|
@photo = Photo.new
|
||||||
@album = current_user.find_visible_post_by_id( params[:id] )
|
@album = current_user.find_visible_post_by_id( params[:id] )
|
||||||
|
unless @album
|
||||||
|
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
|
||||||
|
else
|
||||||
@album_photos = @album.photos
|
@album_photos = @album.photos
|
||||||
respond_with @album
|
respond_with @album
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@album = current_user.find_visible_post_by_id params[:id]
|
@album = current_user.find_visible_post_by_id params[:id]
|
||||||
|
|
|
||||||
|
|
@ -42,10 +42,14 @@ class AspectsController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@aspect = current_user.aspect_by_id params[:id]
|
@aspect = current_user.aspect_by_id params[:id]
|
||||||
|
unless @aspect
|
||||||
|
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
|
||||||
|
else
|
||||||
@friends = @aspect.people
|
@friends = @aspect.people
|
||||||
@posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :per_page => 15, :order => 'created_at DESC'
|
@posts = current_user.visible_posts( :by_members_of => @aspect ).paginate :per_page => 15, :order => 'created_at DESC'
|
||||||
respond_with @aspect
|
respond_with @aspect
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def public
|
def public
|
||||||
# @fb_access_url = MiniFB.oauth_url(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create",
|
# @fb_access_url = MiniFB.oauth_url(FB_APP_ID, APP_CONFIG[:pod_url] + "services/create",
|
||||||
|
|
|
||||||
|
|
@ -17,19 +17,10 @@ class PeopleController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
begin
|
|
||||||
@person = current_user.visible_person_by_id(params[:id])
|
@person = current_user.visible_person_by_id(params[:id])
|
||||||
rescue BSON::InvalidObjectId
|
|
||||||
flash[:error] = "Person not found."
|
|
||||||
redirect_to people_path
|
|
||||||
return
|
|
||||||
end
|
|
||||||
unless @person
|
unless @person
|
||||||
flash[:error] = "Person not found."
|
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
|
||||||
redirect_to people_path
|
else
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
@profile = @person.profile
|
@profile = @person.profile
|
||||||
@aspects_with_person = current_user.aspects_with_person(@person)
|
@aspects_with_person = current_user.aspects_with_person(@person)
|
||||||
@aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]}
|
@aspects_dropdown_array = current_user.aspects.collect{|x| [x.to_s, x.id]}
|
||||||
|
|
@ -38,6 +29,7 @@ class PeopleController < ApplicationController
|
||||||
@post_count = @posts.count
|
@post_count = @posts.count
|
||||||
respond_with @person
|
respond_with @person
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
current_user.unfriend(current_user.visible_person_by_id(params[:id]))
|
current_user.unfriend(current_user.visible_person_by_id(params[:id]))
|
||||||
|
|
|
||||||
|
|
@ -76,9 +76,13 @@ class PhotosController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@photo = current_user.find_visible_post_by_id params[:id]
|
@photo = current_user.find_visible_post_by_id params[:id]
|
||||||
|
unless @photo
|
||||||
|
render :file => "#{Rails.root}/public/404.html", :layout => false, :status => 404
|
||||||
|
else
|
||||||
@album = @photo.album
|
@album = @photo.album
|
||||||
respond_with @photo, @album
|
respond_with @photo, @album
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@photo = current_user.find_visible_post_by_id params[:id]
|
@photo = current_user.find_visible_post_by_id params[:id]
|
||||||
|
|
|
||||||
|
|
@ -33,8 +33,12 @@ class StatusMessagesController < ApplicationController
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@status_message = current_user.find_visible_post_by_id params[:id]
|
@status_message = current_user.find_visible_post_by_id params[:id]
|
||||||
|
unless @status_message
|
||||||
|
render :status => 404
|
||||||
|
else
|
||||||
respond_with @status_message
|
respond_with @status_message
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def clean_hash(params)
|
def clean_hash(params)
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ module Diaspora
|
||||||
module Querying
|
module Querying
|
||||||
|
|
||||||
def find_visible_post_by_id( id )
|
def find_visible_post_by_id( id )
|
||||||
self.raw_visible_posts.find id
|
self.raw_visible_posts.find id.to_id
|
||||||
end
|
end
|
||||||
|
|
||||||
def visible_posts( opts = {} )
|
def visible_posts( opts = {} )
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,11 @@
|
||||||
|
|
||||||
class String
|
class String
|
||||||
def to_id
|
def to_id
|
||||||
|
begin
|
||||||
BSON::ObjectId self
|
BSON::ObjectId self
|
||||||
|
rescue
|
||||||
|
nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
class BSON::ObjectId
|
class BSON::ObjectId
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue