Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use seperate is_public scope in queries. Minor association name typo fix

  • Loading branch information...
commit 52df9cbd21dadef8184c7bf332da71a9501edaf7 1 parent 29f4918
@jamesu authored
Showing with 103 additions and 164 deletions.
  1. +0 −2  app/controllers/categories_controller.rb
  2. +1 −1  app/controllers/comments_controller.rb
  3. +1 −3 app/controllers/dashboard_controller.rb
  4. +4 −3 app/controllers/feed_controller.rb
  5. +4 −2 app/controllers/files_controller.rb
  6. +2 −1  app/controllers/folders_controller.rb
  7. +0 −2  app/controllers/messages_controller.rb
  8. +10 −5 app/controllers/milestones_controller.rb
  9. +8 −7 app/controllers/projects_controller.rb
  10. +8 −8 app/controllers/task_lists_controller.rb
  11. +4 −5 app/controllers/tasks_controller.rb
  12. +8 −4 app/controllers/times_controller.rb
  13. +1 −1  app/models/activity.rb
  14. +2 −12 app/models/comment.rb
  15. +2 −12 app/models/message.rb
  16. +10 −20 app/models/milestone.rb
  17. +2 −2 app/models/project.rb
  18. +5 −15 app/models/project_file.rb
  19. +2 −2 app/models/project_file_revision.rb
  20. +0 −10 app/models/tag.rb
  21. +5 −5 app/models/task.rb
  22. +9 −19 app/models/task_list.rb
  23. +3 −13 app/models/time_record.rb
  24. +1 −1  app/views/files/show.html.erb
  25. +3 −1 app/views/messages/_show_list.html.erb
  26. +3 −3 app/views/messages/show.html.erb
  27. +2 −2 app/views/milestones/_show.html.erb
  28. +1 −1  app/views/tasks/show.html.erb
  29. +2 −2 db/migrate_basecamp.rb
View
2  app/controllers/categories_controller.rb
@@ -165,8 +165,6 @@ def posts
authorize! :show, @category
- include_private = @logged_user.member_of_owner?
-
# conditions
msg_conditions = {}
msg_conditions['is_private'] = false unless @logged_user.member_of_owner?
View
2  app/controllers/comments_controller.rb
@@ -42,7 +42,7 @@ def index
# Check permissions
authorize! :show, @commented_object
- @comments = @logged_user.member_of_owner? ? @commented_object.comments : @commented_object.comments.public
+ @comments = @logged_user.member_of_owner? ? @commented_object.comments : @commented_object.comments.is_public
respond_to do |format|
format.html {}
View
4 app/controllers/dashboard_controller.rb
@@ -24,11 +24,9 @@ class DashboardController < ApplicationController
def index
when_fragment_expired "user#{@logged_user.id}_dblog", Time.now.utc + (60 * Rails.configuration.minutes_to_activity_log_expire) do
if @active_projects.length > 0
- include_private = @logged_user.member_of_owner?
-
project_ids = @active_projects.collect{ |project| project.id }
- activity_conditions = include_private ?
+ activity_conditions = @logged_user.member_of_owner? ?
{ :project_id => project_ids } :
{ :project_id => project_ids, :is_private => false }
View
7 app/controllers/feed_controller.rb
@@ -148,8 +148,9 @@ def project_milestones
return
end
- @milestones = @project.milestones.open(@logged_user.member_of_owner?)
- @milestones_url = milestones_url(@project)
+ @milestones = @project.milestones.is_open
+ @milestones = @milestones.is_public unless @logged_user.member_of_owner?
+ @milestones_url = milestones_url(@project)
respond_to do |format|
format.html do
@@ -189,7 +190,7 @@ def export_times
return
end
- @times = @logged_user.member_of_owner? ? @project.time_records : @project.time_records.public
+ @times = @logged_user.member_of_owner? ? @project.time_records : @project.time_records.is_public
else
@times = TimeRecord.all_by_user(@logged_user).where('done_date IS NOT NULL')
end
View
6 app/controllers/files_controller.rb
@@ -55,7 +55,8 @@ def index
result_set.total_pages.times {|page| @pagination << page+1}
# Important files and folders (html only)
- @important_files = @active_project.project_files.important(@logged_user.member_of_owner?)
+ @important_files = @active_project.project_files.important
+ @important_files = @important_files.is_public unless @logged_user.member_of_owner?
@folders = @active_project.folders
}
format.xml {
@@ -103,7 +104,8 @@ def show
@folders = @active_project.folders
# Important files (html only)
- @important_files = @active_project.project_files.important(@logged_user.member_of_owner?)
+ @important_files = @active_project.project_files.important
+ @important_files = @important_files.is_public unless @logged_user.member_of_owner?
}
format.xml {
render :xml => @file.to_xml(:include => [:project_file_revisions])
View
3  app/controllers/folders_controller.rb
@@ -164,7 +164,8 @@ def files
result_set.total_pages.times {|page| @pagination << page+1}
# Important files and folders (html only)
- @important_files = @active_project.project_files.important(@logged_user.member_of_owner?)
+ @important_files = @active_project.project_files.important
+ @important_files = @important_files.is_public unless @logged_user.member_of_owner?
@folders = @active_project.folders
render :template => 'files/index'
View
2  app/controllers/messages_controller.rb
@@ -38,8 +38,6 @@ def index
authorize! :show, @category
end
- include_private = @logged_user.member_of_owner?
-
# conditions
msg_conditions = {}
msg_conditions['category_id'] = @category.id unless @category.nil?
View
15 app/controllers/milestones_controller.rb
@@ -28,15 +28,14 @@ class MilestonesController < ApplicationController
after_filter :user_track, :only => [:index, :show]
def index
- include_private = @logged_user.member_of_owner?
@content_for_sidebar = 'index_sidebar'
respond_to do |format|
format.html {
- index_lists(include_private, false)
+ index_lists(@logged_user.member_of_owner?, false)
}
format.xml {
- @milestones = include_private ? @active_project.milestones : @active_project.milestones.public
+ @milestones = @logged_user.member_of_owner? ? @active_project.milestones : @active_project.milestones.is_public
render :xml => @milestones.to_xml(:root => 'milestones')
}
end
@@ -163,9 +162,15 @@ def obtain_milestone
def index_lists(include_private, calendar_only)
@time_now = Time.zone.now
- @late_milestones = @active_project.milestones.late(include_private) unless calendar_only
+ unless calendar_only
+ @late_milestones = @active_project.milestones.late
+ @late_milestones = @late_milestones.is_public unless include_private
+ end
@upcoming_milestones = Milestone.all_assigned_to(@logged_user, nil, @time_now.utc.to_date, nil, [@active_project])
- @completed_milestones = @active_project.milestones.completed(include_private) unless calendar_only
+ unless calendar_only
+ @completed_milestones = @active_project.milestones.completed
+ @completed_milestones = @completed_milestones.is_public unless include_private
+ end
end_date = (@time_now + 14.days).to_date
@calendar_milestones = @upcoming_milestones.select{|m| m.due_date < end_date}.group_by do |obj|
View
15 app/controllers/projects_controller.rb
@@ -37,16 +37,15 @@ def index
end
def show
- include_private = @logged_user.member_of_owner?
-
respond_to do |format|
format.html {
when_fragment_expired "user#{@logged_user.id}_#{@project.id}_dblog", Time.now.utc + (60 * Rails.configuration.minutes_to_activity_log_expire) do
- @project_log_entries = (@logged_user.member_of_owner? ? @project.activities : @project.activities.public)[0..(Rails.configuration.project_logs_per_page-1)]
+ @project_log_entries = (@logged_user.member_of_owner? ? @project.activities : @project.activities.is_public)[0..(Rails.configuration.project_logs_per_page-1)]
end
@time_now = Time.zone.now
- @late_milestones = @project.milestones.late(include_private)
+ @late_milestones = @project.milestones.late
+ @late_milstones = @late_milestones.is_public unless @logged_user.member_of_owner?
@upcoming_milestones = Milestone.all_assigned_to(@logged_user, nil, @time_now.utc.to_date, (@time_now.utc + 14.days).to_date, [@project])
@calendar_milestones = @upcoming_milestones.group_by do |obj|
@@ -54,9 +53,11 @@ def show
"#{date.month}-#{date.day}"
end
- @project_companies = @project.companies(include_private)
- @important_messages = @project.messages.important(include_private)
- @important_files = @project.project_files.important(include_private)
+ @project_companies = @project.companies
+ @important_messages = @project.messages.important
+ @important_messages = @important_messages.is_public unless @logged_user.member_of_owner?
+ @important_files = @project.project_files.important
+ @important_files = @important_files.is_public unless @logged_user.member_of_owner?
@content_for_sidebar = 'overview_sidebar'
}
View
16 app/controllers/task_lists_controller.rb
@@ -55,12 +55,10 @@ def show
end
authorize! :show, @task_list
-
- include_private = @logged_user.member_of_owner?
respond_to do |format|
format.html {
- index_lists(include_private)
+ index_lists(@logged_user.member_of_owner?)
}
format.xml { render :xml => @task_list.to_xml(:root => 'task-list') }
@@ -75,8 +73,8 @@ def new
@task_list = @active_project.task_lists.build()
begin
- @task_list.project_milestone = @active_project.milestones.find(params[:milestone_id])
- @task_list.is_private = @task_list.project_milestone.is_private
+ @task_list.milestone = @active_project.milestones.find(params[:milestone_id])
+ @task_list.is_private = @task_list.milestone.is_private
rescue ActiveRecord::RecordNotFound
@task_list.milestone_id = 0
end
@@ -190,7 +188,7 @@ def reorder
authorize! :edit, @task_list
- order = params[:tasks].collect { |id| id.to_i }
+ order = (params[:tasks]||[]).collect { |id| id.to_i }
@task_list.tasks.each do |item|
idx = order.index(item.id)
@@ -208,8 +206,10 @@ def reorder
protected
def index_lists(include_private)
- @open_task_lists = @active_project.task_lists.open(include_private)
- @completed_task_lists = @active_project.task_lists.completed(include_private)
+ @open_task_lists = @active_project.task_lists.is_open
+ @open_task_lists = @open_task_lists.is_public unless include_private
+ @completed_task_lists = @active_project.task_lists.completed
+ @completed_task_lists = @completed_task_lists.is_public unless include_private
@content_for_sidebar = 'index_sidebar'
end
View
9 app/controllers/tasks_controller.rb
@@ -28,12 +28,12 @@ class TasksController < ApplicationController
# GET /tasks
# GET /tasks.xml
def index
- include_private = @logged_user.member_of_owner?
-
respond_to do |format|
format.html {
- @open_task_lists = @active_project.task_lists.open(include_private)
- @completed_task_lists = @active_project.task_lists.completed(include_private)
+ @open_task_lists = @active_project.task_lists.is_open
+ @open_task_lists = @open_task_lists.is_public unless @logged_user.member_of_owner?
+ @completed_task_lists = @active_project.task_lists.completed
+ @completed_task_lists = @completed_task_lists.is_public unless @logged_user.member_of_owner?
@content_for_sidebar = 'task_lists/index_sidebar'
}
format.xml {
@@ -150,7 +150,6 @@ def destroy
respond_to do |format|
format.html { redirect_back_or_default(task_lists_url) }
- format.js
format.xml { head :ok }
end
end
View
12 app/controllers/times_controller.rb
@@ -73,7 +73,8 @@ def new
authorize! :create_time, @active_project
@time = @active_project.time_records.build
- @open_task_lists = @active_project.task_lists.open(@logged_user.member_of_owner?)
+ @open_task_lists = @active_project.task_lists.is_open
+ @open_task_lists = @open_task_lists.is_public unless @logged_user.member_of_owner?
@task_filter = Proc.new {|task| task.is_completed? }
end
@@ -97,7 +98,8 @@ def create
format.xml { render :xml => @time.to_xml(:root => 'time'), :status => :created, :location => @time }
else
- @open_task_lists = @active_project.task_lists.open(@logged_user.member_of_owner?)
+ @open_task_lists = @active_project.task_lists.is_open
+ @open_task_lists = @open_task_lists.is_public unless @logged_user.member_of_owner?
@task_filter = Proc.new {|task| task.is_completed? }
format.html { render :action => "new" }
@@ -109,7 +111,8 @@ def create
def edit
authorize! :edit, @time
- @open_task_lists = @active_project.task_lists.open(@logged_user.member_of_owner?)
+ @open_task_lists = @active_project.task_lists.is_open
+ @open_task_lists = @open_task_lists.is_public unless @logged_user.member_of_owner?
@open_task_lists << @time.task_list unless @time.task_list.nil? || @open_task_lists.include?(@time.task_list)
@task_filter = Proc.new {|task| task.is_completed? && task != @time.task}
end
@@ -129,7 +132,8 @@ def update
format.xml { head :ok }
else
- @open_task_lists = @active_project.task_lists.open(@logged_user.member_of_owner?)
+ @open_task_lists = @active_project.task_lists.is_open
+ @open_task_lists = @open_task_lists.is_public unless @logged_user.member_of_owner?
@open_task_lists << @time.task_list unless @time.task_list.nil? || @open_task_lists.include?(@time.task_list)
@task_filter = Proc.new {|task| task.is_completed? && task != @time.task}
format.html { render :action => "edit" }
View
2  app/models/activity.rb
@@ -22,7 +22,7 @@ class Activity < ActiveRecord::Base
belongs_to :created_by, :class_name => 'User', :foreign_key => 'created_by_id'
belongs_to :rel_object, :polymorphic => true
- scope :public, where(:is_private => false)
+ scope :is_public, where(:is_private => false)
before_create :process_params
View
14 app/models/comment.rb
@@ -31,7 +31,7 @@ class Comment < ActiveRecord::Base
before_update :process_update_params
before_destroy :process_destroy
- scope :public, where(:is_private => false)
+ scope :is_public, where(:is_private => false)
def process_params
self.is_anonymous = self.created_by.is_anonymous?
@@ -55,18 +55,8 @@ def process_destroy
def last_edited_by_owner?
return (self.created_by.member_of_owner? or (!self.updated_by.nil? and self.updated_by.member_of_owner?))
end
-
- def self.priv_scope(include_private)
- if include_private
- yield
- else
- with_scope :find => { :conditions => ['is_private = ?', false] } do
- yield
- end
- end
- end
- # Helpers
+ # Helpers
def object_name
self.text.excerpt(50)
View
14 app/models/message.rb
@@ -35,9 +35,9 @@ class Message < ActiveRecord::Base
has_and_belongs_to_many :subscribers, :class_name => 'User', :join_table => 'message_subscriptions', :foreign_key => 'message_id'
- scope :public, where(:is_private => false)
+ scope :is_public, where(:is_private => false)
- scope :important, lambda { |include_private| Message.priv_scope(include_private) { where(:is_important => true) } }
+ scope :important, where(:is_important => true)
before_validation :process_params, :on => :create
after_create :process_create
@@ -112,16 +112,6 @@ def send_notification(user)
Notifier.deliver_message(user, self)
end
- def self.priv_scope(include_private)
- if include_private
- yield
- else
- with_scope :find => { :conditions => ['is_private = ?', false] } do
- yield
- end
- end
- end
-
# Accesibility
attr_accessible :title, :text, :milestone_id, :category_id, :is_private, :is_important, :comments_enabled, :anonymous_comments_enabled
View
30 app/models/milestone.rb
@@ -37,12 +37,12 @@ class Milestone < ActiveRecord::Base
#has_many :tags, :as => 'rel_object', :dependent => :destroy
- scope :public, where(:is_private => false)
- scope :open, lambda { |include_private| Milestone.priv_scope(include_private) { where('milestones.completed_on IS NULL', :order => 'milestones.due_date ASC') } }
- scope :late, lambda { |include_private| Milestone.priv_scope(include_private) { where(['due_date < ? AND completed_on IS NULL', Date.today]) } }
- scope :todays, lambda { |include_private| Milestone.priv_scope(include_private) { where(['completed_on IS NULL AND (due_date >= ? AND due_date < ?)', Date.today, Date.today+1]) } }
- scope :upcoming, lambda { |include_private| Milestone.priv_scope(include_private) { where(['completed_on IS NULL AND due_date >= ?', Date.today+1]) } }
- scope :completed, lambda { |include_private| Milestone.priv_scope(include_private) { where('completed_on IS NOT NULL') } }
+ scope :is_public, where(:is_private => false)
+ scope :is_open, where('milestones.completed_on IS NULL').order('milestones.due_date ASC')
+ scope :late, where(['due_date < ? AND completed_on IS NULL', Date.today])
+ scope :todays, where(['completed_on IS NULL AND (due_date >= ? AND due_date < ?)', Date.today, Date.today+1])
+ scope :upcoming, where(['completed_on IS NULL AND due_date >= ?', Date.today+1])
+ scope :completed, where('completed_on IS NOT NULL')
before_validation :process_params, :on => :create
after_create :process_create
@@ -61,7 +61,7 @@ def process_params
end
def process_create
- Activity::new_log(self, self.created_by, :add, self.is_private)
+ Activity.new_log(self, self.created_by, :add, self.is_private)
end
def process_update_params
@@ -73,17 +73,17 @@ def process_update_params
end
if @update_completed.nil?
- Activity::new_log(self, self.updated_by, :edit, self.is_private)
+ Activity.new_log(self, self.updated_by, :edit, self.is_private)
else
write_attribute('completed_on', @update_completed ? Time.now.utc : nil)
self.completed_by = @update_completed_user
- Activity::new_log(self, @update_completed_user, @update_completed ? :close : :open, self.is_private)
+ Activity.new_log(self, @update_completed_user, @update_completed ? :close : :open, self.is_private)
end
end
def process_destroy
Tag.clear_by_object(self)
- Activity::new_log(self, self.updated_by, :delete, self.is_private)
+ Activity.new_log(self, self.updated_by, :delete, self.is_private)
end
def object_name
@@ -176,16 +176,6 @@ def set_completed(value, user=nil)
@update_completed_user = user
end
- def self.priv_scope(include_private)
- if include_private
- yield
- else
- with_scope :find => { :conditions => ['is_private = ?', false] } do
- yield
- end
- end
- end
-
# Helpers
def self.all_by_user(user)
View
4 app/models/project.rb
@@ -63,11 +63,11 @@ def process_create
def process_update_params
if @update_completed.nil?
- Activity::new_log(self, self.updated_by, :edit, true)
+ Activity.new_log(self, self.updated_by, :edit, true)
else
write_attribute("completed_on", @update_completed ? Time.now.utc : nil)
self.completed_by = @update_completed_user
- Activity::new_log(self, @update_completed_user, @update_completed ? :close : :open, true)
+ Activity.new_log(self, @update_completed_user, @update_completed ? :close : :open, true)
end
end
View
20 app/models/project_file.rb
@@ -31,7 +31,7 @@ class ProjectFile < ActiveRecord::Base
has_many :comments, :as => 'rel_object', :dependent => :destroy
#has_many :tags, :as => 'rel_object', :dependent => :destroy
- scope :important, lambda { |include_private| ProjectFile.priv_scope(include_private) { where(:is_important => true) } }
+ scope :important, where(:is_important => true)
before_validation :process_params, :on => :create
after_create :process_create
@@ -43,17 +43,17 @@ def process_params
end
def process_create
- Activity::new_log(self, self.created_by, :add)
+ Activity.new_log(self, self.created_by, :add)
end
def process_update_params
- Activity::new_log(self, self.updated_by, :edit)
+ Activity.new_log(self, self.updated_by, :edit)
end
def process_destroy
AttachedFile.clear_files(self.id)
Tag.clear_by_object(self)
- Activity::new_log(self, self.updated_by, :delete)
+ Activity.new_log(self, self.updated_by, :delete)
end
def tags
@@ -109,16 +109,6 @@ def last_edited_by_owner?
def send_comment_notifications(comment)
end
- def self.priv_scope(include_private)
- if include_private
- yield
- else
- with_scope :find => { :conditions => ['is_private = ?', false] } do
- yield
- end
- end
- end
-
def add_revision(file, new_revision, user, comment)
file_revision = ProjectFileRevision.new(:revision_number => new_revision)
file_revision.project_file = self
@@ -127,7 +117,7 @@ def add_revision(file, new_revision, user, comment)
file_revision.comment = comment
file_revision.save!
- Activity::new_log(file_revision, user, :add, self.is_private, self.project) unless new_revision == 1
+ Activity.new_log(file_revision, user, :add, self.is_private, self.project) unless new_revision == 1
end
def update_revision(file, old_revision, user, comment)
View
4 app/models/project_file_revision.rb
@@ -54,11 +54,11 @@ def process_params
end
def process_update_params
- Activity::new_log(self, self.updated_by, :edit, self.project_file.is_private, self.project_file.project)
+ Activity.new_log(self, self.updated_by, :edit, self.project_file.is_private, self.project_file.project)
end
def process_destroy
- Activity::new_log(self, self.updated_by, :delete, self.project_file.is_private, self.project_file.project)
+ Activity.new_log(self, self.updated_by, :delete, self.project_file.is_private, self.project_file.project)
end
def project_id
View
10 app/models/tag.rb
@@ -42,16 +42,6 @@ def object_url(host = nil)
url_for :only_path => host.nil?, :host => host, :controller => 'projects', :action => 'tags', :id => self.tag, :active_project => self.project_id
end
- def self.priv_scope(include_private)
- if include_private
- yield
- else
- with_scope :find => { :conditions => ['is_private = ?', false] } do
- yield
- end
- end
- end
-
def self.find_objects(tag_name, project, is_public)
tag_conditions = is_public ?
['project_id = ? AND tag = ? AND is_private = ?', project.id, tag_name, false] :
View
10 app/models/task.rb
@@ -49,13 +49,13 @@ def process_params
def process_create
self.task_list.ensure_completed(self.created_by)
self.task_list.save!
- ApplicationLog.new_log(self, self.created_by, :add, self.task_list.is_private, self.task_list.project)
+ Activity.new_log(self, self.created_by, :add, self.task_list.is_private, self.task_list.project)
end
def process_update_params
if @update_completed.nil?
if @update_is_minor.nil?
- ApplicationLog.new_log(self, self.updated_by, :edit, self.task_list.is_private, self.task_list.project)
+ Activity.new_log(self, self.updated_by, :edit, self.task_list.is_private, self.task_list.project)
end
else
write_attribute('completed_on', @update_completed ? Time.now.utc : nil)
@@ -63,13 +63,13 @@ def process_update_params
# If closed, we log before the task list
if @update_completed
- ApplicationLog::new_log(self, @update_completed_user, :close, self.task_list.is_private, self.task_list.project)
+ Activity.new_log(self, @update_completed_user, :close, self.task_list.is_private, self.task_list.project)
end
end
end
def process_destroy
- ApplicationLog.new_log(self, self.updated_by, :delete, true, self.task_list.project)
+ Activity.new_log(self, self.updated_by, :delete, true, self.task_list.project)
@update_completed = true
@update_completed_user = self.updated_by
end
@@ -83,7 +83,7 @@ def update_task_list
# If opened, we log after the task list
if !@update_completed
- ApplicationLog::new_log(self, @update_completed_user, :open, self.task_list.is_private, self.task_list.project)
+ Activity.new_log(self, @update_completed_user, :open, self.task_list.is_private, self.task_list.project)
end
end
View
28 app/models/task_list.rb
@@ -30,9 +30,9 @@ class TaskList < ActiveRecord::Base
#has_many :tags, :as => 'rel_object', :dependent => :destroy
- scope :public, where(:is_private => false)
- scope :open, lambda { |include_private| TaskList.priv_scope(include_private) { where('task_lists.completed_on IS NULL') } }
- scope :completed, lambda { |include_private| TaskList.priv_scope(include_private) { where('task_lists.completed_on IS NOT NULL') } }
+ scope :is_public, where(:is_private => false)
+ scope :is_open, where('task_lists.completed_on IS NULL')
+ scope :completed, where('task_lists.completed_on IS NOT NULL')
before_validation :process_params, :on => :create
after_create :process_create
@@ -53,19 +53,19 @@ def process_params
end
def process_create
- ApplicationLog.new_log(self, self.created_by, :add, self.is_private)
+ Activity.new_log(self, self.created_by, :add, self.is_private)
update_tags
end
def process_update_params
return unless @ensured_complete.nil?
- ApplicationLog.new_log(self, self.updated_by, :edit, self.is_private)
+ Activity.new_log(self, self.updated_by, :edit, self.is_private)
end
def process_destroy
Tag.clear_by_object(self)
- ApplicationLog.new_log(self, self.updated_by, :delete, self.is_private)
+ Activity.new_log(self, self.updated_by, :delete, self.is_private)
end
def ensure_completed(completed_by)
@@ -78,12 +78,12 @@ def ensure_completed(completed_by)
if self.completed_on.nil?
write_attribute('completed_on', Time.now.utc)
self.completed_by = completed_by
- ApplicationLog::new_log(self, completed_by, :close, self.is_private)
+ Activity.new_log(self, completed_by, :close, self.is_private)
end
else
unless self.completed_on.nil?
write_attribute('completed_on', nil)
- ApplicationLog::new_log(self, completed_by, :open, self.is_private)
+ Activity.new_log(self, completed_by, :open, self.is_private)
end
end
end
@@ -141,16 +141,6 @@ def finished_all_tasks?
completed_count > 0 and completed_count == self.tasks.length
end
- def self.priv_scope(include_private)
- if include_private
- yield
- else
- with_scope :find => { :conditions => ['is_private = ?', false] } do
- yield
- end
- end
- end
-
def self.select_list(project)
TaskList.where(:project_id => project.id).select('id, name').collect do |tasklist|
[tasklist.name, tasklist.id]
@@ -181,7 +171,7 @@ def to_xml(options = {}, &block)
# Validation
validates_presence_of :name
- validates_each :project_milestone, :allow_nil => true do |record, attr, value|
+ validates_each :milestone, :allow_nil => true do |record, attr, value|
record.errors.add(attr, I18n.t('not_part_of_project')) if value.project_id != record.project_id
end
View
16 app/models/time_record.rb
@@ -36,7 +36,7 @@ class TimeRecord < ActiveRecord::Base
#has_many :tags, :as => 'rel_object', :dependent => :destroy
scope :running, where('start_date IS NOT NULL AND done_date IS NULL')
- scope :public, where(:is_private => false)
+ scope :is_public, where(:is_private => false)
before_validation :process_params, :on => :create
after_create :process_create
@@ -70,7 +70,7 @@ def process_params
end
def process_create
- Activity::new_log(self, self.created_by, :add, self.is_private)
+ Activity.new_log(self, self.created_by, :add, self.is_private)
end
def process_update_params
@@ -81,7 +81,7 @@ def process_update_params
write_attribute("assigned_to_company_id", 0)
end
- Activity::new_log(self, self.updated_by, :edit, self.is_private)
+ Activity.new_log(self, self.updated_by, :edit, self.is_private)
end
def process_destroy
@@ -194,16 +194,6 @@ def last_edited_by_owner?
return (self.created_by.member_of_owner? or (!self.updated_by.nil? and self.updated_by.member_of_owner?))
end
- def self.priv_scope(include_private)
- if include_private
- yield
- else
- with_scope :find => { :conditions => ['is_private = ?', false] } do
- yield
- end
- end
- end
-
def self.find_by_task_lists(task_lists, time_conds)
lists = []
View
2  app/views/files/show.html.erb
@@ -70,7 +70,7 @@
<!-- Comments -->
<div id="fileComments">
-<%= render :partial => 'comments/object_comments', :locals => {:comments => @logged_user.member_of_owner? ? @file.comments : @file.comments.public} %>
+<%= render :partial => 'comments/object_comments', :locals => {:comments => @logged_user.member_of_owner? ? @file.comments : @file.comments.is_public} %>
<% if can? :comment, @file %>
<%= render :partial => 'comments/add_form', :locals => {:commented_object => @file} %>
View
4 app/views/messages/_show_list.html.erb
@@ -13,7 +13,9 @@
<span><%= t('tags') %>:</span> <%= tag_list message %>
</div>
- <% fc = message.attached_files(@logged_user.member_of_owner?).length %>
+ <% fc = message.attached_files
+ fc = fc.is_public unless @logged_user.member_of_owner?
+ fc = fc.length %>
<% if fc > 0 %>
<div class="objectFilesTitle">
<span><%= t('attached_files') %>:</span> <%= fc %>
View
6 app/views/messages/show.html.erb
@@ -5,8 +5,8 @@
<div class="messageAuthor"><span><%= t('from') %>:</span> <%= link_to( h(@message.created_by.display_name), user_path(:id => @message.created_by.id)) %></div>
<% end %>
<div class="messageDate"><span><%= t('log_date') %>:</span> <%= format_usertime(@message.created_on, :message_created_format) %></div>
-<% unless @message.project_milestone.nil? %>
- <div class="messageMilestone"><span><%= t('milestone') %>:</span> <%= link_to h(@message.project_milestone.object_name), @message.project_milestone.object_url %></div>
+<% unless @message.milestone.nil? %>
+ <div class="messageMilestone"><span><%= t('milestone') %>:</span> <%= link_to h(@message.milestone.object_name), @message.milestone.object_url %></div>
<% end %>
<div class="messageTags"><span><%= t('tags') %>:</span> <%= @message.tags %></div>
</div>
@@ -20,7 +20,7 @@
<!-- Comments -->
<div id="messageComments">
-<%= render :partial => 'comments/object_comments', :locals => {:comments => @logged_user.member_of_owner? ? @message.comments : @message.comments.public} %>
+<%= render :partial => 'comments/object_comments', :locals => {:comments => @logged_user.member_of_owner? ? @message.comments : @message.comments.is_public} %>
<% if can? :comment, @message %>
<%= render :partial => 'comments/add_form', :locals => {:commented_object => @message} %>
View
4 app/views/milestones/_show.html.erb
@@ -55,7 +55,7 @@
<% if milestone.messages.length > 0 %>
<p><%= t('messages') %>:</p>
<ul>
-<% (@logged_user.member_of_owner? ? milestone.messages : milestone.messages.public).each do |message| -%>
+<% (@logged_user.member_of_owner? ? milestone.messages : milestone.messages.is_public).each do |message| -%>
<li><%= link_to (h message.title), message_path(:id => message.id) %>
<% if not message.created_by.nil? %>
<span class="desc">(<%= t('milestone_messages_created_with_user',
@@ -70,7 +70,7 @@
<% if milestone.task_lists.length > 0 %>
<p><%= t('task_lists') %>:</p>
<ul>
-<% (@logged_user.member_of_owner? ? milestone.task_lists : milestone.task_lists.public).each do |task_list| -%>
+<% (@logged_user.member_of_owner? ? milestone.task_lists : milestone.task_lists.is_public).each do |task_list| -%>
<% if task_list.is_completed? %>
<li><del datetime="<%= task_list.completed_on.iso8601 %>"><%= link_to (h task_list.name), task_list_path(:id => task_list.id) %></del></li>
<% else %>
View
2  app/views/tasks/show.html.erb
@@ -29,7 +29,7 @@
<!-- Comments -->
<div id="taskComments">
-<%= render :partial => 'comments/object_comments', :locals => {:comments => @logged_user.member_of_owner? ? @task.comments : @task.comments.public} %>
+<%= render :partial => 'comments/object_comments', :locals => {:comments => @logged_user.member_of_owner? ? @task.comments : @task.comments.is_public} %>
<% if can? :comment, @task %>
<%= render :partial => 'comments/add_form', :locals => {:commented_object => @task} %>
View
4 db/migrate_basecamp.rb
@@ -173,7 +173,7 @@ def import_company(firm_attribs, owner=nil)
puts " Adding folder '#{folder.name}'"
folder.save!
MAP_IDS[:folders][attach_category.elements['id'].text.to_i] = folder.id
- Activity::new_log(folder, MAP_IDS[:owner], :add)
+ Activity.new_log(folder, MAP_IDS[:owner], :add)
end
# Message categories...
@@ -184,7 +184,7 @@ def import_company(firm_attribs, owner=nil)
puts " Adding category '#{category.name}'"
category.save!
MAP_IDS[:categories][post_category.elements['id'].text.to_i] = category.id
- Activity::new_log(category, MAP_IDS[:owner], :add)
+ Activity.new_log(category, MAP_IDS[:owner], :add)
end
# Milestones...
Please sign in to comment.
Something went wrong with that request. Please try again.