Updating styling, fixing some errors, and adding cert logging

This commit is contained in:
Will Bradley 2013-01-25 06:52:19 -07:00
parent 653fcc3112
commit 63b1b05010
10 changed files with 63 additions and 9 deletions

View File

@ -11,3 +11,9 @@
*= require_self *= require_self
*= require_tree . *= require_tree .
*/ */
table { border-spacing: 0; }
td, th { padding: 0.5em; }
.col_highlight { background-color: #ccc; }
dt { font-weight: bold; }
.notice { color: green; }
.alert { color: red; }

View File

@ -4,6 +4,11 @@ class UserCertificationsController < ApplicationController
load_and_authorize_resource :certification, :through => :user_certification load_and_authorize_resource :certification, :through => :user_certification
before_filter :authenticate_user! before_filter :authenticate_user!
# Load users and certs based on current ability
before_filter :only => [:new, :edit, :create, :update] do
@users = User.accessible_by(current_ability).sort_by(&:name)
@certifications = Certification.accessible_by(current_ability).sort_by(&:name)
end
# GET /user_certifications # GET /user_certifications
# GET /user_certifications.json # GET /user_certifications.json
@ -19,6 +24,9 @@ class UserCertificationsController < ApplicationController
# GET /user_certifications/1 # GET /user_certifications/1
# GET /user_certifications/1.json # GET /user_certifications/1.json
def show def show
@created_by = User.find(@user_certification.created_by) unless @user_certification.created_by.blank?
@updated_by = User.find(@user_certification.updated_by) unless @user_certification.updated_by.blank?
respond_to do |format| respond_to do |format|
format.html # show.html.erb format.html # show.html.erb
format.json { render :json => @user_certification } format.json { render :json => @user_certification }
@ -28,8 +36,6 @@ class UserCertificationsController < ApplicationController
# GET /user_certifications/new # GET /user_certifications/new
# GET /user_certifications/new.json # GET /user_certifications/new.json
def new def new
@users = User.accessible_by(current_ability).sort_by(&:name)
@certifications = Certification.accessible_by(current_ability).sort_by(&:name)
respond_to do |format| respond_to do |format|
format.html # new.html.erb format.html # new.html.erb
@ -44,6 +50,9 @@ class UserCertificationsController < ApplicationController
# POST /user_certifications # POST /user_certifications
# POST /user_certifications.json # POST /user_certifications.json
def create def create
#Log who created this
@user_certification.created_by = current_user.id
respond_to do |format| respond_to do |format|
if @user_certification.save if @user_certification.save
format.html { redirect_to UserCertification, :notice => 'User certification was successfully created.' } format.html { redirect_to UserCertification, :notice => 'User certification was successfully created.' }
@ -58,6 +67,9 @@ class UserCertificationsController < ApplicationController
# PUT /user_certifications/1 # PUT /user_certifications/1
# PUT /user_certifications/1.json # PUT /user_certifications/1.json
def update def update
#Log who updated this
@user_certification.updated_by = current_user.id
respond_to do |format| respond_to do |format|
if @user_certification.update_attributes(params[:user_certification]) if @user_certification.update_attributes(params[:user_certification])
format.html { redirect_to UserCertification, :notice => 'User certification was successfully updated.' } format.html { redirect_to UserCertification, :notice => 'User certification was successfully updated.' }

View File

@ -3,6 +3,11 @@
<%= link_to 'New Card', new_card_path if can? :create, Card %> <%= link_to 'New Card', new_card_path if can? :create, Card %>
<%= link_to 'Upload all cards', upload_all_path if can? :upload_all, Card %> <%= link_to 'Upload all cards', upload_all_path if can? :upload_all, Card %>
<table> <table>
<col />
<col />
<col class="col_highlight" />
<col />
<col class="col_highlight" />
<tr> <tr>
<th>User</th> <th>User</th>
<th>Note</th> <th>Note</th>

View File

@ -17,6 +17,7 @@
<%= link_to 'Certifications', certifications_path if can? :read, Certification %> <%= link_to 'Certifications', certifications_path if can? :read, Certification %>
<% end %> <% end %>
<%= link_to 'Logs', door_logs_path if can? :read, DoorLog %> <%= link_to 'Logs', door_logs_path if can? :read, DoorLog %>
<% if user_signed_in? then %><%= link_to 'Profile', edit_user_registration_path %><% end %>
<%= link_to 'Sign out', destroy_user_session_path, :method => :delete if user_signed_in? %> <%= link_to 'Sign out', destroy_user_session_path, :method => :delete if user_signed_in? %>
<%= link_to 'Sign in', new_user_session_path unless user_signed_in? %> <%= link_to 'Sign in', new_user_session_path unless user_signed_in? %>
</div> </div>

View File

@ -8,6 +8,15 @@
<%= @user_certification.certification.name %> <%= @user_certification.certification.name %>
</p> </p>
<p>
<b>Created:</b> by <%= link_to @created_by.name, @created_by unless @created_by.blank? %>
at <%= @user_certification.created_at %>
</p>
<p>
<b>Updated:</b> by <%= link_to @updated_by.name, @updated_by unless @updated_by.blank? %>
at <%= @user_certification.updated_at %>
</p>
<%= link_to 'Edit', edit_user_certification_path(@user_certification) %> | <%= link_to 'Edit', edit_user_certification_path(@user_certification) %> |
<%= link_to 'Back', user_certifications_path %> <%= link_to 'Back', user_certifications_path %>

View File

@ -4,6 +4,15 @@
<%= link_to 'New User', new_user_path %> <%= link_to 'New User', new_user_path %>
<% end %> <% end %>
<table> <table>
<col />
<col />
<col />
<% if current_user.admin? %><col /><% end %>
<col class="col_highlight" />
<col />
<col class="col_highlight" />
<col />
<col class="col_highlight" />
<tr> <tr>
<th>Name</th> <th>Name</th>
<th>Email</th> <th>Email</th>

View File

@ -11,29 +11,29 @@
<p> <p>
<b>Waiver?</b> <b>Waiver?</b>
<%= @user.waiver %> <%= @user.waiver.strftime("%B %d %Y") unless @user.waiver.blank? %>
</p> </p>
<% if current_user.admin? then %> <% if current_user.admin? then %>
<p> <p>
<b>Orientation?</b> <b>Orientation?</b>
<%= @user.orientation %> <%= @user.orientation.strftime("%B %d %Y") unless @user.orientation.blank? %>
</p> </p>
<% end %> <% end %>
<p> <p>
<b>Member?</b> <b>Member?</b>
<%= @user.member %> <%= raw(@user.member_status) %>
</p> </p>
<p> <p>
<b>Instructor?</b> <b>Instructor?</b>
<%= @user.instructor %> <%= @user.instructor? %>
</p> </p>
<p> <p>
<b>Admin?</b> <b>Admin?</b>
<%= @user.admin %> <%= @user.admin? %>
</p> </p>
<% if current_user.admin? then %> <% if current_user.admin? then %>
@ -53,5 +53,5 @@
<% if @user.certifications.blank? %><li>n/a</li><% end %> <% if @user.certifications.blank? %><li>n/a</li><% end %>
</ul> </ul>
<%= link_to 'Edit', edit_user_path(@user) %> | <% if can? :update, @user then %><%= link_to 'Edit', edit_user_path(@user) %> |<% end %>
<%= link_to 'Back', users_path %> <%= link_to 'Back', users_path %>

View File

@ -0,0 +1,5 @@
class AddUpdatedByToUserCertifications < ActiveRecord::Migration
def change
add_column :user_certifications, :updated_by, :integer
end
end

View File

@ -0,0 +1,5 @@
class AddCreatedByToUserCertifications < ActiveRecord::Migration
def change
add_column :user_certifications, :created_by, :integer
end
end

View File

@ -10,7 +10,7 @@
# #
# It's strongly recommended to check this file into your version control system. # It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20130125124102) do ActiveRecord::Schema.define(:version => 20130125133237) do
create_table "cards", :force => true do |t| create_table "cards", :force => true do |t|
t.string "card_number" t.string "card_number"
@ -40,6 +40,8 @@ ActiveRecord::Schema.define(:version => 20130125124102) do
t.integer "certification_id" t.integer "certification_id"
t.datetime "created_at", :null => false t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false t.datetime "updated_at", :null => false
t.integer "updated_by"
t.integer "created_by"
end end
create_table "users", :force => true do |t| create_table "users", :force => true do |t|