Skip to content
This repository has been archived by the owner on Jul 24, 2020. It is now read-only.

Commit

Permalink
Merge pull request #1194 from YaleSTC/temp
Browse files Browse the repository at this point in the history
resolves #1081
  • Loading branch information
orenyk committed Mar 23, 2015
2 parents 6d20470 + 0700a2f commit cc77989
Show file tree
Hide file tree
Showing 77 changed files with 1,031 additions and 1,033 deletions.
40 changes: 20 additions & 20 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ GEM
ast (2.0.0)
astrolabe (1.3.0)
parser (>= 2.2.0.pre.3, < 3.0)
autoprefixer-rails (5.0.0.3)
autoprefixer-rails (5.1.7)
execjs
json
awesome_print (1.6.1)
Expand Down Expand Up @@ -80,7 +80,7 @@ GEM
cocaine (0.5.5)
climate_control (>= 0.0.3, < 1.0)
cocoon (1.2.6)
codeclimate-test-reporter (0.4.6)
codeclimate-test-reporter (0.4.7)
simplecov (>= 0.7.1, < 1.0.0)
coderay (1.1.0)
coffee-rails (4.1.0)
Expand Down Expand Up @@ -122,7 +122,7 @@ GEM
eventmachine (>= 0.12.9)
http_parser.rb (~> 0.6.0)
erubis (2.7.0)
eventmachine (1.0.3)
eventmachine (1.0.7)
execjs (2.3.0)
factory_girl (4.5.0)
activesupport (>= 3.0.0)
Expand All @@ -139,7 +139,7 @@ GEM
fuubar (2.0.0)
rspec (~> 3.0)
ruby-progressbar (~> 1.4)
guard (2.12.1)
guard (2.12.4)
formatador (>= 0.2.4)
listen (~> 2.7)
lumberjack (~> 1.0)
Expand Down Expand Up @@ -196,7 +196,7 @@ GEM
mime-types (>= 1.16, < 3)
method_source (0.8.2)
mime-types (2.4.3)
mini_portile (0.6.0)
mini_portile (0.6.2)
minitest (5.5.1)
multi_json (1.10.1)
multipart-post (2.0.0)
Expand All @@ -210,12 +210,12 @@ GEM
nilify_blanks (1.2.0)
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
nokogiri (1.6.3.1)
mini_portile (= 0.6.0)
notiffany (0.0.5)
nokogiri (1.6.6.2)
mini_portile (~> 0.6.0)
notiffany (0.0.6)
nenv (~> 0.1)
shellany (~> 0.0)
octokit (3.7.1)
octokit (3.8.0)
sawyer (~> 0.6.0, >= 0.5.3)
orm_adapter (0.5.0)
paperclip (4.2.1)
Expand Down Expand Up @@ -247,7 +247,7 @@ GEM
binding_of_caller (>= 0.7)
pry (>= 0.9.11)
rack (1.5.2)
rack-mini-profiler (0.9.2)
rack-mini-profiler (0.9.3)
rack (>= 1.1.3)
rack-pjax (0.8.0)
nokogiri (~> 1.5)
Expand Down Expand Up @@ -309,23 +309,23 @@ GEM
rspec-core (~> 3.2.0)
rspec-expectations (~> 3.2.0)
rspec-mocks (~> 3.2.0)
rspec-core (3.2.0)
rspec-core (3.2.1)
rspec-support (~> 3.2.0)
rspec-expectations (3.2.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-mocks (3.2.0)
rspec-mocks (3.2.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.2.0)
rspec-rails (3.2.0)
actionpack (>= 3.0, <= 4.2)
activesupport (>= 3.0, <= 4.2)
railties (>= 3.0, <= 4.2)
rspec-rails (3.2.1)
actionpack (>= 3.0, < 4.3)
activesupport (>= 3.0, < 4.3)
railties (>= 3.0, < 4.3)
rspec-core (~> 3.2.0)
rspec-expectations (~> 3.2.0)
rspec-mocks (~> 3.2.0)
rspec-support (~> 3.2.0)
rspec-support (3.2.1)
rspec-support (3.2.2)
rubocop (0.29.1)
astrolabe (~> 1.3)
parser (>= 2.2.0.1, < 3.0)
Expand All @@ -336,7 +336,7 @@ GEM
rubycas-client (2.3.9)
activesupport
safe_yaml (1.0.4)
sass (3.4.12)
sass (3.4.13)
sass-rails (5.0.1)
railties (>= 4.0.0, < 5.0)
sass (~> 3.1)
Expand All @@ -360,7 +360,7 @@ GEM
simplecov-html (~> 0.9.0)
simplecov-html (0.9.0)
slop (3.6.0)
spring (1.3.2)
spring (1.3.3)
spring-commands-rspec (1.0.4)
spring (>= 0.9.1)
sprockets (2.12.3)
Expand Down Expand Up @@ -390,7 +390,7 @@ GEM
hitimes
tzinfo (1.2.2)
thread_safe (~> 0.1)
uglifier (2.7.0)
uglifier (2.7.1)
execjs (>= 0.3.0)
json (>= 1.8.0)
unicorn (4.8.3)
Expand Down
8 changes: 4 additions & 4 deletions app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,13 +177,13 @@ $(document).ready(function() {
$('select#equipment_model_category_id').select2();
$('select#equipment_model_associated_equipment_model_ids').select2();
$('select#equipment_model_requirements').select2();
$('select#equipment_object_equipment_model_id').select2();
$('select#equipment_item_equipment_model_id').select2();
$('select#requirement_equipment_model').select2();
$('select.dropdown.dropselect').select2();

// Popup confirmation when editing reservation equipment objects
$('.reservation_eq_objects').on('change', function() {
newMsg = ($('.select2-choice > .select2-chosen').text() == $('#equipment_object').attr('placeholder'))
// Popup confirmation when editing reservation equipment items
$('.reservation_eq_items').on('change', function() {
newMsg = ($('.select2-choice > .select2-chosen').text() == $('#equipment_item').attr('placeholder'))
? ""
: "Be aware that changing the reservation equipment item may have an effect on another reservation. If you set this reservation's equipment item to an item that has already been checked out, the reservations will be swapped.";
$('input[type="submit"]').data('confirm', newMsg);
Expand Down
6 changes: 3 additions & 3 deletions app/assets/javascripts/deactivation.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function handleDeactivation(e, reservation_id, overbooked) {
}
if (confirmCheckedOut == true && confirmOverbooked == true) {
var reason = prompt("Write down the reason for deactivation of this " +
"equipment object.")
"equipment item.")
if (reason == null) {
e.href += "?deactivation_cancelled=1"
} else if (reason != "") {
Expand All @@ -28,10 +28,10 @@ function handleDeactivation(e, reservation_id, overbooked) {
}
};

function handleBigDeactivation(e, res_count, object_str) {
function handleBigDeactivation(e, res_count, item_str) {
if (arguments.length > 1 && res_count > 0) {
var confirmDeactivation = confirm("There is/are currently " +
res_count + " reservation(s) for this " + object_str + " over the " +
res_count + " reservation(s) for this " + item_str + " over the " +
"coming week. Are you sure you want to continue?")
} else {
confirmDeactivation = true
Expand Down
Empty file modified app/assets/stylesheets/blackouts/_new_recurring.css.scss
100644 → 100755
Empty file.
18 changes: 9 additions & 9 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ def prepare_catalog_index_vars(eq_models = nil)
id_array << em.id
end

# 1 query to grab all the active related equipment objects
eq_objects = EquipmentObject.active.where(equipment_model_id: id_array).all
# 1 query to grab all the active related equipment items
eq_items = EquipmentItem.active.where(equipment_model_id: id_array).all

# 1 query to grab all the related reservations
source_reservations =
Expand All @@ -231,7 +231,7 @@ def prepare_catalog_index_vars(eq_models = nil)
# build the hash using class methods that use 0 queries
eq_models.each do |em|
@availability_hash[em.id] =
[EquipmentObject.for_eq_model(em.id, eq_objects)\
[EquipmentItem.for_eq_model(em.id, eq_items)\
- Reservation.number_overdue_for_eq_model(em.id, source_reservations)\
- em.num_reserved(cart.start_date, cart.due_date, source_reservations)\
- cart.items[em.id].to_i, 0].max
Expand Down Expand Up @@ -260,22 +260,22 @@ def terms_of_service
# activate and deactivate are overridden in the users controller because
# users are activated and deactivated differently
def deactivate
authorize! :deactivate, :objects
# Finds the current model (EM, EO, Category)
@objects_class2 =
authorize! :deactivate, :items
# Finds the current model (EM, EI, Category)
@items_class2 =
params[:controller].singularize.titleize.delete(' ')
.constantize.find(params[:id])
# Deactivate the model you had originally intended to deactivate
@objects_class2.destroy
@items_class2.destroy
flash[:notice] = 'Successfully deactivated '\
+ params[:controller].singularize.titleize\
+ '. Any related equipment has been deactivated as well.'
redirect_to request.referer # Or use redirect_to(back).
end

def activate
authorize! :activate, :objects
# Finds the current model (EM, EO, Category)
authorize! :activate, :items
# Finds the current model (EM, EI, Category)
@model_to_activate =
params[:controller].singularize.titleize.delete(' ')
.constantize.find(params[:id])
Expand Down
4 changes: 2 additions & 2 deletions app/controllers/catalog_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def search
@equipment_model_results =
EquipmentModel.active.catalog_search(params[:query])
@category_results = Category.catalog_search(params[:query])
@equipment_object_results =
EquipmentObject.catalog_search(params[:query])
@equipment_item_results =
EquipmentItem.catalog_search(params[:query])
prepare_catalog_index_vars(@equipment_model_results)
render('search_results') && return
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class EquipmentObjectsController < ApplicationController
class EquipmentItemsController < ApplicationController
load_and_authorize_resource
decorates_assigned :equipment_object
before_action :set_current_equipment_object,
decorates_assigned :equipment_item
before_action :set_current_equipment_item,
only: [:show, :edit, :update, :destroy, :deactivate,
:activate]
before_action :set_equipment_model_if_possible, only: [:index, :new]
Expand All @@ -10,8 +10,8 @@ class EquipmentObjectsController < ApplicationController

# ---------- before filter methods ---------- #

def set_current_equipment_object
@equipment_object = EquipmentObject.find(params[:id])
def set_current_equipment_item
@equipment_item = EquipmentItem.find(params[:id])
end

def set_equipment_model_if_possible
Expand All @@ -24,27 +24,27 @@ def set_equipment_model_if_possible
def index
method = params[:show_deleted] ? :all : :active
if @equipment_model
@equipment_objects = @equipment_model.equipment_objects.send(method)
@equipment_items = @equipment_model.equipment_items.send(method)
else
@equipment_objects = EquipmentObject.send(method)
@equipment_items = EquipmentItem.send(method)
end
end

def show
end

def new
@equipment_object = EquipmentObject.new(equipment_model: @equipment_model)
@equipment_item = EquipmentItem.new(equipment_model: @equipment_model)
end

def create
@equipment_object = EquipmentObject.new(equipment_object_params)
@equipment_object.notes = "#### Created at #{Time.zone.now.to_s(:long)} "\
@equipment_item = EquipmentItem.new(equipment_item_params)
@equipment_item.notes = "#### Created at #{Time.zone.now.to_s(:long)} "\
"by #{current_user.md_link}."
if @equipment_object.save
flash[:notice] = 'Successfully created equipment object. '\
"#{@equipment_object.serial}"
redirect_to @equipment_object.equipment_model
if @equipment_item.save
flash[:notice] = 'Successfully created equipment item. '\
"#{@equipment_item.serial}"
redirect_to @equipment_item.equipment_model
else
render action: 'new'
end
Expand All @@ -54,15 +54,15 @@ def edit
end

def update
p = equipment_object_params
p = equipment_item_params
if p[:deleted_at].blank?
# Delete deactivation reason when "Disabled?" is toggled
p[:deactivation_reason] = ''
end
@equipment_object.update(current_user, p)
if @equipment_object.save
flash[:notice] = 'Successfully updated equipment object.'
redirect_to @equipment_object
@equipment_item.update(current_user, p)
if @equipment_item.save
flash[:notice] = 'Successfully updated equipment item.'
redirect_to @equipment_item
else
render action: 'edit'
end
Expand All @@ -74,39 +74,39 @@ def deactivate # rubocop:disable MethodLength, AbcSize
# update notes and deactivate
new_notes = "#### Deactivated at #{Time.zone.now.to_s(:long)} by "\
"#{current_user.md_link}\n#{params[:deactivation_reason]}\n\n"\
+ @equipment_object.notes
@equipment_object.update_attributes(
+ @equipment_item.notes
@equipment_item.update_attributes(
deactivation_reason: params[:deactivation_reason],
notes: new_notes)
# archive current reservation if any
if @equipment_object.current_reservation
@equipment_object.current_reservation.archive(
if @equipment_item.current_reservation
@equipment_item.current_reservation.archive(
current_user,
'The equipment item was deactivated for the following reason: '\
"**#{params[:deactivation_reason]}**").save(validate: false)
end
super
elsif params[:deactivation_cancelled]
flash[:notice] = 'Deactivation cancelled.'
redirect_to @equipment_object.equipment_model
redirect_to @equipment_item.equipment_model
else
flash[:error] = 'Please enter a deactivation reason.'
redirect_to @equipment_object.equipment_model
redirect_to @equipment_item.equipment_model
end
end

def activate
super
new_notes = "#### Reactivated at #{Time.zone.now.to_s(:long)} by "\
"#{current_user.md_link}\n\n" + @equipment_object.notes
@equipment_object.update_attributes(deactivation_reason: nil,
notes: new_notes)
"#{current_user.md_link}\n\n" + @equipment_item.notes
@equipment_item.update_attributes(deactivation_reason: nil,
notes: new_notes)
end

private

def equipment_object_params
params.require(:equipment_object)
def equipment_item_params
params.require(:equipment_item)
.permit(:name, :serial, :deleted_at, :equipment_model_id,
:deactivation_reason, :notes)
end
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/equipment_models_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def show

@date = Time.zone.today
@date_max = @date + calendar_length - 1.week
@max = @equipment_model.equipment_objects.active.count
@max = @equipment_model.equipment_items.active.count

@restricted = @equipment_model.model_restricted?(cart.reserver_id)
end
Expand Down
Loading

0 comments on commit cc77989

Please sign in to comment.