Skip to content
This repository was archived by the owner on Jun 16, 2021. It is now read-only.

Commit f9b0ff9

Browse files
authored
Merge pull request #879 from omu/country-regulations
Add country specific sms regulations
2 parents b69b1de + 5821f37 commit f9b0ff9

28 files changed

+28423
-1799
lines changed

Gemfile.lock

+22-25
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ GIT
88

99
GIT
1010
remote: https://github.com/rails/rails.git
11-
revision: 1cdc6c6576afe9a9fa67a6b313080a7dc62188d9
11+
revision: efb706daad0e2e1039c6abb4879c837ef8bf4d10
1212
specs:
1313
actioncable (6.0.0.beta3)
1414
actionpack (= 6.0.0.beta3)
@@ -63,7 +63,7 @@ GIT
6363
i18n (>= 0.7, < 2)
6464
minitest (~> 5.1)
6565
tzinfo (~> 1.1)
66-
zeitwerk (~> 1.3, >= 1.3.4)
66+
zeitwerk (~> 1.4)
6767
rails (6.0.0.beta3)
6868
actioncable (= 6.0.0.beta3)
6969
actionmailbox (= 6.0.0.beta3)
@@ -98,9 +98,9 @@ GIT
9898

9999
GIT
100100
remote: https://github.com/rollbar/rollbar-gem.git
101-
revision: 3c66a47be634fb56a32a390ec3b8e32e2b6c49ed
101+
revision: 83ef1acca2b0b1d1b74ff8ef29435ca82e8ca1d6
102102
specs:
103-
rollbar (2.19.2)
103+
rollbar (2.19.3)
104104
multi_json
105105

106106
PATH
@@ -133,18 +133,17 @@ GEM
133133
io-like (~> 0.3.0)
134134
ast (2.4.0)
135135
aws-eventstream (1.0.2)
136-
aws-partitions (1.144.0)
137-
aws-sdk-core (3.47.0)
136+
aws-partitions (1.145.0)
137+
aws-sdk-core (3.48.2)
138138
aws-eventstream (~> 1.0, >= 1.0.2)
139139
aws-partitions (~> 1.0)
140140
aws-sigv4 (~> 1.1)
141-
http-2 (~> 0.10)
142141
jmespath (~> 1.0)
143-
aws-sdk-kms (1.14.0)
144-
aws-sdk-core (~> 3, >= 3.47.0)
142+
aws-sdk-kms (1.16.0)
143+
aws-sdk-core (~> 3, >= 3.48.2)
145144
aws-sigv4 (~> 1.1)
146-
aws-sdk-s3 (1.32.0)
147-
aws-sdk-core (~> 3, >= 3.47.0)
145+
aws-sdk-s3 (1.34.0)
146+
aws-sdk-core (~> 3, >= 3.48.2)
148147
aws-sdk-kms (~> 1)
149148
aws-sigv4 (~> 1.0)
150149
aws-sigv4 (1.1.0)
@@ -161,13 +160,13 @@ GEM
161160
bindex (0.5.0)
162161
bootsnap (1.4.1)
163162
msgpack (~> 1.0)
164-
brakeman (4.4.0)
163+
brakeman (4.5.0)
165164
builder (3.2.3)
166165
bundler-audit (0.6.1)
167166
bundler (>= 1.2.0, < 3)
168167
thor (~> 0.18)
169-
byebug (11.0.0)
170-
capybara (3.14.0)
168+
byebug (11.0.1)
169+
capybara (3.15.0)
171170
addressable
172171
mini_mime (>= 0.1.3)
173172
nokogiri (~> 1.8)
@@ -233,7 +232,6 @@ GEM
233232
activesupport (>= 4.2)
234233
hashdiff (0.3.8)
235234
html_tokenizer (0.0.7)
236-
http-2 (0.10.1)
237235
i18n (1.6.0)
238236
concurrent-ruby (~> 1.0)
239237
image_processing (1.8.0)
@@ -278,25 +276,24 @@ GEM
278276
nokogiri (1.10.1)
279277
mini_portile2 (~> 2.4.0)
280278
orm_adapter (0.5.0)
281-
pagy (2.1.2)
279+
pagy (2.1.3)
282280
parallel (1.14.0)
283-
parser (2.6.0.0)
281+
parser (2.6.2.0)
284282
ast (~> 2.4.0)
285283
pg (1.1.4)
286284
pg_search (2.1.4)
287285
activerecord (>= 4.2)
288286
activesupport (>= 4.2)
289287
pghero (2.2.0)
290288
activerecord
291-
powerpack (0.1.2)
292289
pry (0.12.2)
293290
coderay (~> 1.1.0)
294291
method_source (~> 0.9.0)
295292
pry-rails (0.3.9)
296293
pry (>= 0.10.4)
297294
psych (3.1.0)
298295
public_suffix (3.0.3)
299-
puma (3.12.0)
296+
puma (3.12.1)
300297
pwned (1.2.1)
301298
rack (2.0.6)
302299
rack-attack (5.4.2)
@@ -327,15 +324,14 @@ GEM
327324
responders (2.4.1)
328325
actionpack (>= 4.2.0, < 6.0)
329326
railties (>= 4.2.0, < 6.0)
330-
rubocop (0.65.0)
327+
rubocop (0.66.0)
331328
jaro_winkler (~> 1.5.1)
332329
parallel (~> 1.10)
333330
parser (>= 2.5, != 2.5.1.1)
334-
powerpack (~> 0.1)
335331
psych (>= 3.1.0)
336332
rainbow (>= 2.2.2, < 4.0)
337333
ruby-progressbar (~> 1.7)
338-
unicode-display_width (~> 1.4.0)
334+
unicode-display_width (>= 1.4.0, < 1.6)
339335
ruby-progressbar (1.10.0)
340336
ruby-vips (2.0.13)
341337
ffi (~> 1.9)
@@ -394,7 +390,7 @@ GEM
394390
unf (0.1.4)
395391
unf_ext
396392
unf_ext (0.0.7.5)
397-
unicode-display_width (1.4.1)
393+
unicode-display_width (1.5.0)
398394
uniform_notifier (1.12.1)
399395
warden (1.2.8)
400396
rack (>= 2.0.6)
@@ -409,10 +405,11 @@ GEM
409405
websocket-driver (0.7.0)
410406
websocket-extensions (>= 0.1.0)
411407
websocket-extensions (0.1.3)
412-
wicked_pdf (1.1.0)
408+
wicked_pdf (1.2.1)
409+
activesupport
413410
xpath (3.2.0)
414411
nokogiri (~> 1.8)
415-
zeitwerk (1.3.4)
412+
zeitwerk (1.4.0)
416413

417414
PLATFORMS
418415
ruby

app/controllers/location/cities_controller.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ def set_city
4545
end
4646

4747
def city_params
48-
params.require(:city).permit(:name, :alpha_2_code)
48+
params.require(:city).permit(:name, :alpha_2_code, :latitude, :longitude)
4949
end
5050
end
5151
end

app/controllers/location/countries_controller.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,10 @@ def set_country
4040
end
4141

4242
def country_params
43-
params.require(:country).permit(:name, :alpha_2_code, :alpha_3_code, :numeric_code, :mernis_code, :yoksis_code)
43+
params.require(:country).permit(
44+
:name, :alpha_2_code, :alpha_3_code, :numeric_code, :mernis_code, :yoksis_code, :continent, :currency_code,
45+
:latitude, :longitude, :phone_code, :region, :start_of_week, :subregion, :un_locode, :world_region
46+
)
4447
end
4548
end
4649
end

app/helpers/continent_helper.rb

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# frozen_string_literal: true
2+
3+
module ContinentHelper
4+
def continents
5+
%w[Afrika Antarktika Asya Avrupa Avusturalya Güney\ Amerika Kuzey\ Amerika]
6+
end
7+
8+
def regions
9+
%w[Afrika Amerika Asya Avrupa Okyanusya]
10+
end
11+
12+
# rubocop:disable Metrics/MethodLength
13+
def subregions
14+
%w[
15+
Avusturalya\ ve\ Yeni\ Zellanda
16+
Batı\ Afrika
17+
Batı\ Asya
18+
Batı\ Avrupa
19+
Doğu\ Afrika
20+
Doğu\ Asya
21+
Doğu\ Avrupa
22+
Güney\ Afrika
23+
Güney\ Amerika
24+
Güney\ Asya
25+
Güney\ Avrupa
26+
Güneydoğu\ Asya
27+
Karayipler
28+
Kuzey\ Afrika
29+
Kuzey\ Amerika
30+
Kuzey\ Avrupa
31+
Melanezya
32+
Mikronezya
33+
Orta\ Afrika
34+
Orta\ Amerika
35+
Orta\ Asya
36+
Polinezya
37+
]
38+
end
39+
# rubocop:enable Metrics/MethodLength
40+
end

app/models/city.rb

+2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ class City < ApplicationRecord
2020

2121
# validations
2222
validates :alpha_2_code, presence: true, uniqueness: true, length: { maximum: 255 }
23+
validates :latitude, numericality: true
24+
validates :longitude, numericality: true
2325
validates :name, presence: true, uniqueness: { scope: %i[country_id] }, length: { maximum: 255 }
2426

2527
# callbacks

app/models/country.rb

+14
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,25 @@ class Country < ApplicationRecord
2222
validates :name, presence: true, uniqueness: true, length: { maximum: 255 }
2323
validates :alpha_2_code, presence: true, uniqueness: true, length: { is: 2 }
2424
validates :alpha_3_code, presence: true, uniqueness: true, length: { is: 3 }
25+
validates :continent, presence: true, length: { maximum: 255 }
26+
validates :currency_code, presence: true, length: { is: 3 }
27+
validates :latitude, numericality: true
28+
validates :longitude, numericality: true
29+
validates :phone_code, length: { maximum: 3 }
30+
validates :region, length: { maximum: 255 }
31+
validates :start_of_week, length: { maximum: 255 }
32+
validates :subregion, length: { maximum: 255 }
2533
validates :numeric_code, presence: true, uniqueness: true, length: { is: 3 },
2634
numericality: { only_integer: true, greater_than: 0 }
2735
validates :mernis_code, allow_nil: true, uniqueness: true, length: { is: 4 },
2836
numericality: { only_integer: true, greater_than: 0 }
37+
validates :sms_delivery_report, inclusion: { in: [true, false] }
38+
validates :sms_alpha_sender_id, inclusion: { in: [true, false] }
39+
validates :sms_unicode, inclusion: { in: [true, false] }
40+
validates :sms_concatenation, inclusion: { in: [true, false] }
41+
validates :un_locode, allow_nil: true, length: { is: 2 }
2942
validates :yoksis_code, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 1 }
43+
validates :world_region, presence: true, length: { maximum: 255 }
3044

3145
private
3246

app/views/location/cities/_form.html.erb

+10
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,15 @@
1111
field: 'alpha_2_code',
1212
width: 12,
1313
required: true
14+
},
15+
{
16+
field: 'latitude',
17+
width: 6,
18+
required: true
19+
},
20+
{
21+
field: 'longitude',
22+
width: 6,
23+
required: true
1424
}
1525
] %>

app/views/location/countries/_form.html.erb

+59-5
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,79 @@
99
},
1010
{
1111
field: 'alpha_2_code',
12-
width: 3,
12+
width: 4,
1313
required: true
1414
},
1515
{
1616
field: 'alpha_3_code',
17-
width: 3,
17+
width: 4,
1818
required: true
1919
},
2020
{
2121
field: 'numeric_code',
22-
width: 3,
22+
width: 4,
2323
required: true
2424
},
2525
{
2626
field: 'mernis_code',
27-
width: 3
27+
width: 4
2828
},
2929
{
3030
field: 'yoksis_code',
31-
width: 3
31+
width: 4
32+
},
33+
{
34+
field: 'un_locode',
35+
width: 4
36+
},
37+
{
38+
field: 'continent',
39+
width: 6,
40+
collection: continents,
41+
required: true,
42+
selected: @country.continent
43+
},
44+
{
45+
field: 'region',
46+
width: 6,
47+
collection: regions,
48+
selected: @country.region
49+
},
50+
{
51+
field: 'subregion',
52+
width: 6,
53+
collection: subregions,
54+
selected: @country.subregion
55+
},
56+
{
57+
field: 'world_region',
58+
width: 6,
59+
collection: %w[APAC EMEA AMER],
60+
selected: @country.world_region
61+
},
62+
{
63+
field: 'currency_code',
64+
width: 6,
65+
required: true
66+
},
67+
{
68+
field: 'phone_code',
69+
width: 6
70+
},
71+
{
72+
field: 'latitude',
73+
width: 4,
74+
required: true
75+
},
76+
{
77+
field: 'longitude',
78+
width: 4,
79+
required: true
80+
},
81+
{
82+
field: 'start_of_week',
83+
width: 4,
84+
collection: %w[Cumartesi Pazar Pazartesi],
85+
selected: @country.start_of_week
3286
}
3387
] %>

app/views/location/countries/show.html.erb

+22-4
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,44 @@
1414
<tr>
1515
<td><%= t('activerecord.attributes.country.name') %></td>
1616
<td><%= @country.name %></td>
17+
<td><%= t('.continent') %> / <%= t('.world_region') %></td>
18+
<td><%= @country.continent %> / <%= @country.world_region %></td>
1719
</tr>
1820
<tr>
19-
<td><%= t('.alpha_2_code') %></td>
20-
<td><%= @country.alpha_2_code %></td>
21+
<td><%= t('.region') %> / <%= t('.subregion') %></td>
22+
<td><%= @country.region %> / <%= @country.subregion %></td>
23+
<td><%= t('.start_of_week') %></td>
24+
<td><%= @country.start_of_week %></td>
2125
</tr>
2226
<tr>
27+
<td><%= t('.alpha_2_code') %></td>
28+
<td><%= @country.alpha_2_code %></td>
2329
<td><%= t('.alpha_3_code') %></td>
2430
<td><%= @country.alpha_3_code %></td>
2531
</tr>
2632
<tr>
2733
<td><%= t('.numeric_code') %></td>
2834
<td><%= @country.numeric_code %></td>
29-
</tr>
30-
<tr>
3135
<td><%= t('.mernis_code') %></td>
3236
<td><%= @country.mernis_code %></td>
3337
</tr>
3438
<tr>
3539
<td><%= t('.yoksis_code') %></td>
3640
<td><%= @country.yoksis_code %></td>
41+
<td><%= t('.currency_code') %></td>
42+
<td><%= @country.currency_code %></td>
43+
</tr>
44+
<tr>
45+
<td><%= t('.phone_code') %></td>
46+
<td><%= @country.phone_code %></td>
47+
<td><%= t('.un_locode') %></td>
48+
<td><%= @country.un_locode %></td>
49+
</tr>
50+
<tr>
51+
<td><%= t('.latitude') %></td>
52+
<td><%= @country.latitude %></td>
53+
<td><%= t('.longitude') %></td>
54+
<td><%= @country.longitude %></td>
3755
</tr>
3856
</tbody>
3957
</table>

0 commit comments

Comments
 (0)