-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed conflicts from rebase with master
- Loading branch information
Showing
12 changed files
with
147 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,50 @@ | ||
# app/model/shelf_selection_report.rb | ||
class ShelfSelectionReport | ||
include ActiveModel::Model | ||
extend ActiveModel::Callbacks | ||
include ActiveModel::Validations | ||
include ActiveModel::Validations::Callbacks | ||
attr_accessor :email, :lib, :loc_array, :cloc_diff, :fmt_array, | ||
:itype_array, :icat1_array, :lang, :min_yr, :max_yr, | ||
:min_circ, :max_circ, :shadowed, :digisent, :url, | ||
:mhlds, :has_dups, :multvol, :multcop, :no_boundw, | ||
:range_type, :call_alpha, :subj_name, | ||
:save_opt, :search_name, :call_lo, :call_hi | ||
validates :email, :loc_array, presence: true | ||
validates :loc_array, length: { minimum: 2, message: "can't be empty" } | ||
validates :call_lo, presence: true, if: :lc_range_type? | ||
validates :fmt_array, :itype_array, length: { minimum: 2, message: "can't be empty" }, if: :lc_range_type? | ||
validate :classic_call_lo_and_hi, if: :classic_range_type? | ||
validates :itype_array, length: { minimum: 2, message: "can't be empty" }, if: :classic_range_type? | ||
validates :fmt_array, length: { minimum: 2, message: "can't be empty" }, if: :other_range_type? | ||
validates :fmt_array, length: { minimum: 2, message: "can't be empty" }, if: :other_range_type? | ||
|
||
def self.generic_options | ||
[["Doesn't matter", 0], ['INCLUDE only', 1], ['EXCLUDE', 2]] | ||
end | ||
|
||
def save_search? | ||
subj_name.present? && save_opt == 'save' | ||
end | ||
|
||
private | ||
|
||
def lc_range_type? | ||
range_type == 'lc' | ||
end | ||
|
||
def classic_range_type? | ||
range_type == 'classic' | ||
end | ||
|
||
def other_range_type? | ||
range_type == 'other' | ||
end | ||
|
||
def classic_call_lo_and_hi | ||
lo_integer = call_lo.to_i | ||
hi_integer = call_hi.to_i | ||
message = 'Low and hi callnum range must be all digits, with lo lower than hi.' | ||
errors.add(:base, message) unless call_lo =~ /^[0-9]+$/ && call_hi =~ /^[0-9]+$/ && lo_integer < hi_integer | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# frozen_string_literal: true | ||
FactoryGirl.define do | ||
factory :shelf_selection_report do | ||
email 'test@test.org' | ||
lib 'GREEN' | ||
loc_array ['', 'BENDER'] | ||
cloc_diff '0' | ||
fmt_array ['', 'MANUSCRIPT'] | ||
itype_array ['', 'ATLAS-EXP'] | ||
icat1_array ['', 'ALL'] | ||
lang '' | ||
min_yr '' | ||
max_yr '' | ||
min_circ '' | ||
max_circ '' | ||
shadowed '2' | ||
digisent '0' | ||
url '0' | ||
mhlds '0' | ||
has_dups '0' | ||
multvol '0' | ||
multcop '0' | ||
no_boundw '1' | ||
range_type 'lc' | ||
call_alpha '' | ||
subj_name 'Green Bender A-B' | ||
save_opt 'save' | ||
search_name '' | ||
call_lo 'A' | ||
call_hi 'B' | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters