Adding users without cards report, fixing mac registration for existing macs
This commit is contained in:
parent
377170d47c
commit
cad46e45c5
|
@ -9,7 +9,7 @@ rescue_from CanCan::AccessDenied do |exception|
|
|||
redirect_to main_app.root_url, :alert => "Nothing to see here!"
|
||||
end
|
||||
end
|
||||
load_and_authorize_resource :mac
|
||||
load_and_authorize_resource :mac, :except => :create
|
||||
load_and_authorize_resource :user, :through => :mac, :except => [:index, :show, :scan, :import]
|
||||
|
||||
#require "active_record"
|
||||
|
@ -80,26 +80,34 @@ end
|
|||
end
|
||||
|
||||
# POST /macs
|
||||
# POST /user
|
||||
def create
|
||||
@mac = Mac.new(params[:mac])
|
||||
authorize! :update, @mac
|
||||
|
||||
if can? :manage, Mac then
|
||||
@users = User.accessible_by(current_ability).sort_by(&:name)
|
||||
else
|
||||
@users = [current_user]
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
if @mac.save
|
||||
format.html { redirect_to macs_path, :notice => 'Mac was successfully created.' }
|
||||
format.json { render :json => @mac, :status => :created, :location => @mac }
|
||||
@existing_mac = Mac.find_by_mac(@mac.mac)
|
||||
if can? :manage, Mac then
|
||||
@users = User.accessible_by(current_ability).sort_by(&:name)
|
||||
else
|
||||
@users = [current_user]
|
||||
end
|
||||
|
||||
if @existing_mac.present?
|
||||
if @existing_mac.user_id.nil?
|
||||
redirect_to edit_mac_path(@existing_mac), :notice => 'This MAC already exists, edit it here:'
|
||||
else
|
||||
@mac.errors.add(:user,"for this MAC is already set to #{@existing_mac.user.name} -- please contact them or an admin if this is incorrect.")
|
||||
render :action => "new"
|
||||
end
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.json { render :json => @mac.errors, :status => :unprocessable_entity }
|
||||
|
||||
respond_to do |format|
|
||||
if @mac.save
|
||||
format.html { redirect_to macs_path, :notice => 'MAC was successfully created.' }
|
||||
format.json { render :json => @mac, :status => :created, :location => @mac }
|
||||
else
|
||||
format.html { render :action => "new" }
|
||||
format.json { render :json => @mac.errors, :status => :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /macs/1
|
||||
|
@ -119,7 +127,7 @@ end
|
|||
|
||||
respond_to do |format|
|
||||
if @mac.save
|
||||
format.html { redirect_to macs_path, :notice => 'Mac was successfully updated.' }
|
||||
format.html { redirect_to macs_path, :notice => 'MAC was successfully updated.' }
|
||||
format.json { head :no_content }
|
||||
else
|
||||
format.html { render :action => "edit" }
|
||||
|
|
|
@ -42,6 +42,7 @@ class UsersController < ApplicationController
|
|||
def activity
|
||||
@user_logins = User.where(:last_sign_in_at => 1.month.ago..Date.today)
|
||||
@new_users = User.where(:created_at => 3.months.ago..Date.today)
|
||||
@cardless_users = User.includes('cards').where(['users.member_level >= ?','50']).where('cards.id IS NULL')
|
||||
end
|
||||
|
||||
# GET /users/1
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<%= form_for(@mac) do |f| %>
|
||||
<% if @mac.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@mac.errors.count, "error") %> prohibited this Mac from being saved:</h2>
|
||||
<h2><%= pluralize(@mac.errors.count, "error") %> prohibited this MAC from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @mac.errors.full_messages.each do |msg| %>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<h1>Editing Mac</h1>
|
||||
<h1>Editing MAC</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ Rails.logger.info mac.inspect %>
|
|||
<% end %>
|
||||
|
||||
<% if can? :manage, Mac %>
|
||||
<h3>All Macs</h3>
|
||||
<h3>All MACs</h3>
|
||||
<table>
|
||||
<% @all_macs.each do |mac| %>
|
||||
<tr <%= raw('class="hidden"') if mac.hidden? %>>
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<h1>New Mac</h1>
|
||||
<h1>New MAC</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
</p>
|
||||
|
||||
<p>
|
||||
<b>Mac:</b>
|
||||
<b>MAC:</b>
|
||||
<%= @mac.mac %>
|
||||
</p>
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
<h1>Recent User Activity</h1>
|
||||
<h1>Member Onboarding/Activity</h1>
|
||||
<a href="#new_users">New Users</a> |
|
||||
<a href="#members_without_cards">Members Without Cards</a> |
|
||||
<a href="#logins">Logins</a>
|
||||
|
||||
<h2>New Users</h2>
|
||||
|
||||
<h2><a name="new_users"></a>New Users</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
|
@ -42,7 +46,47 @@
|
|||
<% end %>
|
||||
</table>
|
||||
|
||||
<h2>Logins</h2>
|
||||
<h2><a name="members_without_cards"></a>Basic+ Members Without Cards</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Account Created</th>
|
||||
<th>Member Level</th>
|
||||
<th>Payment</th>
|
||||
<th>Card</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
|
||||
<% if !@cardless_users.blank? %>
|
||||
<% @cardless_users.sort_by(&:created_at).reverse!.each do |user| %>
|
||||
<tr<%= " class='hidden'" if user.hidden? %>>
|
||||
<td><%= link_to user.name, user %></td>
|
||||
<td><%= distance_of_time_in_words DateTime.now, user.created_at %> ago</td>
|
||||
<td><%= user.member_level_string %></td>
|
||||
<td><% if user.payments.present? %>
|
||||
<% last_payment = user.payments.maximum(:date) %>
|
||||
<% if Date.today-last_payment > 60 %>
|
||||
<span class="alert">
|
||||
<% else %>
|
||||
<span class="notice">
|
||||
<% end %>
|
||||
<%= distance_of_time_in_words(Date.today, user.payments.maximum(:date))+" ago" %>
|
||||
</span>
|
||||
<% else %>
|
||||
<span class="alert">×</span>
|
||||
<% end %></td>
|
||||
<td><% if user.cards.present? %>
|
||||
<span class="notice">✓</span>
|
||||
<% else %>
|
||||
<span class="alert">×</span>
|
||||
<% end %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</table>
|
||||
|
||||
|
||||
<h2><a name="logins"></a>Logins</h2>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
|
|
Loading…
Reference in New Issue
Block a user