top contributors
This commit is contained in:
parent
3992e57adc
commit
446a117ec8
6 changed files with 58 additions and 1 deletions
5
app/controllers/users_controller.rb
Normal file
5
app/controllers/users_controller.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class UsersController < ApplicationController
|
||||||
|
def top_contributors
|
||||||
|
@users = User.top_contributors.paginate :page => params[:page], :per_page => 20
|
||||||
|
end
|
||||||
|
end
|
|
@ -3,7 +3,7 @@ class User < ActiveRecord::Base
|
||||||
|
|
||||||
has_many :contributions
|
has_many :contributions
|
||||||
|
|
||||||
scope :top_contributors, order('points DESC')
|
scope :top_contributors, order('points DESC').where(arel_table[:points].gt(0))
|
||||||
|
|
||||||
def self.find_or_create_from_remote_auth_data(user_data)
|
def self.find_or_create_from_remote_auth_data(user_data)
|
||||||
user = find_or_initialize_by_remote_id_and_auth_server_id(
|
user = find_or_initialize_by_remote_id_and_auth_server_id(
|
||||||
|
|
|
@ -11,3 +11,4 @@
|
||||||
@import outfits/new
|
@import outfits/new
|
||||||
@import pets/bulk
|
@import pets/bulk
|
||||||
@import static/terms
|
@import static/terms
|
||||||
|
@import users/top_contributors
|
||||||
|
|
15
app/stylesheets/users/_top_contributors.sass
Normal file
15
app/stylesheets/users/_top_contributors.sass
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
body.users-top_contributors
|
||||||
|
text-align: center
|
||||||
|
|
||||||
|
#top-contributors
|
||||||
|
border:
|
||||||
|
spacing: 0
|
||||||
|
width: 1px 1px 0 0
|
||||||
|
margin: 1em auto
|
||||||
|
&, td, th
|
||||||
|
border:
|
||||||
|
color: $text-color
|
||||||
|
style: solid
|
||||||
|
td, th
|
||||||
|
border-width: 0 0 1px 1px
|
||||||
|
padding: .5em 1em
|
15
app/views/users/top_contributors.html.haml
Normal file
15
app/views/users/top_contributors.html.haml
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
- title 'Top Contributors'
|
||||||
|
= will_paginate @users
|
||||||
|
%table#top-contributors
|
||||||
|
%thead
|
||||||
|
%tr
|
||||||
|
%th{:scope => 'column'} Rank
|
||||||
|
%th{:scope => 'column'} User
|
||||||
|
%th{:scope => 'column'} Points
|
||||||
|
%tbody
|
||||||
|
- @users.each_with_index do |user, rank|
|
||||||
|
%tr
|
||||||
|
%th{:scope => 'row'}= @users.offset + rank + 1
|
||||||
|
%td= link_to user.name, user_contributions_path(user)
|
||||||
|
%td= user.points
|
||||||
|
= will_paginate @users
|
|
@ -956,3 +956,24 @@ body.pets-bulk .script-only {
|
||||||
body.static-terms {
|
body.static-terms {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* line 1, ../../../app/stylesheets/users/_top_contributors.sass */
|
||||||
|
body.users-top_contributors {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
/* line 4, ../../../app/stylesheets/users/_top_contributors.sass */
|
||||||
|
body.users-top_contributors #top-contributors {
|
||||||
|
border-spacing: 0;
|
||||||
|
border-width: 1px 1px 0 0;
|
||||||
|
margin: 1em auto;
|
||||||
|
}
|
||||||
|
/* line 9, ../../../app/stylesheets/users/_top_contributors.sass */
|
||||||
|
body.users-top_contributors #top-contributors, body.users-top_contributors #top-contributors td, body.users-top_contributors #top-contributors th {
|
||||||
|
border-color: #004400;
|
||||||
|
border-style: solid;
|
||||||
|
}
|
||||||
|
/* line 13, ../../../app/stylesheets/users/_top_contributors.sass */
|
||||||
|
body.users-top_contributors #top-contributors td, body.users-top_contributors #top-contributors th {
|
||||||
|
border-width: 0 0 1px 1px;
|
||||||
|
padding: 0.5em 1em;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue