diff --git a/app/logical/post_query_builder.rb b/app/logical/post_query_builder.rb index 8fff27df7..dd5a2f350 100644 --- a/app/logical/post_query_builder.rb +++ b/app/logical/post_query_builder.rb @@ -189,6 +189,16 @@ class PostQueryBuilder has_constraints! end + if q[:commenter_id] + relation = relation.where(:id => Comment.where("creator_id = ?", q[:commenter_id]).select("post_id").uniq) + has_constraints! + end + + if q[:noter_id] + relation = relation.where(:id => Note.where("creator_id = ?", q[:noter_id]).select("post_id").uniq) + has_constraints! + end + if q[:parent_id] relation = relation.where("(posts.id = ? or posts.parent_id = ?)", q[:parent_id], q[:parent_id]) has_constraints! @@ -235,10 +245,10 @@ class PostQueryBuilder when "favcount_asc" relation = relation.order("posts.fav_count ASC, posts.id DESC") - when "comment" + when "comment", "comm" relation = relation.order("posts.last_commented_at DESC, posts.id DESC").where("posts.last_commented_at is not null") - when "comment_asc" + when "comment_asc", "comm_asc" relation = relation.order("posts.last_commented_at ASC, posts.id DESC").where("posts.last_commented_at is not null") when "note" diff --git a/app/models/artist_version.rb b/app/models/artist_version.rb index 3677675e6..0bd3b40a3 100644 --- a/app/models/artist_version.rb +++ b/app/models/artist_version.rb @@ -1,5 +1,5 @@ class ArtistVersion < ActiveRecord::Base - belongs_to :updater + belongs_to :updater, :class_name => "User" belongs_to :artist def self.search(params) diff --git a/app/models/comment.rb b/app/models/comment.rb index 604bcd6f5..6c4fd6faa 100644 --- a/app/models/comment.rb +++ b/app/models/comment.rb @@ -3,6 +3,7 @@ class Comment < ActiveRecord::Base validates_format_of :body, :with => /\S/, :message => 'has no content' belongs_to :post belongs_to :creator, :class_name => "User" + belongs_to :updater, :class_name => "User" has_many :votes, :class_name => "CommentVote", :dependent => :destroy before_validation :initialize_creator, :on => :create before_validation :initialize_updater diff --git a/app/models/forum_post.rb b/app/models/forum_post.rb index 0a239d6ce..32f5dd964 100644 --- a/app/models/forum_post.rb +++ b/app/models/forum_post.rb @@ -2,6 +2,7 @@ class ForumPost < ActiveRecord::Base attr_accessible :body, :topic_id, :as => [:member, :builder, :janitor, :privileged, :platinum, :contributor, :admin, :moderator, :default] attr_accessible :is_locked, :is_sticky, :is_deleted, :as => [:admin, :moderator, :janitor] belongs_to :creator, :class_name => "User" + belongs_to :updater, :class_name => "User" belongs_to :topic, :class_name => "ForumTopic" before_validation :initialize_creator, :on => :create before_validation :initialize_updater diff --git a/app/models/tag.rb b/app/models/tag.rb index eb8698e87..ef23c739f 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -1,5 +1,5 @@ class Tag < ActiveRecord::Base - METATAGS = "-user|user|-approver|approver|-pool|pool|-fav|fav|sub|md5|-rating|rating|width|height|mpixels|score|filesize|source|id|date|order|-status|status|tagcount|gentags|arttags|chartags|copytags|parent|pixiv" + METATAGS = "-user|user|-approver|approver|commenter|comm|noter|-pool|pool|-fav|fav|sub|md5|-rating|rating|width|height|mpixels|score|filesize|source|id|date|order|-status|status|tagcount|gentags|arttags|chartags|copytags|parent|pixiv" attr_accessible :category has_one :wiki_page, :foreign_key => "name", :primary_key => "title" @@ -280,6 +280,14 @@ class Tag < ActiveRecord::Base q[:approver_id] = User.name_to_id($2) q[:approver_id] = -1 if q[:approver_id].nil? + when "commenter", "comm" + q[:commenter_id] = User.name_to_id($2) + q[:commenter_id] = -1 if q[:commenter_id].nil? + + when "noter" + q[:noter_id] = User.name_to_id($2) + q[:noter_id] = -1 if q[:noter_id].nil? + when "-pool" q[:tags][:exclude] << "pool:#{Pool.name_to_id($2)}" diff --git a/app/models/user.rb b/app/models/user.rb index eb6b8ebac..6e45cd9eb 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -355,6 +355,10 @@ class User < ActiveRecord::Base return true end + + def level_class + "user-#{level_string.downcase}" + end end module EmailMethods diff --git a/app/presenters/user_presenter.rb b/app/presenters/user_presenter.rb index b626914e5..788fd982a 100644 --- a/app/presenters/user_presenter.rb +++ b/app/presenters/user_presenter.rb @@ -105,7 +105,7 @@ class UserPresenter def inviter(template) if user.inviter_id - template.link_to(user.inviter.name, template.user_path(user.inviter_id)) + template.link_to(user.inviter.name, template.user_path(user.inviter_id), { :class => user.inviter.level_class }) else "None" end diff --git a/app/views/artist_versions/index.html.erb b/app/views/artist_versions/index.html.erb index 762b5fb52..ec2b72bf2 100644 --- a/app/views/artist_versions/index.html.erb +++ b/app/views/artist_versions/index.html.erb @@ -27,7 +27,7 @@ <%= artist_version_other_names_diff(artist_version) %> <%= artist_version.group_name %> <%= compact_time artist_version.created_at %> - <%= link_to artist_version.updater_name, user_path(artist_version.updater_id) %> + <%= link_to artist_version.updater_name, user_path(artist_version.updater_id), { :class => artist_version.updater.level_class } %> <%= artist_version.is_active? %>