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