-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrequest_mailer.rb
More file actions
315 lines (258 loc) · 9.79 KB
/
Copy pathrequest_mailer.rb
File metadata and controls
315 lines (258 loc) · 9.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
require 'prawn'
# rubocop:disable Metrics/ClassLength
class RequestMailer < ApplicationMailer
# Adding url_helpers to build the link I create for efees
include Rails.application.routes.url_helpers
helper :mail
# Sends the AffiliateBorrowRequestForm
def affiliate_borrow_request_form_email(borrow_request_hash)
@borrow_request = AffiliateBorrowRequestForm::BorrowRequest.new(**borrow_request_hash)
mail(to: @borrow_request.department_head_email)
end
# Send LibstaffEdevicesLoanRequest confirmation email to user
def libdevice_confirmation_email(email)
mail(to: email)
end
# Send email describing a failure of the LibstaffEdevicesLoanRequest job
def libdevice_failure_email(empid, displayname, note)
@empid = empid
@displayname = displayname
@note = note
mail(to: admin_to)
end
def doemoff_room_confirmation_email(email)
mail(to: email)
end
# Send email describing a failure of the DoemoffStudyRoomUse job
def doemoff_room_failure_email(empid, displayname, note)
@empid = empid
@displayname = displayname
@note = note
mail(to: admin_to)
end
def doemoff_patron_email(payload)
@email_form = DoemoffPatronEmailForm::PatronEmail.new(**payload)
mail(
to: @email_form.patron_email,
bcc: @email_form.recipient_email,
reply_to: @email_form.recipient_email,
subject: 'Message from Doe/Moffitt Libraries Staff'
)
end
# Sends the Security Incident form email
def security_incident_email(payload)
@security_incident = SecurityIncidentReportForm::SecurityIncident.new(**payload)
if @security_incident.sup_email.nil?
mail(to: security_to, subject: 'Incident Report Form email')
else
mail(to: [security_to, @security_incident.sup_email], subject: 'Incident Report Form email')
end
end
def security_incident_failure_email(email)
mail(to: email)
end
# Send ServiceArticleRequest confirmation email to user
# rubocop:disable Metrics/MethodLength
def service_article_confirmation_email(email, publication, patron)
@pub_title = publication[:pub_title]
@pub_location = publication[:pub_location]
@issn = publication[:issn]
@vol = publication[:vol]
@article_title = publication[:article_title]
@author = publication[:author]
@pages = publication[:pages]
@citation = publication[:citation]
@pub_notes = publication[:pub_notes]
@patron_name = patron.name
@patron_email = patron.email
mail(to: email)
end
# rubocop:enable Metrics/MethodLength
# Send email describing a failure of the ServiceArticleRequest job
def service_article_failure_email(empid, displayname)
@empid = empid
@displayname = displayname
mail(to: admin_to)
end
# Send StudentEdevicesLoanJob confirmation email to user
def student_edevices_confirmation_email(email)
mail(to: email)
end
# Send email describing a failure of the StudentEdevicesLoanJob job
def student_edevices_failure_email(empid, displayname, note)
@empid = empid
@displayname = displayname
@note = note
mail(to: admin_to)
end
# Send GalcRequest confirmation email to user
def galc_confirmation_email(email)
mail(to: email, subject: 'GALC confirmation email')
end
# Send email describing a failure of the GalcRequest job
def galc_failure_email(empid, displayname, note)
@empid = empid
@displayname = displayname
@note = note
mail(to: admin_to)
end
# Send email describing a failure of a ScanRequest job
def scan_request_opt_in_failure_email(empid, displayname, note)
@empid = empid
@displayname = displayname
@note = note
mail(to: admin_to)
end
# Send ScanRequest confirmation email to the opted-in user
def scan_request_opt_in_confirmation_email(email)
mail(to: [email, admin_to])
end
def scan_request_opt_out_staff(empid, displayname)
@empid = empid
@displayname = displayname
mail(cc: [admin_to, confirm_to])
end
def scan_request_opt_out_faculty(email)
mail(to: [email, admin_to])
end
# Send Proxy-Borrower Card Request Instructions to user
def proxy_borrower_request_email(proxy_request)
@proxy_request = proxy_request
mail(to: @proxy_request.user_email)
end
# Send Proxy-Borrower Card Request Alert to privdesk
def proxy_borrower_alert_email(proxy_request)
@proxy_request = proxy_request
mail(to: [privdesk_to, 'mamarrow@berkeley.edu'])
end
# Send Stack Pass Request Alert to privdesk
def stack_pass_email(stackpass_form)
@stackpass_form = stackpass_form
mail(to: [privdesk_to, 'mamarrow@berkeley.edu'], subject: 'Stack Pass Request')
end
# Send Stack Pass Denial to requester
def stack_pass_denied(stackpass_form)
@stackpass_form = stackpass_form
mail(to: @stackpass_form.email, subject: 'Stack Pass Request - Denied')
end
# Send Stack Pass Approval to requester
def stack_pass_approved(stackpass_form)
# Generate the Approval PDF File:
pdf = stackpass_pdf(stackpass_form)
attachments['approval.pdf'] = pdf.render
mail(to: stackpass_form.email, subject: 'Stack Pass Request - Approved')
end
# Send Reference Card Request Alert to privdesk
def reference_card_email(reference_card_form)
@reference_card_form = reference_card_form
mail(to: [privdesk_to, 'mamarrow@berkeley.edu'], subject: 'Reference Card Request')
end
# Send Reference Card Denial to requester
def reference_card_denied(reference_card_form)
@reference_card_form = reference_card_form
mail(to: @reference_card_form.email, subject: 'Reference Card Request - Denied')
end
# Send Reference Card Approval to requester
def reference_card_approved(reference_card_form)
# Generate the Approval PDF File:
pdf = referencecard_pdf(reference_card_form)
attachments['approval.pdf'] = pdf.render
mail(to: reference_card_form.email, subject: 'Reference Card Request - Approved')
end
# Send marc multiple batch files for Tind upload.
def tind_marc_batch_2_email(email, attachment_contents, subject, body)
attachment_contents.each do |filename, attachment|
attachments[filename] = attachment
end
mail(to: email, subject:, body:)
end
# Send CSV/XLSX spreadsheet for spreadsheet validator.
def tind_spread_email(email, subject, body, attachment_contents)
return mail(to: email, subject:, body:) if attachment_contents.empty?
attachment_contents.each do |filename, attachment|
attachments[filename] = attachment
end
mail(to: email, subject:, body:)
end
# Send Item Set notes job update
def item_notes_update_email(email, message)
@email_message = message
mail(to: email, subject: 'Item set internal notes updated')
end
def bibliographic_email(email, attachment_contents, subject, body)
attachment_contents.each do |filename, attachment|
attachments[filename] = attachment
end
mail(to: email, subject:, body:)
end
def bibliographic_failure_email(email, subject, host_bib_task, host_bib)
@host_bib_task = host_bib_task
@host_bib = host_bib
mail(to: email, subject:)
end
def efee_invoice_email(alma_id)
efee = EfeesInvoice.new(alma_id)
# type probably isn't needed now that I spun this off to a separate url
params = {
type: 'efee',
jwt: efee.jwt
}
invoice_link = URI.parse(efee_url.to_s)
invoice_link.query = URI.encode_www_form(params)
@name = efee.name
@link = invoice_link.to_s
mail(to: efee.email, subject: 'Library Fees')
end
# Departmental Card Request : alerts to privdesk, Mark Marrow and Supervisor
def departmental_card_form_email(departmental_card_form)
@departmental_card_form = departmental_card_form
mail(
to: [privdesk_to, 'mamarrow@berkeley.edu', @departmental_card_form.supervisor_email],
subject: 'Departmental Card Request',
reply_to: [privdesk_to, 'mamarrow@berkeley.edu']
)
end
private
# Create the Stack Pass approved PDF file
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
def stackpass_pdf(stackpass_form)
pdf = Prawn::Document.new
pdf.move_down 10
pdf.font_size 24
pdf.text 'Main (Gardner) Stack Pass Approval', align: :center
pdf.move_down 10
pdf.font_size 12
pdf.text 'Print out this Stack Pass or save it to your phone and bring it to the Doe Library,
Gardner Stacks Level A along with a government-issued photo ID.', align: :center
pdf.move_down 10
pdf.text "Name: #{stackpass_form.name}", align: :center
pdf.text "Date of Stack Pass: #{stackpass_form.pass_date.strftime('%m/%d/%Y')}", align: :center
pdf.text "Approved by: #{stackpass_form.processed_by}", align: :center
pdf.move_down 10
pdf.text 'University of California, Berkeley Library'
pdf
end
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
# Create the Reference Card approved PDF file
# rubocop:disable Metrics/MethodLength, Metrics/AbcSize
def referencecard_pdf(refcard_form)
pdf = Prawn::Document.new
pdf.move_down 10
pdf.font_size 24
pdf.text 'Main (Gardner) Stack Reference Card Approval', align: :center
pdf.move_down 10
pdf.font_size 12
pdf.text 'Print out or save this approval document to your phone and bring it to the Privileges
Desk (Doe Library, Gardner Stacks Level A) along with a government-issued photo ID.', align: :center
pdf.move_down 10
pdf.text "Name: #{refcard_form.name}", align: :center
pdf.text "Start date of Reference card: #{refcard_form.pass_date.strftime('%m/%d/%Y')}", align: :center
pdf.text "End date of Reference card: #{refcard_form.pass_date_end.strftime('%m/%d/%Y')}", align: :center
pdf.text "Approved by: #{refcard_form.processed_by}", align: :center
pdf.move_down 10
pdf.text 'University of California, Berkeley Library'
pdf
end
# rubocop:enable Metrics/MethodLength, Metrics/AbcSize
end
# rubocop:enable Metrics/ClassLength