Skip to content

Commit

Permalink
Merge branch 'new-features' into wristband-dist
Browse files Browse the repository at this point in the history
  • Loading branch information
sclark authored Mar 28, 2017
2 parents 2091498 + de1891d commit fd0a0d8
Show file tree
Hide file tree
Showing 28 changed files with 417 additions and 377 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ rvm:
bundler_args: --without development staging production
sudo: false
before_script:
- bundle exec rake db:test:prepare
- bundle exec rake db:migrate RAILS_ENV=test
- bundle exec rake test:prepare
- bundle exec rake db:migrate
1 change: 1 addition & 0 deletions app/controllers/checkouts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class CheckoutsController < ApplicationController
def index
@tool = Tool.find(params[:tool_id])
@checkouts = @tool.checkouts
authorize! :read, @checkouts

respond_to do |format|
format.html # index.html.erb
Expand Down
1 change: 1 addition & 0 deletions app/controllers/faqs_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ class FaqsController < ApplicationController
# GET /faqs.json
def index
@faqs = Faq.all
authorize! :read, @faqs
end

# GET /faqs/new
Expand Down
19 changes: 14 additions & 5 deletions app/controllers/waivers_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,12 @@ def new

if @user.has_signed_waiver
flash[:notice] = "You have already agreed to the release."
else
@user.start_waiver_timer
end


@should_see_video = !@user.is_scc?

end


Expand All @@ -21,16 +25,21 @@ def create
else
@participant = Participant.find params[:participant_id]
end


if params[:adult].blank?

if @participant.is_waiver_cheater?
@participant.start_waiver_timer
redirect_to '/cheating.html'
elsif params[:adult].blank?
flash[:error] = "You must be 18 or older to sign the electronic waiver. Please contact Andrew Greenwald (<a target='_blank' href='mailto:[email protected]'>[email protected]</a>)."
redirect_to action: :new
elsif params[:agree].blank?
flash[:error] = "You must agree to the terms of the release."
redirect_to action: :new
elsif params[:phone_number] == ""
flash[:error] = "You must provide a mobile phone number"
flash[:error] = "You must provide a mobile phone number."
redirect_to action: :new
elsif params[:signature] != @participant.name
flash[:error] = "You must electronically sign the waiver with your full name as it appears on the waiver."
redirect_to action: :new
else
@participant.phone_number = params[:phone_number]
Expand Down
10 changes: 10 additions & 0 deletions app/models/participant.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
# **`phone_number`** | `string(255)` |
# **`updated_at`** | `datetime` |
# **`user_id`** | `integer` |
# **`waiver_start`** | `datetime` |
#
# ### Indexes
#
Expand Down Expand Up @@ -49,6 +50,15 @@ class Participant < ActiveRecord::Base
scope :search, lambda { |term| where('lower(andrewid) LIKE lower(?) OR lower(cached_name) LIKE lower(?)', "%#{term}%", "%#{term}%") }
scope :scc, -> { joins(:organizations).where(organizations: {name: 'Spring Carnival Committee'}) }

def start_waiver_timer
self.waiver_start = DateTime.now
self.save
end

def is_waiver_cheater?
(self.waiver_start + 3.minutes + 37.seconds) > DateTime.now
end

def is_booth_chair?
!memberships.booth_chairs.blank?
end
Expand Down
2 changes: 1 addition & 1 deletion app/models/store_item.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# **`created_at`** | `datetime` | `not null`
# **`id`** | `integer` | `not null, primary key`
# **`name`** | `string(255)` |
# **`price`** | `decimal(10, )` |
# **`price`** | `decimal(8, 2)` |
# **`quantity`** | `integer` |
# **`updated_at`** | `datetime` | `not null`
#
Expand Down
2 changes: 1 addition & 1 deletion app/models/store_purchase.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# **`charge_id`** | `integer` |
# **`created_at`** | `datetime` | `not null`
# **`id`** | `integer` | `not null, primary key`
# **`price_at_purchase`** | `decimal(10, )` |
# **`price_at_purchase`** | `decimal(8, 2)` |
# **`quantity_purchased`** | `integer` |
# **`store_item_id`** | `integer` |
# **`updated_at`** | `datetime` | `not null`
Expand Down
14 changes: 5 additions & 9 deletions app/views/charges/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<% if can?(:update, @charge) %>
<%- model_class = Charge -%>
<div class="page-header">
<h1><%=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human %></h1>
</div>
<%- model_class = Charge -%>
<div class="page-header">
<h1><%=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human %></h1>
</div>

<%= render 'form' %>
<%= render 'form' %>

<% else %>
<h3>Not Authorized!</h3>
<% end %>

14 changes: 5 additions & 9 deletions app/views/charges/new.html.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
<% if can?(:create, @charge) %>
<%- model_class = Charge -%>
<div class="page-header">
<h1><%=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human %></h1>
</div>
<%- model_class = Charge -%>
<div class="page-header">
<h1><%=t '.title', :default => [:'helpers.titles.new', 'New %{model}'], :model => model_class.model_name.human %></h1>
</div>

<%= render 'form' %>
<%= render 'form' %>

<% else %>
<h3>Not Authorized!</h3>
<% end %>

95 changes: 45 additions & 50 deletions app/views/charges/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,58 +1,53 @@
<% if can?(:read, @charge) %>
<%- model_class = Charge -%>
<div class="page-header">
<h1 <%= raw('class="text-muted"') unless @charge.is_approved? %>><%= @charge.charge_type.name %></h1>
</div>
<%- model_class = Charge -%>
<div class="page-header">
<h1 <%= raw('class="text-muted"') unless @charge.is_approved? %>><%= @charge.charge_type.name %></h1>
</div>

<dl class="dl-horizontal">
<dt><strong><%= model_class.human_attribute_name(:description) %>:</strong></dt>
<dd><%= @charge.description %></dd>
<dt><strong><%= model_class.human_attribute_name(:amount) %>:</strong></dt>
<dd><%= number_to_currency @charge.amount %></dd>
<dt><strong><%= model_class.human_attribute_name(:organization) %>:</strong></dt>
<dd><%= link_to @charge.organization.name, @charge.organization %></dd>
<dt><strong><%= model_class.human_attribute_name(:issuing_participant) %>:</strong></dt>
<dd><%= link_to @charge.issuing_participant.formatted_name, @charge.issuing_participant %></dd>
<dt><strong><%= model_class.human_attribute_name(:receiving_participant) %>:</strong></dt>
<dd><%= link_to @charge.receiving_participant.formatted_name, @charge.receiving_participant unless @charge.receiving_participant.nil? %></dd>
<dt><strong><%= model_class.human_attribute_name(:charged_at) %>:</strong></dt>
<dd><%= date_and_time @charge.charged_at %></dd>
<dt><strong><%= model_class.human_attribute_name(:is_approved) %></strong></dt>
<dd><%= format_boolean @charge.is_approved %></dd>
</dl>
<dl class="dl-horizontal">
<dt><strong><%= model_class.human_attribute_name(:description) %>:</strong></dt>
<dd><%= @charge.description %></dd>
<dt><strong><%= model_class.human_attribute_name(:amount) %>:</strong></dt>
<dd><%= number_to_currency @charge.amount %></dd>
<dt><strong><%= model_class.human_attribute_name(:organization) %>:</strong></dt>
<dd><%= link_to @charge.organization.name, @charge.organization %></dd>
<dt><strong><%= model_class.human_attribute_name(:issuing_participant) %>:</strong></dt>
<dd><%= link_to @charge.issuing_participant.formatted_name, @charge.issuing_participant %></dd>
<dt><strong><%= model_class.human_attribute_name(:receiving_participant) %>:</strong></dt>
<dd><%= link_to @charge.receiving_participant.formatted_name, @charge.receiving_participant unless @charge.receiving_participant.nil? %></dd>
<dt><strong><%= model_class.human_attribute_name(:charged_at) %>:</strong></dt>
<dd><%= date_and_time @charge.charged_at %></dd>
<dt><strong><%= model_class.human_attribute_name(:is_approved) %></strong></dt>
<dd><%= format_boolean @charge.is_approved %></dd>
</dl>

<div class="form-actions">
<div class="form-actions">
<%= link_to t('.back', :default => t("helpers.links.back")),
charges_path, :class => 'btn btn-default' %>

<% if can?(:approve, Charge) %>
<% unless @charge.is_approved? %>
<%= form_tag approve_charge_path(@charge), method: :put, style: "display: inline;", role: "form" do -%>
<%= hidden_field_tag 'url', request.original_fullpath %>
<%= submit_tag 'Approve', :class => 'btn btn-success', :type => 'submit' %>
<% end -%>
<% else %>
<%= form_tag approve_charge_path(@charge), method: :put, style: "display: inline;", role: "form" do -%>
<%= hidden_field_tag 'url', request.original_fullpath %>
<%= submit_tag 'Un-Approve', :class => 'btn btn-danger', :type => 'submit' %>
<% end -%>
<% end %>
<% if can?(:approve, Charge) %>
<% unless @charge.is_approved? %>
<%= form_tag approve_charge_path(@charge), method: :put, style: "display: inline;", role: "form" do -%>
<%= hidden_field_tag 'url', request.original_fullpath %>
<%= submit_tag 'Approve', :class => 'btn btn-success', :type => 'submit' %>
<% end -%>
<% else %>
<%= form_tag approve_charge_path(@charge), method: :put, style: "display: inline;", role: "form" do -%>
<%= hidden_field_tag 'url', request.original_fullpath %>
<%= submit_tag 'Un-Approve', :class => 'btn btn-danger', :type => 'submit' %>
<% end -%>
<% end %>
<% end %>

<% if can?(:update, @charge) %>
<%= link_to t('.edit', :default => t("helpers.links.edit")),
edit_charge_path(@charge), :class => 'btn btn-primary' %>
<% end %>
<% if can?(:update, @charge) %>
<%= link_to t('.edit', :default => t("helpers.links.edit")),
edit_charge_path(@charge), :class => 'btn btn-primary' %>
<% end %>

<% if can?(:destroy, @charge) %>
<%= link_to t('.destroy', :default => t("helpers.links.destroy")),
charge_path(@charge),
:method => 'delete',
:data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
:class => 'btn btn-danger' %>
<% end %>
</div>

<% else %>
<h3>Not Authorized!</h3>
<% end %>
<% if can?(:destroy, @charge) %>
<%= link_to t('.destroy', :default => t("helpers.links.destroy")),
charge_path(@charge),
:method => 'delete',
:data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
:class => 'btn btn-danger' %>
<% end %>
</div>
61 changes: 29 additions & 32 deletions app/views/checkouts/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
<% if can?(:read, Checkout) %>
<%- model_class = Checkout -%>
<div class="page-header">
<h1><%=t '.title', :default => model_class.model_name.human.pluralize %></h1>
</div>
<table class="table table-striped">
<thead>
<tr>
<th><%= model_class.human_attribute_name(:id) %></th>
<th><%= model_class.human_attribute_name(:tool) %></th>
<th><%= model_class.human_attribute_name(:checked_out_at) %></th>
<th><%= model_class.human_attribute_name(:checked_in_at) %></th>
<th><%= model_class.human_attribute_name(:participant_id) %></th>
<th><%= model_class.human_attribute_name(:organization_id) %></th>
<%- model_class = Checkout -%>
<div class="page-header">
<h1><%=t '.title', :default => model_class.model_name.human.pluralize %></h1>
</div>
<table class="table table-striped">
<thead>
<tr>
<th><%= model_class.human_attribute_name(:id) %></th>
<th><%= model_class.human_attribute_name(:tool) %></th>
<th><%= model_class.human_attribute_name(:checked_out_at) %></th>
<th><%= model_class.human_attribute_name(:checked_in_at) %></th>
<th><%= model_class.human_attribute_name(:participant_id) %></th>
<th><%= model_class.human_attribute_name(:organization_id) %></th>
</tr>
</thead>
<tbody>
<% @checkouts.each do |checkout| %>
<% if can?(:read, checkout) %>
<tr>
<td><%= checkout.id %></td>
<td><%= checkout.tool.name %></td>
<td><%= date_and_time(checkout.checked_out_at) unless checkout.checked_out_at.nil? %></td>
<td><%= date_and_time(checkout.checked_in_at) unless checkout.checked_in_at.nil? %></td>
<td><%= checkout.participant.andrewid unless checkout.participant.nil? %></td>
<td><%= checkout.organization.name unless checkout.organization.nil?%></td>
</tr>
<% end %>
</thead>
<tbody>
<% @checkouts.each do |checkout| %>
<% if can?(:read, checkout) %>
<tr>
<td><%= checkout.id %></td>
<td><%= checkout.tool.name %></td>
<td><%= date_and_time(checkout.checked_out_at) unless checkout.checked_out_at.nil? %></td>
<td><%= date_and_time(checkout.checked_in_at) unless checkout.checked_in_at.nil? %></td>
<td><%= checkout.participant.andrewid unless checkout.participant.nil? %></td>
<td><%= checkout.organization.name unless checkout.organization.nil?%></td>
</tr>
<% end %>
</tbody>
</table>
<% else %>
<h3>Not Authorized!</h3>
<% end %>
<% end %>
</tbody>
</table>


14 changes: 5 additions & 9 deletions app/views/documents/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
<% if can?(:update, @document) %>
<%- model_class = Document -%>
<div class="page-header">
<h1><%=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human %></h1>
</div>
<%- model_class = Document -%>
<div class="page-header">
<h1><%=t '.title', :default => [:'helpers.titles.edit', 'Edit %{model}'], :model => model_class.model_name.human %></h1>
</div>

<%= render 'form' %>
<%= render 'form' %>

<% else %>
<h3>Not Authorized!</h3>
<% end %>
Loading

0 comments on commit fd0a0d8

Please sign in to comment.