class DiaryEntriesController < ApplicationController
+ include UserMethods
+
layout "site", :except => :rss
before_action :authorize_web
elsif params[:friends]
if current_user
@title = t ".title_friends"
- entries = DiaryEntry.where(:user_id => current_user.friends)
+ entries = DiaryEntry.where(:user => current_user.friends)
else
require_user
return
elsif params[:nearby]
if current_user
@title = t ".title_nearby"
- entries = DiaryEntry.where(:user_id => current_user.nearby)
+ entries = DiaryEntry.where(:user => current_user.nearby)
else
require_user
return
end
def show
- @entry = @user.diary_entries.visible.where(:id => params[:id]).first
+ entries = @user.diary_entries
+ entries = entries.visible unless can? :unhide, DiaryEntry
+ @entry = entries.where(:id => params[:id]).first
if @entry
@title = t ".title", :user => params[:display_name], :title => @entry.title
@comments = can?(:unhidecomment, DiaryEntry) ? @entry.comments : @entry.visible_comments
@lon = @diary_entry.longitude
@lat = @diary_entry.latitude
@zoom = 12
- elsif current_user.home_lat.nil? || current_user.home_lon.nil?
+ elsif !current_user.home_location?
@lon = params[:lon] || -0.1
@lat = params[:lat] || 51.5
@zoom = params[:zoom] || 4