-
Notifications
You must be signed in to change notification settings - Fork 120
/
Copy pathhelp-if-you-are-arrested-abroad.rb
107 lines (86 loc) · 3.38 KB
/
help-if-you-are-arrested-abroad.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
module SmartAnswer
class HelpIfYouAreArrestedAbroadFlow < Flow
def define
content_id "cb62c931-a0fa-4363-b33d-12ac06d6232a"
name 'help-if-you-are-arrested-abroad'
status :published
satisfies_need "100220"
arrested_calc = SmartAnswer::Calculators::ArrestedAbroad.new
prisoner_packs = arrested_calc.data
exclude_countries = %w(holy-see british-antarctic-territory)
#Q1
country_select :which_country?, exclude_countries: exclude_countries do
save_input_as :country
calculate :location do
loc = WorldLocation.find(country)
raise InvalidResponse unless loc
loc
end
calculate :organisation do
location.fco_organisation
end
calculate :country_name do
location.name
end
calculate :pdf do
arrested_calc.generate_url_for_download(country, "pdf", "Prisoner pack for #{country_name}")
end
calculate :doc do
arrested_calc.generate_url_for_download(country, "doc", "Prisoner pack for #{country_name}")
end
calculate :benefits do
arrested_calc.generate_url_for_download(country, "benefits", "Benefits or legal aid in #{country_name}")
end
calculate :prison do
arrested_calc.generate_url_for_download(country, "prison", "Information on prisons and prison procedures in #{country_name}")
end
calculate :judicial do
arrested_calc.generate_url_for_download(country, "judicial", "Information on the judicial system and procedures in #{country_name}")
end
calculate :police do
arrested_calc.generate_url_for_download(country, "police", "Information on the police and police procedures in #{country_name}")
end
calculate :consul do
arrested_calc.generate_url_for_download(country, "consul", "Consul help available in #{country_name}")
end
calculate :lawyer do
arrested_calc.generate_url_for_download(country, "lawyer", "English speaking lawyers and translators/interpreters in #{country_name}")
end
calculate :has_extra_downloads do
[police, judicial, consul, prison, lawyer, benefits, doc, pdf].select { |x|
x != ""
}.length > 0 || arrested_calc.countries_with_regions.include?(country)
end
calculate :region_links do
links = []
if arrested_calc.countries_with_regions.include?(country)
regions = arrested_calc.get_country_regions(country)
regions.each do |key, val|
links << "- [#{val['url_text']}](#{val['link']})"
end
end
links
end
next_node(permitted: :auto) do |response|
if response == "iran"
outcome :answer_two_iran
elsif response == "syria"
outcome :answer_three_syria
else
outcome :answer_one_generic
end
end
end
outcome :answer_one_generic do
precalculate :transfers_back_to_uk_treaty_change_countries do
%w(austria belgium croatia denmark finland hungary italy latvia luxembourg malta netherlands slovakia)
end
precalculate :region_downloads do
region_links.join("\n")
end
end
outcome :answer_two_iran
outcome :answer_three_syria
end
end
end