From 125ad76a1ca286e473a05ba4ece0813b5be70954 Mon Sep 17 00:00:00 2001 From: Will Bradley Date: Mon, 26 Aug 2013 22:07:41 -0700 Subject: [PATCH 1/4] Hacks to allow 1.8.7 --- Gemfile | 2 ++ app/controllers/ipns_controller.rb | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index 023493f..921e64e 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,7 @@ source 'https://rubygems.org' +#ruby '1.9.3' + gem 'rails', '3.2.3' # Bundle edge Rails instead: diff --git a/app/controllers/ipns_controller.rb b/app/controllers/ipns_controller.rb index 36a9407..931556a 100644 --- a/app/controllers/ipns_controller.rb +++ b/app/controllers/ipns_controller.rb @@ -1,6 +1,6 @@ class IpnsController < ApplicationController load_and_authorize_resource :ipn, :except => [:new, :create] - before_filter :authenticate_user! + before_filter :authenticate_user!, :except => [:new, :create] protect_from_forgery :except => [:create] @@ -19,9 +19,9 @@ class IpnsController < ApplicationController @ipn.data = params.to_json @ipn.save render :nothing => true - unless @ipn.validate! - Rails.logger.error "Unable to validate IPN: #{@ipn.inspect}" - end + #unless @ipn.validate! + # Rails.logger.error "Unable to validate IPN: #{@ipn.inspect}" + #end end def validate @@ -41,4 +41,4 @@ class IpnsController < ApplicationController end end -end \ No newline at end of file +end From 98be42e9f939634bbfb397b5ce53188aacca6882 Mon Sep 17 00:00:00 2001 From: Will Bradley Date: Mon, 26 Aug 2013 22:11:04 -0700 Subject: [PATCH 2/4] Fixing nil errors --- app/models/user_certification.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/models/user_certification.rb b/app/models/user_certification.rb index 649c48e..54c2891 100644 --- a/app/models/user_certification.rb +++ b/app/models/user_certification.rb @@ -7,6 +7,10 @@ class UserCertification < ActiveRecord::Base belongs_to :certification def user_name - self.user.name unless self.user.blank? + if self.user.blank? + "" + else + self.user.name + end end end From 810ff6b034836afc8da96a2b1539c92cf4068421 Mon Sep 17 00:00:00 2001 From: Will Bradley Date: Mon, 26 Aug 2013 22:32:08 -0700 Subject: [PATCH 3/4] De-duplicating cert view --- app/controllers/user_certifications_controller.rb | 2 +- app/views/certifications/show.html.erb | 11 ++++------- app/views/user_certifications/show.html.erb | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/app/controllers/user_certifications_controller.rb b/app/controllers/user_certifications_controller.rb index 6d222ee..aff149a 100644 --- a/app/controllers/user_certifications_controller.rb +++ b/app/controllers/user_certifications_controller.rb @@ -6,7 +6,7 @@ class UserCertificationsController < ApplicationController # Load users and certs based on current ability before_filter :only => [:new, :edit, :create, :update] do - @users = User.where(:hidden => false).accessible_by(current_ability).sort_by(&:name) + @users = User.where(:hidden => [false,nil]).accessible_by(current_ability).sort_by(&:name) @certifications = Certification.accessible_by(current_ability).sort_by(&:name) end diff --git a/app/views/certifications/show.html.erb b/app/views/certifications/show.html.erb index 272deae..c9fce2b 100644 --- a/app/views/certifications/show.html.erb +++ b/app/views/certifications/show.html.erb @@ -8,13 +8,10 @@ <%= simple_format @certification.description %>

-Certified Users: -
    - <% @certification_users.each do |user| %> -
  • <%= link_to user.name, user %>
  • - <% end %> - <% if @certification_users.blank? then %>
  • n/a
  • <% end %> -
+

+ Certified Users: + <%= link_to "Click Here", user_certifications_path %> +

<% if can? :update, @certification %><%= link_to 'Edit', edit_certification_path(@certification) %> |<% end %> <%= link_to 'Back', certifications_path %> diff --git a/app/views/user_certifications/show.html.erb b/app/views/user_certifications/show.html.erb index d12c3be..66b4b5f 100644 --- a/app/views/user_certifications/show.html.erb +++ b/app/views/user_certifications/show.html.erb @@ -1,6 +1,6 @@

User: - <%= @user_certification.user.name %> + <%= link_to @user_certification.user.name, @user_certification.user %>

From 18bc427eb3dc578756d0980866a84925ad196945 Mon Sep 17 00:00:00 2001 From: Will Bradley Date: Mon, 26 Aug 2013 23:01:43 -0700 Subject: [PATCH 4/4] Adding quick-add buttons to user profiles --- app/assets/stylesheets/application.css | 33 ++++++++++++++++++++ app/models/card.rb | 3 +- app/models/user_certification.rb | 1 + app/views/cards/_form.html.erb | 3 +- app/views/user_certifications/_form.html.erb | 5 +-- app/views/users/show.html.erb | 4 +-- 6 files changed, 43 insertions(+), 6 deletions(-) diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index 38f2c00..43f1ef9 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -12,3 +12,36 @@ *= require_tree . */ .caption { display: inline-block; background-color: #eee; border: 1px solid #333; border-radius: 5px; margin-bottom: 1em; } +.btn { +display: inline-block; +padding: 4px 10px 4px; +margin-bottom: 0; +font-size: 13px; +line-height: 18px; +color: #333; +text-align: center; +text-shadow: 0 1px 1px rgba(255,255,255,.75); +vertical-align: middle; +background-color: #f5f5f5; +background-image: -moz-linear-gradient(top, #fff, #e6e6e6); +background-image: -ms-linear-gradient(top, #fff, #e6e6e6); +background-image: -webkit-gradient(linear,0 0,0 100%,from( #fff),to( #e6e6e6)); +background-image: -webkit-linear-gradient(top, #fff, #e6e6e6); +background-image: -o-linear-gradient(top, #fff, #e6e6e6); +background-image: linear-gradient(top, #fff, #e6e6e6); +background-repeat: repeat-x; +filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#e6e6e6', GradientType=0); +border-color: #e6e6e6 #e6e6e6 #bfbfbf; +border-color: rgba(0,0,0,.1) rgba(0,0,0,.1) rgba(0,0,0,.25); +filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +border: 1px solid #ccc; +border-bottom-color: #bbb; +-webkit-border-radius: 4px; +-moz-border-radius: 4px; +border-radius: 4px; +-webkit-box-shadow: inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05); +-moz-box-shadow: inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05); +box-shadow: inset 0 1px 0 rgba(255,255,255,.2),0 1px 2px rgba(0,0,0,.05); +cursor: pointer; +filter: progid:DXImageTransform.Microsoft.gradient(enabled=false); +} diff --git a/app/models/card.rb b/app/models/card.rb index 1416ac3..700cb3b 100644 --- a/app/models/card.rb +++ b/app/models/card.rb @@ -2,7 +2,8 @@ class Card < ActiveRecord::Base require 'open-uri' attr_accessible :id, :user_id, :name, :card_number, :card_permissions - validates_uniqueness_of :id,:card_number + validates_presence_of :user_id, :card_number, :card_permissions + validates_uniqueness_of :id, :card_number belongs_to :user def upload_to_door diff --git a/app/models/user_certification.rb b/app/models/user_certification.rb index 54c2891..8ae9ddb 100644 --- a/app/models/user_certification.rb +++ b/app/models/user_certification.rb @@ -1,6 +1,7 @@ class UserCertification < ActiveRecord::Base attr_accessible :certification_id, :user_id + validates_presence_of :certification_id, :user_id validates_uniqueness_of :certification_id, :scope => :user_id, :message => 'already exists for this user.' # Makes sure users don't get certified twice belongs_to :user diff --git a/app/views/cards/_form.html.erb b/app/views/cards/_form.html.erb index 3a63ed0..6a14351 100644 --- a/app/views/cards/_form.html.erb +++ b/app/views/cards/_form.html.erb @@ -11,9 +11,10 @@ <% end %> + <% @card.user_id = params[:user] if params[:user].present? %>

<%= f.label :user %>
- <%= collection_select(:card, :user_id, User.all.sort_by(&:name), :id, :name) %> + <%= collection_select(:card, :user_id, User.all.sort_by(&:name), :id, :name, :include_blank => true) %>
<%= f.label :name, "Card Note" %>
diff --git a/app/views/user_certifications/_form.html.erb b/app/views/user_certifications/_form.html.erb index 919e8e5..cf571f6 100644 --- a/app/views/user_certifications/_form.html.erb +++ b/app/views/user_certifications/_form.html.erb @@ -11,13 +11,14 @@
<% end %> + <% @user_certification.user_id = params[:user] if params[:user].present? %>
<%= f.label :user_id, "User" %>
- <%= collection_select(:user_certification, :user_id, @users, :id, :name) %> + <%= collection_select(:user_certification, :user_id, @users, :id, :name, :include_blank => true) %>
<%= f.label :certification_id, "Certification" %>
- <%= collection_select(:user_certification, :certification_id, @certifications, :id, :name) %> + <%= collection_select(:user_certification, :certification_id, @certifications, :id, :name, :include_blank => true) %>
<%= f.submit %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 5d2e308..eaa42c7 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -74,7 +74,7 @@

<% end %>

- Card: + Card:<%= link_to "+ Add", (new_card_path+"?user="+@user.id.to_s), :class => 'btn' if can? :create, Card %> <% if current_user.admin? then %> <% @user.cards.each do |c| %> <%= link_to c.card_number, c %><%= "," unless c == @user.cards.last %> @@ -84,7 +84,7 @@ <% end %>

-Certifications: +Certifications:<%= link_to "+ Add", (new_user_certification_path+"?user="+@user.id.to_s), :class => 'btn' if can? :create, UserCertification %>
    <% @user.certifications.each do |certification| %>
  • <%= link_to certification.name, certification %>