Skip to content

Commit

Permalink
Fix bug in project serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
bwalex committed Apr 14, 2012
1 parent 148685f commit de72dc9
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions db.rb
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ class Document < ActiveRecord::Base

class Project < ActiveRecord::Base
attr_accessor :new_owner
attr_accessor :current_user

belongs_to :owner, :class_name => "User",
:foreign_key => "owner_id"#,
Expand Down Expand Up @@ -332,8 +333,8 @@ def event_stats
filters = ["extres"]

if defined? @current_user and not @current_user.nil?
s = @current_user.user_project_settings.where(:project_id => @project.id, :key => 'timeline:events')
filters = filters | s[0].value.split(',')
s = @current_user.user_project_settings.where(:project_id => self[:id], :key => 'timeline:events')
filters = filters | s[0].value.split(',') unless s.empty?
end

return {
Expand All @@ -342,7 +343,7 @@ def event_stats
end

def as_json(options={})
@current_user = options.user if defined? options.user
@current_user = options[:user] if defined? options[:user]
super(
:include => { :project_users => {}, :owner => { :only => [:id, :alias] } },
:methods => [ :path, :task_stats, :note_stats, :wiki_stats, :user_stats, :event_stats ]
Expand Down

0 comments on commit de72dc9

Please sign in to comment.