-
Notifications
You must be signed in to change notification settings - Fork 9
/
pages_controller.rb
320 lines (284 loc) · 10.5 KB
/
pages_controller.rb
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
316
317
318
319
320
class PagesController < ApplicationController
before_action :save_referer, except: [:handbook]
def home
end
def handbook
client = Octokit::Client.new(
client_id: ENV['GITHUB_KEY'],
client_secret: ENV['GITHUB_SECRET']
)
@content = client.contents(
"makeitrealcamp/handbook",
path: "README.md", accept: "application/vnd.github.VERSION.raw"
).encode("ASCII-8BIT").force_encoding("utf-8")
render layout: "application"
end
def create_full_stack_online_lead
suffix = ['MX', 'CO', 'PE'].include?(params['country']) ? params['country'].downcase : "other"
data = {
pid: cookies[:dp_pid],
program: "Full Stack Online",
event: "filled-full-stack-form-#{suffix}",
first_name: params['first-name'],
last_name: params['last-name'],
email: params['email'],
country: params['country'],
mobile: params['mobile'],
source: params['source'],
gender: params['gender'],
birthday: params['birthday'],
ip: request.remote_ip
}
CreateLeadJob.perform_later(data)
redirect_to "/thanks-full-stack-online"
end
def create_data_science_online_lead
suffix = ['MX', 'CO', 'PE'].include?(params['country']) ? params['country'].downcase : "other"
data = {
pid: cookies[:dp_pid],
program: "Data Science Online",
event: "filled-data-science-form-#{suffix}",
first_name: params['first-name'],
last_name: params['last-name'],
email: params['email'],
country: params['country'],
mobile: params['mobile'],
source: params['source'],
gender: params['gender'],
birthday: params['birthday'],
ip: request.remote_ip
}
CreateLeadJob.perform_later(data)
redirect_to "/thanks-data-science-online"
end
def send_web_developer_guide
subscriber = SubscriberForm.new(params.to_unsafe_hash)
person = { pid: cookies[:dp_pid], email: subscriber.email, first_name: subscriber.first_name,
last_name: subscriber.last_name, user_goal: subscriber.goal }
begin
ConvertLoop.event_logs.send(name: "requested-developer-guide", person: person)
rescue => e
Rails.logger.error "Couldn't send event requested-developer-guide to ConvertLoop: #{e.message}"
end
PagesMailer.web_developer_guide(subscriber).deliver_now
respond_to do |format|
format.html do
@email_sent = true
render :web_developer_guide
end
format.js
end
end
def download_web_developer_guide
if params[:email].blank?
redirect_to root_path
return
end
person = { email: params[:email] }
metadata = { ip: request.remote_ip }
begin
ConvertLoop.event_logs.send(name: "downloaded-developer-guide", person: person, metadata: metadata)
rescue => e
Rails.logger.error "Couldn't send event downloaded-developer-guide to ConvertLoop: #{e.message}"
Rails.logger.error "Backtrace: \n\t#{e.backtrace.join("\n\t")}"
end
redirect_to "https://s3.amazonaws.com/makeitreal/e-books/convertirte-en-desarrollador-web.pdf"
end
def create_top_applicant
top_applicant_params_updated = top_applicant_params.dup
program_format = top_applicant_params[:format] == "format-full" ? "full" : "partial"
payment_method = top_applicant_params[:payment_method] == "" ? top_applicant_params[:payment_method_2] : top_applicant_params[:payment_method]
top_applicant_params_updated.delete(:payment_method_2)
top_applicant_params_updated[:format] = program_format
top_applicant_params_updated[:payment_method] = payment_method
TopApplicant.create!(top_applicant_params_updated.merge(version: 2))
data = {
name: "filled-top-application",
person: {
pid: cookies[:dp_pid],
email: top_applicant_params[:email],
first_name: top_applicant_params[:first_name],
last_name: top_applicant_params[:last_name],
birthday: top_applicant_params[:birthday],
country_code: top_applicant_params[:country],
mobile: top_applicant_params[:mobile],
gender: top_applicant_params[:gender],
format: program_format,
stipend: top_applicant_params[:stipend],
payment_method: payment_method
},
metadata: {
linkedin: top_applicant_params[:url],
ip: request.remote_ip,
goal: top_applicant_params[:goal],
experience: top_applicant_params[:experience],
more_info: top_applicant_params[:additional]
}
}
ConvertLoopJob.perform_later(data)
AdminMailer.new_lead("Top", data[:person][:first_name], data[:person][:last_name], data[:person][:email], data[:person][:country_code],
data[:person][:mobile], "").deliver_later
redirect_to "/thanks-top"
end
def create_innovate_applicant
InnovateApplicant.create!(innovate_applicant_params)
format = innovate_applicant_params[:format]
p format
suffix = format == "format-full" ? "full" : "partial"
data = {
name: "filled-innovate-application-#{suffix}",
person: {
pid: cookies[:dp_pid],
email: innovate_applicant_params[:email],
first_name: innovate_applicant_params[:first_name],
last_name: innovate_applicant_params[:last_name],
birthday: innovate_applicant_params[:birthday],
country_code: innovate_applicant_params[:country],
mobile: innovate_applicant_params[:mobile],
gender: innovate_applicant_params[:gender]
},
metadata: {
linkedin: innovate_applicant_params[:url],
ip: request.remote_ip,
goal: innovate_applicant_params[:goal],
experience: innovate_applicant_params[:experience],
typical_day: innovate_applicant_params[:typical_day],
vision: innovate_applicant_params[:vision],
more_info: innovate_applicant_params[:additional]
}
}
ConvertLoopJob.perform_later(data)
AdminMailer.new_lead("Innovate", data[:person][:first_name], data[:person][:last_name], data[:person][:email], data[:person][:country_code],
data[:person][:mobile], "").deliver_later
redirect_to "/thanks-innovate"
end
def full_stack_online_seat
@course = Billing::Charge::COURSES[:fullstack]
@currency = params[:currency] || "COP"
end
def data_science_online_seat
@course = Billing::Charge::COURSES[:datascience]
@currency = params[:currency] || "COP"
end
def innovate_full_time_seat
@course = Billing::Charge::COURSES[:innovate_full_time]
@currency = params[:currency] || "PEN"
end
def innovate_part_time_seat
@course = Billing::Charge::COURSES[:innovate_part_time]
@currency = params[:currency] || "PEN"
end
def create_ruby_on_rails_lead
suffix = ['MX', 'CO', 'PE'].include?(params['country']) ? params['country'].downcase : "other"
data = {
pid: cookies[:dp_pid],
program: "Ruby on Rails",
event: "filled-ruby-on-rails-form-#{suffix}",
first_name: params['first-name'],
last_name: params['last-name'],
email: params['email'],
country: params['country'],
mobile: params['mobile'],
gender: params['gender'],
birthday: params['birthday'],
source: params['source'],
ip: request.remote_ip
}
CreateLeadJob.perform_later(data)
redirect_to "/thanks-ruby-on-rails"
end
def create_agile_tester_lead
suffix = ['MX', 'CO', 'PE'].include?(params['country']) ? params['country'].downcase : "other"
data = {
pid: cookies[:dp_pid],
program: "Agile Tester",
event: "filled-application-tester-form-#{suffix}",
first_name: params['first-name'],
last_name: params['last-name'],
email: params['email'],
country: params['country'],
mobile: params['mobile'],
gender: params['gender'],
birthday: params['birthday'],
source: params['source'],
ip: request.remote_ip
}
CreateLeadJob.perform_later(data)
redirect_to "/thanks-agile-tester"
end
def create_intro_to_js_lead
data = {
pid: cookies[:dp_pid],
program: "Intro to JavaScript Innpulsa",
event: "filled-intro-to-js-2021-jul-form",
first_name: params['first-name'],
last_name: params['last-name'],
email: params['email'],
country: params['country'],
mobile: params['mobile'],
gender: params['gender'],
birthday: params['birthday'],
ip: request.remote_ip
}
CreateLeadJob.perform_later(data)
redirect_to "/thanks-intro-to-js"
end
def create_intro_to_python_lead
data = {
pid: cookies[:dp_pid],
program: "Intro to Python",
event: "filled-intro-to-python-form",
first_name: params['first-name'],
last_name: params['last-name'],
email: params['email'],
country: params['country'],
mobile: params['mobile'],
gender: params['gender'],
birthday: params['birthday'],
ip: request.remote_ip
}
CreateLeadJob.perform_later(data)
redirect_to "/thanks-intro-to-python"
end
def create_fs_becas_mujeres_lead
data = {
name: "filled-fs-becas-mujeres-form",
person: {
pid: cookies[:dp_pid],
first_name: params['first-name'],
last_name: params['last-name'],
email: params['email'],
country_code: params['country'],
mobile: params['mobile'],
birthday: params['birthday'],
source: params['source']
},
metadata: {
application_reason: params['application_reason'],
more_info_url: params['url'],
ip: request.remote_ip
}
}
ConvertLoopJob.perform_later(data)
AdminMailer.new_scholarship(data).deliver_later
redirect_to "/thanks-fs-becas-mujeres"
end
def thanks_preparation_top
applicant = TopApplicant.where("info -> 'uid' = ?", params[:uid]).take
if applicant
ConvertLoop.event_logs.send(name: "rsvp-preparation-top", person: { email: applicant.email })
else
raise ActiveRecord::RecordNotFound
end
end
private
def save_referer
session['referer'] = request.env["HTTP_REFERER"] || 'none' unless session['referer']
end
def top_applicant_params
params.require(:applicant).permit(:accepted_terms, :email, :first_name, :last_name, :country, :mobile, :birthday, :gender, :url, :goal, :experience, :additional, :payment_method, :payment_method_2, :format, :stipend)
end
def innovate_applicant_params
params.require(:applicant).permit(:accepted_terms, :email, :first_name, :last_name, :country, :mobile, :birthday, :gender, :linkedin, :goal, :experience, :additional, :format)
end
end