This commit is contained in:
albert
2011-06-25 16:33:30 -04:00
parent 1ad075c05a
commit 28d179708f
18 changed files with 113 additions and 23 deletions

View File

@@ -14,7 +14,7 @@ class ArtistsController < ApplicationController
def index
@search = Artist.search(params[:search])
@artists = @search.paginate(:page => params[:page])
@artists = @search.paginate(params[:page])
respond_with(@artists)
end

View File

@@ -39,7 +39,7 @@ class CommentsController < ApplicationController
private
def index_by_post
@posts = Post.tag_match(params[:tags]).commented_before(params[:before_date] || Time.now).limit(8)
@posts = Post.commented_before(Time.now).tag_match(params[:tags]).paginate(params[:page])
respond_with(@posts) do |format|
format.html {render :action => "index_by_post"}
end
@@ -47,7 +47,7 @@ private
def index_by_comment
@search = Comment.search(params[:search])
@comments = @search.paginate(:page => params[:page])
@comments = @search.paginate(params[:page])
respond_with(@comments) do |format|
format.html {render :action => "index_by_comment"}
end

View File

@@ -52,7 +52,7 @@ private
end
def index_by_post
@posts = Post.tag_match(params[:tags]).noted_before(params[:before_date] || Time.now).limit(8)
@posts = Post.tag_match(params[:tags]).noted_before(params[:before_date] || Time.now).paginate(params[:page])
respond_with(@posts) do |format|
format.html {render :action => "index_by_post"}
end
@@ -60,7 +60,7 @@ private
def index_by_note
@search = Note.search(params[:search])
@notes = @search.paginate(:page => params[:page])
@notes = @search.paginate(params[:page])
respond_with(@notes) do |format|
format.html {render :action => "index_by_note"}
end

View File

@@ -9,7 +9,7 @@ class TagAliasesController < ApplicationController
def index
@search = TagAlias.search(params[:search])
@tag_aliases = @search.paginate(:page => params[:page])
@tag_aliases = @search.paginate(params[:page])
respond_with(@tag_aliases)
end

View File

@@ -9,7 +9,7 @@ class TagImplicationsController < ApplicationController
def index
@search = TagImplication.search(params[:search])
@tag_implications = @search.paginate(:page => params[:page])
@tag_implications = @search.paginate(params[:page])
respond_with(@tag_implicationes)
end

View File

@@ -9,7 +9,7 @@ class TagsController < ApplicationController
def index
@search = Tag.search(params[:search])
@tags = @search.paginate(:page => params[:page])
@tags = @search.paginate(params[:page])
respond_with(@tags)
end

View File

@@ -16,7 +16,7 @@ class UsersController < ApplicationController
def index
@search = User.search(params[:search])
@users = @search.paginate(:page => params[:page])
@users = @search.paginate(params[:page])
respond_with(@users)
end

View File

@@ -35,12 +35,11 @@ module ApplicationHelper
protected
def nav_link_match(controller, url)
puts "controller=#{controller} url=#{url}"
url =~ case controller
when "tag_aliases", "tag_implications"
/^\/tags/
when "sessions", "user_maintenance"
/^\/users/
when "sessions", "users"
/^\/(session|users)/
when "forum_posts"
/^\/forum_topics/

View File

@@ -40,6 +40,8 @@ class Post < ActiveRecord::Base
scope :available_for_moderation, lambda {where(["id NOT IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id])}
scope :hidden_from_moderation, lambda {where(["id IN (SELECT pd.post_id FROM post_disapprovals pd WHERE pd.user_id = ?)", CurrentUser.id])}
scope :tag_match, lambda {|query| Post.tag_match_helper(query)}
scope :positive, where("score > 1")
scope :negative, where("score < -1")
search_methods :tag_match
scope :after_id, Proc.new {|num|
if num.present?

View File

@@ -7,7 +7,7 @@ class User < ActiveRecord::Base
attr_accessor :password, :old_password
attr_accessible :password, :old_password, :password_confirmation, :password_hash, :email, :last_logged_in_at, :last_forum_read_at, :has_mail, :receive_email_notifications, :comment_threshold, :always_resize_images, :favorite_tags, :blacklisted_tags, :name, :ip_addr
validates_length_of :name, :within => 2..20, :on => :create
validates_format_of :name, :with => /\A[^\s;,]+\Z/, :on => :create, :message => "cannot have whitespace, commas, or semicolons"
validates_format_of :name, :with => /\A[^\s:]+\Z/, :on => :create, :message => "cannot have whitespace or colons"
validates_uniqueness_of :name, :case_sensitive => false, :on => :create
validates_uniqueness_of :email, :case_sensitive => false, :on => :create, :if => lambda {|rec| !rec.email.blank?}
validates_length_of :password, :minimum => 5, :if => lambda {|rec| rec.new_record? || !rec.password.blank?}
@@ -22,6 +22,7 @@ class User < ActiveRecord::Base
has_many :feedback, :class_name => "UserFeedback", :dependent => :destroy
has_one :ban
has_many :subscriptions, :class_name => "TagSubscription"
has_many :note_versions, :foreign_key => "updater_id"
belongs_to :inviter, :class_name => "User"
scope :named, lambda {|name| where(["lower(name) = ?", name])}
scope :admins, where("is_admin = TRUE")
@@ -143,6 +144,13 @@ class User < ActiveRecord::Base
end
end
def level_string
if is_admin?
"Admin"
elsif is_moderator?
"Moderator"
end
def normalize_level
if is_admin?
self.is_moderator = true
@@ -254,6 +262,12 @@ class User < ActiveRecord::Base
end
end
module PostMethods
def posts
Post.where("uploader_string = ?", "uploader:#{id}")
end
end
include BanMethods
include NameMethods
include PasswordMethods
@@ -264,6 +278,7 @@ class User < ActiveRecord::Base
include BlacklistMethods
include ForumMethods
include LimitMethods
include PostMethods
def initialize_default_image_size
self.default_image_size = "Medium"

View File

@@ -8,7 +8,7 @@
</div>
</div>
<div id="paginator">
<div class="paginator">
<%= sequential_paginator(@comments) %>
</div>
</div>

View File

@@ -1,5 +1,9 @@
<div id="c-comments">
<div id="a-index">
<% if @posts.empty? %>
<%= render "post_sets/blank" %>
<% end %>
<% @posts.each do |post| %>
<div class="post">
<div class="preview">
@@ -10,7 +14,7 @@
</div>
<% end %>
<div id="paginator">
<div class="paginator">
<%= sequential_paginator(@posts) %>
</div>
</div>

View File

@@ -1,3 +1,3 @@
<p>Nobody here but us chickens!</p>
<p><%= link_to "Go back", :back %>.</p>
<p><%= link_to "Go back", :back %></p>

View File

@@ -36,7 +36,9 @@
</div>
<div id="paginator">
<%= will_paginate(@aliases) %>
<%= numbered_paginator(@tag_aliases) do |page| %>
<%= link_to(page, tag_aliases_path(:page => page)) %>
<% end %>
</div>
<%= render "secondary_links" %>

View File

@@ -36,7 +36,9 @@
</div>
<div id="paginator">
<%= will_paginate(@implications) %>
<%= numbered_paginator(@tag_implications) do |page| %>
<%= link_to(page, tag_impliactions_path(:page => page)) %>
<% end %>
</div>
<%= render "secondary_links" %>

View File

@@ -18,8 +18,10 @@
</tbody>
</table>
<div id="paginator">
<%= will_paginate(@tags) %>
<div class="paginator">
<%= numbered_paginator(@tags) do |page| %>
<%= link_to(page, tags_path(:page => page)) %>
<% end %>
</div>
<%= render "secondary_links" %>

View File

@@ -0,0 +1,64 @@
<div id="c-users">
<div id="a-index">
<h1>Users</h1>
<% simple_form_for(@search) do |f| %>
<%= f.input :name_contains, :label => "Name" %>
<%= f.input :is_banned_is_true, :label => "Banned" %>
<%= f.input :is_privileged_is_true, :label => "Privileged" %>
<%= f.input :is_contributor_is_true, :label => "Contributor" %>
<%= f.input :is_janitor_is_true, :label => "Janitor" %>
<%= f.input :is_moderator_is_true, :label => "Moderator" %>
<%= f.input :is_admin_is_true, :label => "Admin" %>
<%= f.sort_link "Name", :name %>
<%= f.sort_link "Date", :created_at_desc %>
<%= f.button :submit %>
<% end %>
<table width="100%" class="highlightable">
<thead>
<tr>
<th>Name</th>
<th>Posts</th>
<th>Deleted</th>
<th>% Pos</th>
<th>% Neg</th>
<th>Notes</th>
<th>Level</th>
<th>Joined</th>
</tr>
</thead>
<tbody>
<% @users.each do |user| %>
<tr>
<td>
<%= link_to user.pretty_name, user_path(user.id) %>
<% if user.inviter %>
&larr; <%= link_to user.inviter.name, user_path(user.inviter_id) %>
<% end %>
</td>
<td><%= link_to user.posts.count, posts_path(:tags => "uploader:#{user.name}") %></td>
<td><%= user.posts.deleted.count %></td>
<% if user.posts.count > 100 %>
<td><%= number_to_percentage(100 * user.posts.positive.count.to_f / user.posts.count, :precision => 0) %></td>
<td><%= number_to_percentage(100 * user.posts.negative.count.to_f / user.posts.count, :precision => 0) %></td>
<% else %>
<td></td>
<td></td>
<% end %>
<td><%= link_to user.note_versions.count, note_versions_path(:search => {:updater_id_eq => user.id}) %></td>
<td><%= user.pretty_level %></td>
<td><span title="<%= user.created_at %>"><%= time_ago_in_words user.created_at %> ago</span></td>
</tr>
<% end %>
</tbody>
</table>
<div id="paginator">
<%= will_paginate(@users) %>
</div>
<%= render :partial => "footer" %>
</div>
</div>

View File

@@ -52,7 +52,7 @@
<p>There are some restrictions on names:</p>
<ul>
<li><strong>Name</strong>: Your name must be at least 2 characters and at most 20 characters long. It cannot contain spaces, commas, colons, or semi-colons. All characters must be US-ASCII.</li>
<li><strong>Name</strong>: Your name must be at least 2 characters and at most 20 characters long. It cannot contain spaces or colons. All characters must be US-ASCII.</li>
<li><strong>Password</strong>: Your password must be at least 5 characters long.</li>
<li>
<strong>Email</strong>: