summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2008-03-11 19:33:38 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2008-03-11 19:33:38 +0000
commit624723d0cef9bd8a9528745f4b75ee22f6b1ad2e (patch)
treed622adeab661c9e833c260b5f5bdef076b14c034 /app/models
parent64fb0a561aebbc7583695deba29697f84c620dfb (diff)
downloadredmine-624723d0cef9bd8a9528745f4b75ee22f6b1ad2e.tar.gz
redmine-624723d0cef9bd8a9528745f4b75ee22f6b1ad2e.zip
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
Diffstat (limited to 'app/models')
-rw-r--r--app/models/attachment.rb1
-rw-r--r--app/models/changeset.rb4
-rw-r--r--app/models/project.rb27
-rw-r--r--app/models/wiki_content.rb4
4 files changed, 21 insertions, 15 deletions
diff --git a/app/models/attachment.rb b/app/models/attachment.rb
index c9783b9ce..cdcb8d231 100644
--- a/app/models/attachment.rb
+++ b/app/models/attachment.rb
@@ -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
diff --git a/app/models/changeset.rb b/app/models/changeset.rb
index 6bd15b158..dbe06935d 100644
--- a/app/models/changeset.rb
+++ b/app/models/changeset.rb
@@ -45,6 +45,10 @@ class Changeset < ActiveRecord::Base
super
end
+ def project
+ repository.project
+ end
+
def after_create
scan_comment_for_issue_ids
end
diff --git a/app/models/project.rb b/app/models/project.rb
index 95a201454..ad2f1fb81 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -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)
diff --git a/app/models/wiki_content.rb b/app/models/wiki_content.rb
index c307beb1d..13915c274 100644
--- a/app/models/wiki_content.rb
+++ b/app/models/wiki_content.rb
@@ -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,