-
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.
Add MVC for enbdowed funds management report and higher rubocop thres…
…holds
- Loading branch information
Showing
28 changed files
with
1,476 additions
and
62 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
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 @@ | ||
### | ||
# Controller to handle the Encumberances Report | ||
### | ||
class EndowedFundsReportsController < ApplicationController | ||
def new | ||
@endowed_funds_report = EndowedFundsReport.new | ||
end | ||
|
||
def create | ||
@endowed_funds_report = EndowedFundsReport.new(batch_params) | ||
if @endowed_funds_report.valid? | ||
if @endowed_funds_report.fund | ||
catalog_keys = EndowedFundsReport.ol_cat_key(@endowed_funds_report.fund) | ||
elsif @endowed_funds_report.fund_begin | ||
catalog_keys = EndowedFundsReport.ol_cat_key(@endowed_funds_report.fund_begin) | ||
end | ||
# write keys to file to Symphony mount [/symphony] on libsys-webforms-dev | ||
@endowed_funds_report.write_keys(catalog_keys) | ||
# TODO: kick off perl script to run pl/sql report | ||
|
||
flash[:success] = 'Report requested!' | ||
redirect_to root_path | ||
else | ||
flash[:warning] = 'Check that all form fields are entered!' | ||
render action: 'new' | ||
end | ||
end | ||
|
||
def batch_params | ||
params.require(:endowed_funds_report).permit! | ||
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,37 @@ | ||
### | ||
# Class to model EXPENDITURES oracle table | ||
### | ||
class EndowedFundsReport | ||
include ActiveModel::Model | ||
include ActiveModel::Validations | ||
|
||
attr_accessor :fund, :fund_begin, :fund_select, :report_format, :date_request, | ||
:date_ran, :date_type, :fy_start, :fy_end, :cal_start, :cal_end, | ||
:pd_start, :pd_end, :email | ||
|
||
validates :fund, presence: true, if: 'fund_begin.nil?' | ||
validates :fund_begin, presence: true, if: 'fund.nil?' | ||
|
||
# get cat keys | ||
def self.ol_cat_key(fund) | ||
if fund.is_a?(Array) | ||
fund_codes = [] | ||
fund.each do |fc| | ||
Expenditures.where('ta_fund_code = ?', fc).pluck(:ol_cat_key).each do |ckey| | ||
fund_codes << ckey | ||
end | ||
end | ||
fund_codes.uniq | ||
elsif fund.is_a?(String) | ||
Expenditures.where('ta_fund_code LIKE ?', "%#{fund}%").pluck(:ol_cat_key) | ||
end | ||
end | ||
|
||
def write_keys(catalog_keys) | ||
symphony_file = "endow#{Time.zone.now.strftime('%y%m%d%H%M%S%L%1N')}" | ||
symphony_location = "/symphony/Dataload/EndowRpt/#{symphony_file}" | ||
out_file = File.new(symphony_location, 'w') | ||
out_file.puts(catalog_keys.join("\n")) | ||
out_file.close | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
### | ||
# Class to model EXPENDITURES_FUNDS oracle table | ||
### | ||
class Expenditures < ActiveRecord::Base | ||
self.table_name = 'expenditures' | ||
|
||
def self.ta_fund_code | ||
order(ta_fund_code: :asc) | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<h2>Endowed Funds Report Request</h2> | ||
<%= form_for @endowed_funds_report, multipart: true, class: 'form-group' do |f| %> | ||
<% if @endowed_funds_report.errors.any? %> | ||
<div id='error_explanation'> | ||
<ul> | ||
<% @endowed_funds_report.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
<div> | ||
<%= render 'shared/enter_email', f: f %> | ||
<%= render 'shared/funds_selection', f: f %> | ||
<%= render 'shared/date_range_selection', f: f %> | ||
|
||
<div class='form-group row pad'> | ||
<%= f.label :report_format, class: 'col-sm-10 form-control-label' %> | ||
<div class='col-sm-10'> | ||
<p> | ||
<%= f.radio_button :report_format, 'n', checked: true %> | ||
Text with no bibliographic field labels | ||
</p> | ||
<p> | ||
<%= f.radio_button :report_format, 'i' %> | ||
Text with MARC numeric tags | ||
</p> | ||
<p> | ||
<%= f.radio_button :report_format, 'd' %> | ||
Text with descriptive field labels | ||
</p> | ||
<p> | ||
<%= f.radio_button :report_format, 'r' %> | ||
RefWorks citations | ||
</p> | ||
<p> | ||
<%= f.radio_button :report_format, 'm' %> | ||
MARC (Can be imported to Zotero citations) | ||
</p> | ||
</div> | ||
</div> | ||
|
||
<%= f.hidden_field :date_request, value: Time.now %> | ||
<%= f.hidden_field :date_ran, value: Time.now %> | ||
|
||
<div class='pad'><%= f.submit 'Submit request', class: 'btn' %></div><br/> | ||
|
||
<% end %> | ||
<div class='btn-group'> | ||
<%= main_menu_button %> | ||
</div> | ||
</div> |
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
Oops, something went wrong.