Activity enhancements:
* overall activity view and feed added, link is available on the project list (#423, #494) * switch added on the project activity view to include subprojects (closes #530) git-svn-id: http://redmine.rubyforge.org/svn/trunk@1227 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
@@ -26,7 +26,6 @@ class Attachment < ActiveRecord::Base
|
||||
validates_length_of :disk_filename, :maximum => 255
|
||||
|
||||
acts_as_event :title => :filename,
|
||||
:description => :filename,
|
||||
:url => Proc.new {|o| {:controller => 'attachments', :action => 'download', :id => o.id}}
|
||||
|
||||
cattr_accessor :storage_path
|
||||
|
||||
@@ -45,6 +45,10 @@ class Changeset < ActiveRecord::Base
|
||||
super
|
||||
end
|
||||
|
||||
def project
|
||||
repository.project
|
||||
end
|
||||
|
||||
def after_create
|
||||
scan_comment_for_issue_ids
|
||||
end
|
||||
|
||||
+13
-14
@@ -84,16 +84,6 @@ class Project < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
# Return all issues status changes for the project between the 2 given dates
|
||||
def issues_status_changes(from, to)
|
||||
Journal.find(:all, :include => [:issue, :details, :user],
|
||||
:conditions => ["#{Journal.table_name}.journalized_type = 'Issue'" +
|
||||
" AND #{Issue.table_name}.project_id = ?" +
|
||||
" AND #{JournalDetail.table_name}.prop_key = 'status_id'" +
|
||||
" AND #{Journal.table_name}.created_on BETWEEN ? AND ?",
|
||||
id, from, to+1])
|
||||
end
|
||||
|
||||
# returns latest created projects
|
||||
# non public projects will be returned only if user is a member of those
|
||||
def self.latest(user=nil, count=5)
|
||||
@@ -110,19 +100,28 @@ class Project < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def self.allowed_to_condition(user, permission)
|
||||
def self.allowed_to_condition(user, permission, options={})
|
||||
statements = []
|
||||
active_statement = "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"
|
||||
base_statement = "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}"
|
||||
if options[:project]
|
||||
project_statement = "#{Project.table_name}.id = #{options[:project].id}"
|
||||
project_statement << " OR #{Project.table_name}.parent_id = #{options[:project].id}" if options[:with_subprojects]
|
||||
base_statement = "(#{project_statement}) AND (#{base_statement})"
|
||||
end
|
||||
if user.admin?
|
||||
# no restriction
|
||||
elsif user.logged?
|
||||
statements << "#{Project.table_name}.is_public = #{connection.quoted_true}" if Role.non_member.allowed_to?(permission)
|
||||
allowed_project_ids = user.memberships.select {|m| m.role.allowed_to?(permission)}.collect {|m| m.project_id}
|
||||
statements << "#{Project.table_name}.id IN (#{allowed_project_ids.join(',')})" if allowed_project_ids.any?
|
||||
elsif Role.anonymous.allowed_to?(permission)
|
||||
# anonymous user allowed on public project
|
||||
statements << "#{Project.table_name}.is_public = #{connection.quoted_true}"
|
||||
else
|
||||
statements << "#{Project.table_name}.is_public = #{connection.quoted_true}" if Role.anonymous.allowed_to?(permission)
|
||||
# anonymous user is not authorized
|
||||
statements << "1=0"
|
||||
end
|
||||
statements.empty? ? active_statement : "(#{active_statement} AND (#{statements.join(' OR ')}))"
|
||||
statements.empty? ? base_statement : "((#{base_statement}) AND (#{statements.join(' OR ')}))"
|
||||
end
|
||||
|
||||
def self.find(*args)
|
||||
|
||||
@@ -61,6 +61,10 @@ class WikiContent < ActiveRecord::Base
|
||||
end
|
||||
end
|
||||
|
||||
def project
|
||||
page.project
|
||||
end
|
||||
|
||||
# Returns the previous version or nil
|
||||
def previous
|
||||
@previous ||= WikiContent::Version.find(:first,
|
||||
|
||||
Reference in New Issue
Block a user