-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdevinrio.rb
56 lines (42 loc) · 1.21 KB
/
devinrio.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
require 'rubygems'
require 'sinatra'
require 'parseexcel'
require 'cgi'
configure :production do
end
get '/' do
erb :index, :locals => { :title => "" }
end
get '/localizacao' do
title = "Localização - "
erb :localizacao, :locals => { :title => title }
end
get '/2009' do
erb :"anteriores/site_2009", :layout => false
end
get '/2010' do
erb :"anteriores/site_2010", :layout => false
end
get '/2010-en' do
erb :"anteriores/site_2010_en", :layout => false
end
get '/certificado' do
title = "Certificado de 2010 - "
workbook = Spreadsheet::ParseExcel.parse('public/files/LISTA_COMPLETA.xls')
sheet = workbook.worksheet(0)
certificate_for = nil
i = 0
sheet.each do
name = sheet.cell(i,3).to_s('UTF8').split(' ').map {|w| w.capitalize }.join(' ')
email = sheet.cell(i,4).to_s('UTF8').downcase
present = sheet.cell(i,12).to_s('UTF8')
certificate_for = name if present == "Sim" && email == CGI.unescape(params[:email]).to_s.downcase
break unless certificate_for.to_s.empty?
i += 1
end
unless certificate_for.to_s.empty?
erb :certificado, :layout => false, :locals => { :certificate_for => certificate_for }
else
erb :error, :locals => { :title => title }
end
end