Creating sweet user summary page
This commit is contained in:
parent
17aa2b971c
commit
03a0588073
|
@ -19,7 +19,6 @@ pre {
|
|||
font-size: 11px;
|
||||
}
|
||||
|
||||
|
||||
div {
|
||||
&.field, &.actions {
|
||||
margin-bottom: 10px;
|
||||
|
|
|
@ -17,10 +17,11 @@ class UsersController < ApplicationController
|
|||
def index
|
||||
unless params[:full] # by default, show summary
|
||||
|
||||
@users = @users.joins(:payments).where("payments.date > ?", (DateTime.now - 60.days)).uniq
|
||||
@users = @users.paying + @users.volunteer
|
||||
#.joins(:payments).where("payments.date > ? OR ", (DateTime.now - 60.days)).uniq
|
||||
|
||||
respond_to do |format|
|
||||
format.html { render 'summary' }
|
||||
format.html { render 'summary', layout: 'resources' }
|
||||
format.json { render :json => @users }
|
||||
end
|
||||
|
||||
|
|
|
@ -7,4 +7,25 @@ module ApplicationHelper
|
|||
sort_dir = params[:dir] == 'up' ? 'down' : 'up'
|
||||
link_to_unless condition, title, request.parameters.merge( {:sort => column, :dir => sort_dir} )
|
||||
end
|
||||
|
||||
def li_link_to(name = nil, options = nil, html_options = nil, &block)
|
||||
html_options, options, name = options, name, block if block_given?
|
||||
options ||= {}
|
||||
|
||||
html_options = convert_options_to_data_attributes(options, html_options)
|
||||
|
||||
url = url_for(options)
|
||||
html_options['href'] ||= url
|
||||
|
||||
if current_page?(url)
|
||||
content_tag(:li, class: "active") do
|
||||
content_tag(:a, name || url, html_options, &block)
|
||||
end
|
||||
else
|
||||
content_tag(:li) do
|
||||
content_tag(:a, name || url, html_options, &block)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -18,6 +18,9 @@ class User < ActiveRecord::Base
|
|||
has_many :macs
|
||||
has_many :resources
|
||||
|
||||
scope :volunteer, -> { where('member_level >= 10 AND member_level < 25') }
|
||||
scope :paying, -> { joins(:payments).where("payments.date > ?", (DateTime.now - 90.days)).uniq }
|
||||
|
||||
validates_format_of [:twitter_url, :facebook_url, :github_url, :website_url], :with => URI::regexp(%w(http https)), :allow_blank => true
|
||||
|
||||
# disable # validates_presence_of :postal_code
|
||||
|
|
|
@ -33,9 +33,14 @@
|
|||
<%= link_to 'Membership Application', new_user_registration_path unless user_signed_in? %>
|
||||
</div>
|
||||
<div id="content">
|
||||
<% if notice %>
|
||||
<p class="notice"><%= raw(notice) %></p>
|
||||
<% end %>
|
||||
<% if alert %>
|
||||
<p class="alert"><%= raw(alert) %></p>
|
||||
<%= yield %>
|
||||
<% end %>
|
||||
|
||||
<%= yield %>
|
||||
</div>
|
||||
<%= raw Setting.analytics_code if Setting.present? %>
|
||||
</body>
|
||||
|
|
|
@ -60,18 +60,23 @@
|
|||
|
||||
<div class="collapse navbar-collapse" id="mainmenu-collapse">
|
||||
<ul class="nav navbar-nav">
|
||||
<li>
|
||||
<%= link_to 'People', users_path if can? :read, User %>
|
||||
<% if can? :read, User %>
|
||||
<li class="dropdown <%= "active" if current_page?(controller: :users) %>">
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">People <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<%= li_link_to 'People', users_path if can? :read, User %>
|
||||
<%= li_link_to 'People - Full Table View', {:controller => "users", :full => "full"} if can? :read, User %>
|
||||
<%= li_link_to 'Inactive Users', users_inactive_path if can? :inactive_report, User %>
|
||||
<%= li_link_to 'Recent Activity', users_activity_path if can? :activity, User %>
|
||||
<%= li_link_to 'New Members Report', users_new_member_report_path if can? :new_member_report, User %>
|
||||
</ul>
|
||||
</li>
|
||||
<li class="active">
|
||||
<%= link_to 'Tools & Resources', resources_path if can? :read, Resource %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to 'Access Cards', cards_path if can? :manage, Card %>
|
||||
</li>
|
||||
<li class="dropdown">
|
||||
<% end %>
|
||||
<%= li_link_to 'Tools & Resources', resources_path if can? :read, Resource %>
|
||||
<%= li_link_to 'Doors', cards_path if can? :manage, Card %>
|
||||
<% if can? :create, UserCertification %>
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Certifications <b class="caret"></b></a>
|
||||
<li class="dropdown <%= 'active' if current_page?(controller: :certifications) %>" >
|
||||
<a href="#" class="dropdown-toggle" data-toggle="dropdown">Certs <b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<%= link_to 'Classes', certifications_path if can? :read, Certification %>
|
||||
|
@ -80,31 +85,17 @@
|
|||
<%= link_to 'User Certs', user_certifications_path if can? :create, UserCertification %>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<% else %>
|
||||
<%= link_to 'Certifications', certifications_path if can? :read, Certification %>
|
||||
<%= li_link_to 'Certifications', certifications_path if can? :read, Certification %>
|
||||
<% end %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to 'Payments', payments_path if can? :create, Payment %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to 'Computers', macs_path if user_signed_in? || (can? :read, Mac) %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to 'Settings', settings_path if can? :read, Setting %>
|
||||
</li>
|
||||
<li>
|
||||
<% if user_signed_in? then %><%= link_to 'Profile', edit_user_registration_path %><% end %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to 'Logout', destroy_user_session_path, :method => :delete if user_signed_in? %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to 'Login', new_user_session_path unless user_signed_in? %>
|
||||
</li>
|
||||
<li>
|
||||
<%= link_to 'Membership Application', new_user_registration_path unless user_signed_in? %>
|
||||
</li>
|
||||
<%= li_link_to 'Computers', macs_path if user_signed_in? || (can? :read, Mac) %>
|
||||
<%= li_link_to 'Payments', payments_path if can? :create, Payment %>
|
||||
<%= li_link_to 'Settings', settings_path if can? :read, Setting %>
|
||||
<%= li_link_to 'Profile', edit_user_registration_path if user_signed_in? %>
|
||||
<%= li_link_to 'Logout', destroy_user_session_path, :method => :delete if user_signed_in? %>
|
||||
<%= li_link_to 'Login', new_user_session_path unless user_signed_in? %>
|
||||
<%= li_link_to 'Membership Application', new_user_registration_path unless user_signed_in? %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,13 +1,15 @@
|
|||
<h1 class="col-sm-6">Lab Resources
|
||||
<div class="row">
|
||||
<h1 class="col-md-8">Lab Resources
|
||||
<%= link_to 'Add Resource', new_resource_path, :class => "btn btn-success" if can? :create, Resource %>
|
||||
<%= link_to 'Categories', resource_categories_path, :class => "btn btn-primary" if can? :read, ResourceCategory %>
|
||||
<a class="btn btn-default" onclick="$('#accordion .collapse').collapse('toggle')" />Expand/Collapse All</a>
|
||||
</h1>
|
||||
</h1>
|
||||
|
||||
<span class="col-sm-2">
|
||||
<h3>Featured item:</h3>
|
||||
<%= render @featured_resource %>
|
||||
</span>
|
||||
<span class="col-md-2 col-xs-6">
|
||||
<h3>Featured item:</h3>
|
||||
<%= render @featured_resource %>
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<% unless @resources.blank? %>
|
||||
|
@ -22,7 +24,7 @@
|
|||
<div id="collapse_cat_<%= resource_category.id %>" class="panel-collapse collapse">
|
||||
<div class="panel-body">
|
||||
<% resources.each do |resource| %>
|
||||
<div class="col-sm-2">
|
||||
<div class="col-xs-2">
|
||||
<%= render resource %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
|
5
app/views/users/_badges.html.erb
Normal file
5
app/views/users/_badges.html.erb
Normal file
|
@ -0,0 +1,5 @@
|
|||
<%= raw(user.member_status_symbol) %>
|
||||
<%= link_to image_tag('/twitter.png', :class => 'social-icon', :title => "Twitter"), user.twitter_url, :class => 'social-link' if user.twitter_url.present? %>
|
||||
<%= link_to image_tag('/facebook.png', :class => 'social-icon', :title => "Facebook"), user.facebook_url, :class => 'social-link' if user.facebook_url.present? %>
|
||||
<%= link_to image_tag('/github.png', :class => 'social-icon', :title => "Github"), user.github_url, :class => 'social-link' if user.github_url.present? %>
|
||||
<%= link_to image_tag('/website.png', :class => 'social-icon', :title => "Website"), user.website_url, :class => 'social-link' if user.website_url.present? %>
|
|
@ -1,6 +1,8 @@
|
|||
<div class="thumbnail col-lg-1 col-sm-2 col-xs-4">
|
||||
<%= image_tag user.gravatar_url(:default => "http://members.heatsynclabs.org/pirate.png") %>
|
||||
<span class="badges"><%= raw(user.member_status_symbol) %></span>
|
||||
<span class="badges">
|
||||
<%= render partial: 'badges', locals: {user: user} %>
|
||||
</span>
|
||||
|
||||
<h4><%= link_to user.name, user %></h4>
|
||||
</div>
|
||||
|
|
|
@ -1,41 +1,33 @@
|
|||
<link href="/bootstrap/css/bootstrap.min.css" type="text/css" rel="stylesheet" />
|
||||
<link href="/bootstrap/css/bootstrap-theme.min.css" type="text/css" rel="stylesheet" />
|
||||
<script src="/bootstrap/js/bootstrap.min.js" type="text/javascript" ></script>
|
||||
|
||||
<style type="text/css">
|
||||
.users .thumbnail {
|
||||
height: 200px;
|
||||
position: relative;
|
||||
}
|
||||
.users .badges { position: absolute; top: 125px; }
|
||||
.users .badges { position: absolute; bottom: 3em; }
|
||||
.users .badges img {
|
||||
float: left;
|
||||
width: 24px;
|
||||
height: 24px;
|
||||
background-color: white;
|
||||
border-radius: 12px;
|
||||
}
|
||||
.users .thumbnail h4 { position: absolute; bottom: 1px; margin-bottom: 1px; }
|
||||
|
||||
</style>
|
||||
|
||||
<% if user_signed_in? && current_user.current_sign_in_at < Date.parse("2014-03-01") %>
|
||||
<div class="alert alert-info">Looking for the old table view? Find it in the menu under People, Full Table View.</div>
|
||||
<% end %>
|
||||
|
||||
<h1>HeatSync People
|
||||
<%= link_to 'Full Table View', {:controller => "users", :full => "full"}, class: "btn btn-primary" %>
|
||||
<%= link_to 'New User', new_user_path, class: "btn btn-success" if can? :create, User %>
|
||||
<%= link_to 'Merge Users', users_merge_path, class: "btn btn-default" if can? :manage, User %>
|
||||
</h1>
|
||||
|
||||
<% if can? :create, User %>
|
||||
<%= link_to 'New User', new_user_path %> |
|
||||
<% end %>
|
||||
<% if can? :manage, User %>
|
||||
<%= link_to 'Merge Users', users_merge_path %> |
|
||||
<% end %>
|
||||
<% if current_user.admin? %>
|
||||
<%= link_to 'Inactive Users', users_inactive_path %> |
|
||||
<% end %>
|
||||
<% if can? :activity, User %>
|
||||
<%= link_to 'Recent Activity', users_activity_path %> |
|
||||
<% end %>
|
||||
<% if can? :new_member_report, User %>
|
||||
<%= link_to 'New Members Report', users_new_member_report_path %>
|
||||
<% end %>
|
||||
|
||||
|
||||
|
||||
<div class="users">
|
||||
<%= render @users.sort_by(&:member_status).reverse %>
|
||||
<%= render @users.sort_by{|u| [-u.member_status, u.name] } %>
|
||||
</div>
|
||||
|
||||
<% if current_user.orientation.blank? then %>
|
||||
|
|
Loading…
Reference in New Issue
Block a user