mirror of
https://github.com/ENSL/ensl.org.git
synced 2024-12-26 12:30:48 +00:00
Update to unread gem
This commit is contained in:
parent
2784a6cd74
commit
5fcf4b2a72
14 changed files with 25 additions and 25 deletions
|
@ -4,7 +4,7 @@ class CategoriesController < ApplicationController
|
|||
def show
|
||||
if [Category::DOMAIN_ARTICLES, Category::DOMAIN_NEWS].include? @category.domain
|
||||
@articles = Article.with_comments.ordered.limited.nodrafts.category params[:id]
|
||||
Category.find(params[:id]).read_by! cuser if cuser
|
||||
Category.find(params[:id]).mark_as_read! for: cuser if cuser
|
||||
render partial: 'articles/article', collection: @articles.to_a
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,7 +25,7 @@ class CustomUrlsController < ApplicationController
|
|||
raise ActiveRecord::RecordNotFound unless custom_url
|
||||
@article = custom_url.article
|
||||
raise AccessError unless @article.can_show? cuser
|
||||
@article.read_by! cuser if cuser
|
||||
@article.mark_as_read! for: cuser if cuser
|
||||
render 'articles/show'
|
||||
end
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ class ForumsController < ApplicationController
|
|||
.order('state DESC, (SELECT created_at FROM posts p2 WHERE p2.topic_id = topics.id ORDER BY created_at DESC LIMIT 1) DESC')
|
||||
.paginate(page: params[:page], per_page: 30)
|
||||
|
||||
@forum.read_by! cuser if cuser
|
||||
@forum.mark_as_read! for: cuser if cuser
|
||||
@nobody = true
|
||||
end
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ class IssuesController < ApplicationController
|
|||
|
||||
def show
|
||||
raise AccessError unless @issue.can_show? cuser
|
||||
@issue.read_by! cuser
|
||||
@issue.mark_as_read! for: cuser
|
||||
end
|
||||
|
||||
def new
|
||||
|
|
|
@ -7,7 +7,7 @@ class MessagesController < ApplicationController
|
|||
|
||||
def show
|
||||
raise AccessError unless @message.can_show? cuser
|
||||
@message.read_by! cuser
|
||||
@message.mark_as_read! for: cuser
|
||||
@messages = @message.thread
|
||||
end
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ class MoviesController < ApplicationController
|
|||
end
|
||||
|
||||
def show
|
||||
@movie.read_by! cuser if cuser
|
||||
@movie.mark_as_read! for: cuser if cuser
|
||||
@movie.record_view_count(request.remote_ip, cuser.nil?)
|
||||
redirect_to @movie.file.related if @movie.file and @movie.file.related
|
||||
end
|
||||
|
|
|
@ -13,8 +13,8 @@ class TopicsController < ApplicationController
|
|||
|
||||
return_here
|
||||
@topic.record_view_count(request.remote_ip, cuser.nil?)
|
||||
@topic.read_by! cuser if cuser
|
||||
@topic.forum.read_by! cuser if cuser
|
||||
@topic.mark_as_read! for: cuser if cuser
|
||||
@topic.forum.mark_as_read! for: cuser if cuser
|
||||
@newpost = Post.new
|
||||
@newpost.topic = @topic
|
||||
@newpost.user = cuser
|
||||
|
|
|
@ -69,7 +69,7 @@ class Article < ActiveRecord::Base
|
|||
after_destroy :remove_readings
|
||||
|
||||
has_view_count
|
||||
acts_as_readable
|
||||
acts_as_reader
|
||||
acts_as_versioned
|
||||
|
||||
non_versioned_columns << 'category_id'
|
||||
|
|
|
@ -48,7 +48,7 @@ class Category < ActiveRecord::Base
|
|||
has_many :gathers
|
||||
has_many :servers
|
||||
|
||||
acts_as_readable
|
||||
acts_as_reader
|
||||
|
||||
def to_s
|
||||
name
|
||||
|
|
|
@ -34,7 +34,7 @@ class Forum < ActiveRecord::Base
|
|||
|
||||
after_create :update_position
|
||||
|
||||
acts_as_readable
|
||||
acts_as_reader
|
||||
|
||||
def to_s
|
||||
self.title
|
||||
|
@ -65,17 +65,17 @@ class Forum < ActiveRecord::Base
|
|||
end
|
||||
|
||||
def self.available_to cuser, level
|
||||
user_has_access =
|
||||
Forum .joins("JOIN forumers ON forumers.forum_id = forums.id
|
||||
AND forumers.access = #{level}")
|
||||
.joins("JOIN groups ON forumers.group_id = groups.id")
|
||||
.joins("JOIN groupers ON groupers.group_id = groups.id
|
||||
AND groupers.user_id = #{cuser.id}")
|
||||
user_has_access =
|
||||
Forum .joins("JOIN forumers ON forumers.forum_id = forums.id
|
||||
AND forumers.access = #{level}")
|
||||
.joins("JOIN groups ON forumers.group_id = groups.id")
|
||||
.joins("JOIN groupers ON groupers.group_id = groups.id
|
||||
AND groupers.user_id = #{cuser.id}")
|
||||
|
||||
is_admin = Grouper.where(user_id: cuser, group_id: Group::ADMINS)
|
||||
Forum.where("EXISTS (#{is_admin.to_sql}) OR
|
||||
id IN (SELECT q.id from (#{user_has_access.to_sql}) q ) OR
|
||||
id IN (SELECT q.id from (#{Forum.public_forums.to_sql}) q )")
|
||||
is_admin = Grouper.where(user_id: cuser, group_id: Group::ADMINS)
|
||||
Forum.where("EXISTS (#{is_admin.to_sql}) OR
|
||||
id IN (SELECT q.id from (#{user_has_access.to_sql}) q ) OR
|
||||
id IN (SELECT q.id from (#{Forum.public_forums.to_sql}) q )")
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -49,7 +49,7 @@ class Issue < ActiveRecord::Base
|
|||
before_save :parse_text
|
||||
after_save :remove_readings
|
||||
|
||||
acts_as_readable
|
||||
acts_as_reader
|
||||
|
||||
def to_s
|
||||
title
|
||||
|
|
|
@ -37,7 +37,7 @@ class Message < ActiveRecord::Base
|
|||
before_save :parse_text
|
||||
after_create :send_notifications
|
||||
|
||||
acts_as_readable
|
||||
acts_as_reader
|
||||
|
||||
def to_s
|
||||
title
|
||||
|
|
|
@ -62,7 +62,7 @@ class Movie < ActiveRecord::Base
|
|||
mount_uploader :picture, MovieUploader
|
||||
|
||||
has_view_count
|
||||
acts_as_readable
|
||||
acts_as_reader
|
||||
|
||||
def to_s
|
||||
file.to_s
|
||||
|
|
|
@ -39,7 +39,7 @@ class Topic < ActiveRecord::Base
|
|||
|
||||
after_create :make_post
|
||||
|
||||
acts_as_readable
|
||||
acts_as_reader
|
||||
|
||||
def self.recent_topics
|
||||
find_by_sql %q{
|
||||
|
|
Loading…
Reference in a new issue