Guest User

Untitled

a guest
Feb 20th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.64 KB | None | 0 0
  1. Index: C:/dev/beast/app/models/user.rb
  2. ===================================================================
  3. --- C:/dev/beast/app/models/user.rb (revision 1866)
  4. +++ C:/dev/beast/app/models/user.rb (working copy)
  5. @@ -5,6 +5,13 @@
  6. has_many :forums, :through => :moderatorships, :order => 'forums.name'
  7.  
  8. has_many :posts
  9. +
  10. + has_many :notifications
  11. + has_many :topic_notifications, :through => :notifications, :source => :topic,
  12. + :conditions => "notifications.discussion_type = 'Topic'"
  13. + has_many :forum_notifications, :through => :notifications, :source => :forum,
  14. + :conditions => "notifications.discussion_type = 'Forum'"
  15. +
  16. validates_presence_of :login, :email, :password
  17. validates_uniqueness_of :login, :email, :case_sensitive => false
  18. # names that start with #s really upset me for some reason
  19. @@ -40,4 +47,7 @@
  20. moderatorships.count(:all, :conditions => ['forum_id = ?', (forum.is_a?(Forum) ? forum.id : forum)]) == 1
  21. end
  22.  
  23. + def notifications
  24. + self.topic_notifications + self.forum_notifications
  25. + end
  26. end
  27. Index: C:/dev/beast/app/models/topic.rb
  28. ===================================================================
  29. --- C:/dev/beast/app/models/topic.rb (revision 1866)
  30. +++ C:/dev/beast/app/models/topic.rb (working copy)
  31. @@ -35,4 +35,11 @@
  32. user && (user.id == user_id || user.admin? || user.moderator_of?(forum_id))
  33. end
  34.  
  35. + has_many :notifications, :as => 'discussion'
  36. + has_many :observers, :through => :notifications, :source => :user do
  37. + def <<(user)
  38. + Notification.with_scope(:create => {:discussion_type => 'Topic'}) { self.concat user }
  39. + end
  40. + end
  41. +
  42. end
  43. Index: C:/dev/beast/app/models/forum.rb
  44. ===================================================================
  45. --- C:/dev/beast/app/models/forum.rb (revision 1866)
  46. +++ C:/dev/beast/app/models/forum.rb (working copy)
  47. @@ -17,5 +17,12 @@
  48. @last_post ||= find(:first, :include => :user)
  49. end
  50. end
  51. +
  52. + has_many :notifications, :as => 'discussion'
  53. + has_many :observers, :through => :notifications, :source => :user do
  54. + def <<(user)
  55. + Notification.with_scope(:create => {:discussion_type => 'Forum'}) { self.concat user }
  56. + end
  57. + end
  58.  
  59. end
  60. Index: C:/dev/beast/app/views/topics/show.rhtml
  61. ===================================================================
  62. --- C:/dev/beast/app/views/topics/show.rhtml (revision 1866)
  63. +++ C:/dev/beast/app/views/topics/show.rhtml (working copy)
  64. @@ -2,6 +2,8 @@
  65.  
  66. <% content_for :right do %>
  67.  
  68. +<p id="notifications"><%= render :partial => '/notifications/form', :locals => { :discussion => @forum }%></p>
  69. +
  70. <h4>Voices</h4>
  71. <ul class="flat talking">
  72. <% @topic.posts.map{ |p| p.user }.uniq.each do | user | %>
  73. Index: C:/dev/beast/app/views/forums/show.rhtml
  74. ===================================================================
  75. --- C:/dev/beast/app/views/forums/show.rhtml (revision 1866)
  76. +++ C:/dev/beast/app/views/forums/show.rhtml (working copy)
  77. @@ -5,6 +5,8 @@
  78. <hr />
  79. <% end %>
  80.  
  81. +<p id="notifications"><%= render :partial => '/notifications/form', :locals => { :discussion => @forum }%></p>
  82. +
  83. <h5 style="margin-bottom:1.0em;">Moderators</h5>
  84.  
  85. <% if @forum.moderators.any? -%>
  86. Index: C:/dev/beast/config/routes.rb
  87. ===================================================================
  88. --- C:/dev/beast/config/routes.rb (revision 1866)
  89. +++ C:/dev/beast/config/routes.rb (working copy)
  90. @@ -2,6 +2,7 @@
  91. map.home '', :controller => 'forums', :action => 'index'
  92.  
  93. map.resources :sessions
  94. + map.resources :notifications
  95.  
  96. map.resources :users, :member => { :admin => :post } do |user|
  97. user.resources :moderators
Add Comment
Please, Sign In to add comment