Skip to content

Commit

Permalink
Initial form for circ stats management report
Browse files Browse the repository at this point in the history
  • Loading branch information
tallenaz committed Jun 24, 2016
1 parent 1c0fbf4 commit 42f18f2
Show file tree
Hide file tree
Showing 10 changed files with 220 additions and 3 deletions.
8 changes: 8 additions & 0 deletions app/controllers/circulation_statistics_reports_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
###
# Controller to handle the Circulation Statistics Report
###
class CirculationStatisticsReportsController < ApplicationController
def new
@circulation_statistics_report = CirculationStatisticsReport.new
end
end
5 changes: 5 additions & 0 deletions app/models/circulation_statistics_report.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# app/models/circulation_statistics_report.rb
class CirculationStatisticsReport
include ActiveModel::Model
attr_accessor :email, :libraries, :source, :range_type, :low_callnum_range, :hi_callnum_range
end
8 changes: 8 additions & 0 deletions app/models/uni_libs_locs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# app/models/uni_libs_locs.rb
class UniLibsLocs < ActiveRecord::Base
self.table_name = 'uni_libs_locs'

def self.libraries
UniLibsLocs.select(:library).distinct.where.not(library: nil).order(:library).pluck(:library)
end
end
154 changes: 154 additions & 0 deletions app/views/circulation_statistics_reports/new.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,154 @@
<h2>Circulation Statistics Report Request</h2>
<%= form_for @circulation_statistics_report, multipart: true, class: 'form-group' do |f| %>
<% if @circulation_statistics_report.errors.any? %>
<div id="error_explanation">
<ul>
<% @circulation_statistics_report.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div>
<div class='form-group row'>
<%= f.label :email, 'Email for notification when the report is ready:', class: 'col-sm-5 form-control-label' %>
<div class='col-sm-10'>
<%= f.text_field 'email', class: 'form-control' %>
</div>
</div>
<div class='form-group row'>
<%= f.label :libraries, 'Select libraries to collect stats for:', class: 'col-sm-5 form-control-label' %>
<div class='col-sm-10'>
<%= f.select :libraries, UniLibsLocs.libraries, {}, {multiple: true, size: 6, selected: 'none', class: 'form-control'} %>
</div>
</div>
<div class='form-group row'>
<%= f.label :source, 'Select from:', class: 'col-sm-3 form-control-label' %>
<div class='col-sm-10'>
<%= f.radio_button :source, 'All of Symphony' %> All of Symphony<br />
<%= f.radio_button :source, 'Google candidates (standard barcode)' %> Google candidates (standard barcode)<br />
<%= f.radio_button :source, 'Google candidates (auto-barcode)' %> Google candidates (auto-barcode)<br />
</div>
</div>
<div class='form-group row'>
<%= f.label :range_type, 'Type of selection of records to include in the report: (See examples of call number options below)', class: 'col-sm-7 form-control-label' %>
<div class='col-sm-10'>
<%= f.radio_button :range_type, 'LC Letters Range: All LC call numbers beginning with specified letter(s) or range of letters' %> LC Letters Range: All LC call numbers beginning with specified letter(s) or range of letters<br />
<%= f.radio_button :range_type, 'Classic Selection: LC numerical range all beginning with same letter(s), or any range of Dewey numbers' %> Classic Selection: LC numerical range all beginning with same letter(s), or any range of Dewey numbers<br />
<%= f.radio_button :range_type, 'Other call numbers: All that are neither LC nor Dewey, optionally filtered by start of call number' %> Other call numbers: All that are neither LC nor Dewey, optionally filtered by start of call number<br />
<%= f.radio_button :range_type, 'Upload a barcode list (Any call numbers. "Library" and "Select from" options on this page ignored)' %> Upload a barcode list (Any call numbers. "Library" and "Select from" options on this page ignored)<br />
</div>
</div>
<p>Enter a letter or range of letters for circulation statistics on all LC call numbers beginning with the letter(s).</p>
<div class='form-group row'>
<%= f.label :low_callnum_range, 'Lowest letter(s) of LC call number range. One or two letters required or one letter followed by # symbol.' %>
<div class='col-md-1'>
<%= f.text_field :low_callnum_range, maxlength: 2, class: 'form-control' %><br/>
</div>
</div>
<div class='form-group row'>
<%= f.label :hi_callnum_range, 'Highest letter(s) of LC call number range. Same number of letters as in first field, or leave blank for only letter(s) in first field.' %>
<div class='col-md-1'>
<%= f.text_field :hi_callnum_range, maxlength: 2, class: 'form-control' %><br/>
</div>
</div>
<!-- get libraries from uni_libs_locs -->
<!-- UniLibsLocs.select(:library).distinct.where.not(library: nil).order(:library) -->
<!-- see CIRC_STATS_RPT body -->
<!-- select multiple with :multiple=>true -->
<div><%= f.submit 'Submit request', class: 'btn' %></div><br/>
</div>
<% end %>
<div class="btn-group">
<%= main_menu_button %>
</div>
<h4>Call number range examples for LC Letters Range:</h4>
<div>
<table class='table table-bordered'>
<tbody>
<tr>
<td>H</td>
<td></td>
<td>selects all LC call numbers starting with H (including HA, HB, etc.)</td>
</tr>
<tr>
<td>H#</td>
<td></td>
<td>selects all LC call numbers starting with H followed by digit or cutter, <strong>not</strong> HA, HB, etc. (<em>Same as Classic Selection H 0 9999 below</em>)</td>
</tr>
<tr>
<td>H</td>
<td>K</td>
<td>selects all LC call numbers starting with H, I, J or K</td>
</tr>
<tr>
<td>HB</td>
<td></td>
<td>selects all LC call numbers starting with HB (<em>Same as Classic Selection HB 0 9999 below</em>)</td>
</tr>
<tr>
<td>HB</td>
<td>HD</td>
<td>selects all LC call numbers starting with HB, HC or HD</td>
</tr>
<tr>
<td>A</td>
<td>Z</td>
<td>selects all LC call numbers</td>
</tr>
<tr>
<td class='text-danger'>H#</td>
<td class='text-danger'>HC</td>
<td class='text-danger'>NOT ALLOWED. With # used in first input field, second field must be empty.</td>
</tr>
<tr>
<td class='text-danger'>HB</td>
<td class='text-danger'>JA</td>
<td class='text-danger'>NOT ALLOWED. With 2 letters in each input field, both fields must have the same first letter.</td>
</tr>
<tr>
<td class='text-danger'>H</td>
<td class='text-danger'>HD</td>
<td class='text-danger'>NOT ALLOWED. Can't have one letter in one field and two letters in the other field.</td>
</tr>
</tbody>
</table>
<h4>Call number range examples for Classic Selection: </h4>
<div>
<table class='table table-bordered'>
<tbody>
<tr>
<td>H</td>
<td>0</td>
<td>9999</td>
<td>selects all LC call numbers starting with H followed by digit or cutter (<em>Does NOT include call starting HA, HB, etc</em>)</td>
</tr>
<tr>
<td>HB</td>
<td>120</td>
<td>2000</td>
<td>selects all LC call numbers from HB120 to HB2000.9999</td>
</tr>
<tr>
<td>HB</td>
<td>0</td>
<td>9999</td>
<td>selects all LC call numbers starting with HB (<em>Same as LC Letters Range HB above</em>)</td>
</tr>
<tr>
<td></td>
<td>382</td>
<td>499</td>
<td>selects all Dewey call numbers from 382 to 499.9999</td>
</tr>
<tr>
<td></td>
<td>0</td>
<td>999</td>
<td>selects all Dewey call numbers</td>
</tr>
</tbody>
</table>
</div>
</div>
<div>HB to HC is not possible with Classic Selection. Use LC Letters Range for selections like that.</div>
1 change: 1 addition & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
resources :transfer_items, only: [:new, :create]
resources :sal3_batch_requests_batches, only: [:new, :create]
resources :encumbrance_reports, only: [:new, :create]
resources :circulation_statistics_reports, only: [:new, :create]

get 'batch_record_updates/errors_for_batch' => 'batch_record_updates#errors_for_batch'
get 'batch_record_updates/errors_for_batch/:batch_number' => 'batch_record_updates#errors_for_batch'
Expand Down
8 changes: 8 additions & 0 deletions db/migrate/20160622001510_create_uni_libs_locs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class CreateUniLibsLocs < ActiveRecord::Migration
def change
create_table :uni_libs_locs do |t|
t.string :library
t.string :home_loc
end
end
end
10 changes: 7 additions & 3 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20160617212136) do
ActiveRecord::Schema.define(version: 20160622001510) do

create_table "authorized_user", force: :cascade do |t|
t.string "user_id"
Expand Down Expand Up @@ -59,8 +59,7 @@
t.datetime "updated_at", null: false
end

create_table "sal3_batch_requests_batch", force: :cascade do |t|
t.integer "batch_id"
create_table "sal3_batch_requests_batch", primary_key: "batch_id", force: :cascade do |t|
t.string "batch_name"
t.string "user_name"
t.string "user_email"
Expand Down Expand Up @@ -105,6 +104,11 @@
t.datetime "updated_at", null: false
end

create_table "uni_libs_locs", force: :cascade do |t|
t.string "library"
t.string "home_loc"
end

create_table "uni_updates", force: :cascade do |t|
t.integer "batch_id"
t.string "pending"
Expand Down
11 changes: 11 additions & 0 deletions spec/controllers/circulation_statistics_reports_controller_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require 'rails_helper'

RSpec.describe CirculationStatisticsReportsController, type: :controller do
describe 'get#new' do
it 'renders the correct template' do
stub_current_user(FactoryGirl.create(:authorized_user))
get 'new'
expect(response).to render_template('new')
end
end
end
6 changes: 6 additions & 0 deletions spec/factories/uni_libs_locs.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
FactoryGirl.define do
factory :uni_libs_locs do
library 'SAL3'
home_loc 'PAGE-MU'
end
end
12 changes: 12 additions & 0 deletions spec/models/uni_libs_locs_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
require 'rails_helper'

RSpec.describe UniLibsLocs, type: :model do
it 'has a valid factory' do
expect(FactoryGirl.create(:uni_libs_locs)).to be_valid
end

it 'returns an array of library names' do
FactoryGirl.create(:uni_libs_locs)
expect(UniLibsLocs.libraries).to eq(['SAL3'])
end
end

0 comments on commit 42f18f2

Please sign in to comment.