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

Commit

Permalink
Fix broken calendar feed with archived reservations
Browse files Browse the repository at this point in the history
Resolves #1729
  • Loading branch information
orenyk committed Jun 27, 2018
1 parent 10af6f6 commit 5a6365c
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 12 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* Fixed broken hourly / monthly task buttons ([#1723](https://github.com/YaleSTC/reservations/issues/1723)).
* Fixed reservation checkin / checkout with procedures ([#1726](https://github.com/YaleSTC/reservations/issues/1726)).
* Fixed broken procedure creation ([#1727](https://github.com/YaleSTC/reservations/issues/1727)).
* Fixed broken calendar feed with archived reservations ([#1729](https://github.com/YaleSTC/reservations/issues/1729)).

### Added
* Added link to the accessibility at Yale site in the footer ([#1725](https://github.com/YaleSTC/reservations/issues/1725)).
Expand Down
8 changes: 4 additions & 4 deletions app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# frozen_string_literal: true

class CategoriesController < ApplicationController
load_and_authorize_resource
decorates_assigned :category
before_action :set_current_category,
only: [:show, :edit, :update, :destroy, :deactivate]
only: %i[show edit update destroy deactivate]

include ActivationHelper
include CsvExport
Expand Down Expand Up @@ -53,8 +54,7 @@ def create
end
end

def edit
end
def edit; end

def update
if @category.update_attributes(category_params)
Expand Down Expand Up @@ -95,7 +95,7 @@ def category_params
def generate_calendar_reservations
# we need uniq because it otherwise includes overdue reservations in the
# date range twice
(Reservation.for_cat(@category.id).finalized
(Reservation.for_cat(@category.id).finalized.where.not(status: 'archived')
.includes(:equipment_item, :equipment_model)
.overlaps_with_date_range(@start_date, @end_date) + \
Reservation.for_cat(@category.id)
Expand Down
13 changes: 7 additions & 6 deletions app/controllers/equipment_items_controller.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
# frozen_string_literal: true

# rubocop:disable Metrics/ClassLength
class EquipmentItemsController < ApplicationController
load_and_authorize_resource
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]
only: %i[show edit update destroy deactivate
activate]
before_action :set_equipment_model_if_possible, only: %i[index new]

include ActivationHelper
include CsvExport
Expand Down Expand Up @@ -59,8 +60,7 @@ def create
end
end

def edit
end
def edit; end

def update
p = equipment_item_params
Expand Down Expand Up @@ -122,7 +122,8 @@ def generate_calendar_reservations
# we need uniq because it otherwise includes overdue reservations in the
# date range twice
(@equipment_item.reservations.includes(:equipment_item)
.overlaps_with_date_range(@start_date, @end_date).finalized + \
.overlaps_with_date_range(@start_date, @end_date).finalized
.where.not(status: 'archived') + \
@equipment_item.reservations.includes(:equipment_item).overdue).uniq
end

Expand Down
3 changes: 2 additions & 1 deletion app/controllers/equipment_models_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,8 @@ def generate_calendar_reservations
# we need uniq because it otherwise includes overdue reservations in the
# date range twice
(Reservation.for_eq_model(@equipment_model.id).includes(:equipment_item)
.overlaps_with_date_range(@start_date, @end_date).finalized + \
.overlaps_with_date_range(@start_date, @end_date).finalized
.where.not(status: 'archived') + \
Reservation.for_eq_model(@equipment_model.id).includes(:equipment_item)
.overdue).uniq
end
Expand Down
3 changes: 2 additions & 1 deletion app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,8 @@ def generate_calendar_reservations
# we need uniq because it otherwise includes overdue reservations in the
# date range twice
(@user.reservations.includes(:equipment_item)
.overlaps_with_date_range(@start_date, @end_date).finalized + \
.overlaps_with_date_range(@start_date, @end_date).finalized
.where.not(status: 'archived') + \
@user.reservations.includes(:equipment_item).overdue).uniq
end

Expand Down

0 comments on commit 5a6365c

Please sign in to comment.