summaryrefslogtreecommitdiffstats
path: root/app/models
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2007-03-17 15:18:50 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2007-03-17 15:18:50 +0000
commit10cf1ccc1abe1c6ffdf21259b54292f9068b569c (patch)
treed43c2fd622b2126f72672d177f482e4934106e3d /app/models
parent22b42dc90a86b16904224bf638054fffd062b53f (diff)
downloadredmine-10cf1ccc1abe1c6ffdf21259b54292f9068b569c.tar.gz
redmine-10cf1ccc1abe1c6ffdf21259b54292f9068b569c.zip
added rss/atom feeds at project levels for:
* news * new issues reported * details of issue changes issue cutom queries can be used as feeds git-svn-id: http://redmine.rubyforge.org/svn/trunk@339 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/models')
-rw-r--r--app/models/journal.rb4
-rw-r--r--app/models/token.rb2
-rw-r--r--app/models/user.rb10
3 files changed, 15 insertions, 1 deletions
diff --git a/app/models/journal.rb b/app/models/journal.rb
index 18a6ec083..f70a69863 100644
--- a/app/models/journal.rb
+++ b/app/models/journal.rb
@@ -17,6 +17,10 @@
class Journal < ActiveRecord::Base
belongs_to :journalized, :polymorphic => true
+ # added as a quick fix to allow eager loading of the polymorphic association
+ # since always associated to an issue, for now
+ belongs_to :issue, :foreign_key => :journalized_id
+
belongs_to :user
has_many :details, :class_name => "JournalDetail", :dependent => :delete_all
end
diff --git a/app/models/token.rb b/app/models/token.rb
index 98745d29e..0e8c2c3e2 100644
--- a/app/models/token.rb
+++ b/app/models/token.rb
@@ -31,7 +31,7 @@ class Token < ActiveRecord::Base
# Delete all expired tokens
def self.destroy_expired
- Token.delete_all ["created_on < ?", Time.now - @@validity_time]
+ Token.delete_all ["action <> 'feeds' AND created_on < ?", Time.now - @@validity_time]
end
private
diff --git a/app/models/user.rb b/app/models/user.rb
index 3a315239c..869be920e 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -22,6 +22,7 @@ class User < ActiveRecord::Base
has_many :projects, :through => :memberships
has_many :custom_values, :dependent => :delete_all, :as => :customized
has_one :preference, :dependent => :destroy, :class_name => 'UserPreference'
+ has_one :rss_key, :dependent => :destroy, :class_name => 'Token', :conditions => "action='feeds'"
belongs_to :auth_source
attr_accessor :password, :password_confirmation
@@ -133,6 +134,15 @@ class User < ActiveRecord::Base
def pref
self.preference ||= UserPreference.new(:user => self)
end
+
+ def get_or_create_rss_key
+ self.rss_key || Token.create(:user => self, :action => 'feeds')
+ end
+
+ def self.find_by_rss_key(key)
+ token = Token.find_by_value(key)
+ token && token.user.active? ? token.user : nil
+ end
private
# Return password digest