Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Index: C:/dev/beast/app/models/user.rb
- ===================================================================
- --- C:/dev/beast/app/models/user.rb (revision 1866)
- +++ C:/dev/beast/app/models/user.rb (working copy)
- @@ -5,6 +5,13 @@
- has_many :forums, :through => :moderatorships, :order => 'forums.name'
- has_many :posts
- +
- + has_many :notifications
- + has_many :topic_notifications, :through => :notifications, :source => :topic,
- + :conditions => "notifications.discussion_type = 'Topic'"
- + has_many :forum_notifications, :through => :notifications, :source => :forum,
- + :conditions => "notifications.discussion_type = 'Forum'"
- +
- validates_presence_of :login, :email, :password
- validates_uniqueness_of :login, :email, :case_sensitive => false
- # names that start with #s really upset me for some reason
- @@ -40,4 +47,7 @@
- moderatorships.count(:all, :conditions => ['forum_id = ?', (forum.is_a?(Forum) ? forum.id : forum)]) == 1
- end
- + def notifications
- + self.topic_notifications + self.forum_notifications
- + end
- end
- Index: C:/dev/beast/app/models/topic.rb
- ===================================================================
- --- C:/dev/beast/app/models/topic.rb (revision 1866)
- +++ C:/dev/beast/app/models/topic.rb (working copy)
- @@ -35,4 +35,11 @@
- user && (user.id == user_id || user.admin? || user.moderator_of?(forum_id))
- end
- + has_many :notifications, :as => 'discussion'
- + has_many :observers, :through => :notifications, :source => :user do
- + def <<(user)
- + Notification.with_scope(:create => {:discussion_type => 'Topic'}) { self.concat user }
- + end
- + end
- +
- end
- Index: C:/dev/beast/app/models/forum.rb
- ===================================================================
- --- C:/dev/beast/app/models/forum.rb (revision 1866)
- +++ C:/dev/beast/app/models/forum.rb (working copy)
- @@ -17,5 +17,12 @@
- @last_post ||= find(:first, :include => :user)
- end
- end
- +
- + has_many :notifications, :as => 'discussion'
- + has_many :observers, :through => :notifications, :source => :user do
- + def <<(user)
- + Notification.with_scope(:create => {:discussion_type => 'Forum'}) { self.concat user }
- + end
- + end
- end
- Index: C:/dev/beast/app/views/topics/show.rhtml
- ===================================================================
- --- C:/dev/beast/app/views/topics/show.rhtml (revision 1866)
- +++ C:/dev/beast/app/views/topics/show.rhtml (working copy)
- @@ -2,6 +2,8 @@
- <% content_for :right do %>
- +<p id="notifications"><%= render :partial => '/notifications/form', :locals => { :discussion => @forum }%></p>
- +
- <h4>Voices</h4>
- <ul class="flat talking">
- <% @topic.posts.map{ |p| p.user }.uniq.each do | user | %>
- Index: C:/dev/beast/app/views/forums/show.rhtml
- ===================================================================
- --- C:/dev/beast/app/views/forums/show.rhtml (revision 1866)
- +++ C:/dev/beast/app/views/forums/show.rhtml (working copy)
- @@ -5,6 +5,8 @@
- <hr />
- <% end %>
- +<p id="notifications"><%= render :partial => '/notifications/form', :locals => { :discussion => @forum }%></p>
- +
- <h5 style="margin-bottom:1.0em;">Moderators</h5>
- <% if @forum.moderators.any? -%>
- Index: C:/dev/beast/config/routes.rb
- ===================================================================
- --- C:/dev/beast/config/routes.rb (revision 1866)
- +++ C:/dev/beast/config/routes.rb (working copy)
- @@ -2,6 +2,7 @@
- map.home '', :controller => 'forums', :action => 'index'
- map.resources :sessions
- + map.resources :notifications
- map.resources :users, :member => { :admin => :post } do |user|
- user.resources :moderators
Add Comment
Please, Sign In to add comment