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

Commit

Permalink
Merge pull request #879 from omu/country-regulations
Browse files Browse the repository at this point in the history
Add country specific sms regulations
  • Loading branch information
msdundar authored Mar 22, 2019
2 parents b69b1de + 5821f37 commit f9b0ff9
Show file tree
Hide file tree
Showing 28 changed files with 28,423 additions and 1,799 deletions.
47 changes: 22 additions & 25 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ GIT

GIT
remote: https://github.com/rails/rails.git
revision: 1cdc6c6576afe9a9fa67a6b313080a7dc62188d9
revision: efb706daad0e2e1039c6abb4879c837ef8bf4d10
specs:
actioncable (6.0.0.beta3)
actionpack (= 6.0.0.beta3)
Expand Down Expand Up @@ -63,7 +63,7 @@ GIT
i18n (>= 0.7, < 2)
minitest (~> 5.1)
tzinfo (~> 1.1)
zeitwerk (~> 1.3, >= 1.3.4)
zeitwerk (~> 1.4)
rails (6.0.0.beta3)
actioncable (= 6.0.0.beta3)
actionmailbox (= 6.0.0.beta3)
Expand Down Expand Up @@ -98,9 +98,9 @@ GIT

GIT
remote: https://github.com/rollbar/rollbar-gem.git
revision: 3c66a47be634fb56a32a390ec3b8e32e2b6c49ed
revision: 83ef1acca2b0b1d1b74ff8ef29435ca82e8ca1d6
specs:
rollbar (2.19.2)
rollbar (2.19.3)
multi_json

PATH
Expand Down Expand Up @@ -133,18 +133,17 @@ GEM
io-like (~> 0.3.0)
ast (2.4.0)
aws-eventstream (1.0.2)
aws-partitions (1.144.0)
aws-sdk-core (3.47.0)
aws-partitions (1.145.0)
aws-sdk-core (3.48.2)
aws-eventstream (~> 1.0, >= 1.0.2)
aws-partitions (~> 1.0)
aws-sigv4 (~> 1.1)
http-2 (~> 0.10)
jmespath (~> 1.0)
aws-sdk-kms (1.14.0)
aws-sdk-core (~> 3, >= 3.47.0)
aws-sdk-kms (1.16.0)
aws-sdk-core (~> 3, >= 3.48.2)
aws-sigv4 (~> 1.1)
aws-sdk-s3 (1.32.0)
aws-sdk-core (~> 3, >= 3.47.0)
aws-sdk-s3 (1.34.0)
aws-sdk-core (~> 3, >= 3.48.2)
aws-sdk-kms (~> 1)
aws-sigv4 (~> 1.0)
aws-sigv4 (1.1.0)
Expand All @@ -161,13 +160,13 @@ GEM
bindex (0.5.0)
bootsnap (1.4.1)
msgpack (~> 1.0)
brakeman (4.4.0)
brakeman (4.5.0)
builder (3.2.3)
bundler-audit (0.6.1)
bundler (>= 1.2.0, < 3)
thor (~> 0.18)
byebug (11.0.0)
capybara (3.14.0)
byebug (11.0.1)
capybara (3.15.0)
addressable
mini_mime (>= 0.1.3)
nokogiri (~> 1.8)
Expand Down Expand Up @@ -233,7 +232,6 @@ GEM
activesupport (>= 4.2)
hashdiff (0.3.8)
html_tokenizer (0.0.7)
http-2 (0.10.1)
i18n (1.6.0)
concurrent-ruby (~> 1.0)
image_processing (1.8.0)
Expand Down Expand Up @@ -278,25 +276,24 @@ GEM
nokogiri (1.10.1)
mini_portile2 (~> 2.4.0)
orm_adapter (0.5.0)
pagy (2.1.2)
pagy (2.1.3)
parallel (1.14.0)
parser (2.6.0.0)
parser (2.6.2.0)
ast (~> 2.4.0)
pg (1.1.4)
pg_search (2.1.4)
activerecord (>= 4.2)
activesupport (>= 4.2)
pghero (2.2.0)
activerecord
powerpack (0.1.2)
pry (0.12.2)
coderay (~> 1.1.0)
method_source (~> 0.9.0)
pry-rails (0.3.9)
pry (>= 0.10.4)
psych (3.1.0)
public_suffix (3.0.3)
puma (3.12.0)
puma (3.12.1)
pwned (1.2.1)
rack (2.0.6)
rack-attack (5.4.2)
Expand Down Expand Up @@ -327,15 +324,14 @@ GEM
responders (2.4.1)
actionpack (>= 4.2.0, < 6.0)
railties (>= 4.2.0, < 6.0)
rubocop (0.65.0)
rubocop (0.66.0)
jaro_winkler (~> 1.5.1)
parallel (~> 1.10)
parser (>= 2.5, != 2.5.1.1)
powerpack (~> 0.1)
psych (>= 3.1.0)
rainbow (>= 2.2.2, < 4.0)
ruby-progressbar (~> 1.7)
unicode-display_width (~> 1.4.0)
unicode-display_width (>= 1.4.0, < 1.6)
ruby-progressbar (1.10.0)
ruby-vips (2.0.13)
ffi (~> 1.9)
Expand Down Expand Up @@ -394,7 +390,7 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
unicode-display_width (1.4.1)
unicode-display_width (1.5.0)
uniform_notifier (1.12.1)
warden (1.2.8)
rack (>= 2.0.6)
Expand All @@ -409,10 +405,11 @@ GEM
websocket-driver (0.7.0)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.3)
wicked_pdf (1.1.0)
wicked_pdf (1.2.1)
activesupport
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (1.3.4)
zeitwerk (1.4.0)

PLATFORMS
ruby
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/location/cities_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def set_city
end

def city_params
params.require(:city).permit(:name, :alpha_2_code)
params.require(:city).permit(:name, :alpha_2_code, :latitude, :longitude)
end
end
end
5 changes: 4 additions & 1 deletion app/controllers/location/countries_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,10 @@ def set_country
end

def country_params
params.require(:country).permit(:name, :alpha_2_code, :alpha_3_code, :numeric_code, :mernis_code, :yoksis_code)
params.require(:country).permit(
:name, :alpha_2_code, :alpha_3_code, :numeric_code, :mernis_code, :yoksis_code, :continent, :currency_code,
:latitude, :longitude, :phone_code, :region, :start_of_week, :subregion, :un_locode, :world_region
)
end
end
end
40 changes: 40 additions & 0 deletions app/helpers/continent_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: true

module ContinentHelper
def continents
%w[Afrika Antarktika Asya Avrupa Avusturalya Güney\ Amerika Kuzey\ Amerika]
end

def regions
%w[Afrika Amerika Asya Avrupa Okyanusya]
end

# rubocop:disable Metrics/MethodLength
def subregions
%w[
Avusturalya\ ve\ Yeni\ Zellanda
Batı\ Afrika
Batı\ Asya
Batı\ Avrupa
Doğu\ Afrika
Doğu\ Asya
Doğu\ Avrupa
Güney\ Afrika
Güney\ Amerika
Güney\ Asya
Güney\ Avrupa
Güneydoğu\ Asya
Karayipler
Kuzey\ Afrika
Kuzey\ Amerika
Kuzey\ Avrupa
Melanezya
Mikronezya
Orta\ Afrika
Orta\ Amerika
Orta\ Asya
Polinezya
]
end
# rubocop:enable Metrics/MethodLength
end
2 changes: 2 additions & 0 deletions app/models/city.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class City < ApplicationRecord

# validations
validates :alpha_2_code, presence: true, uniqueness: true, length: { maximum: 255 }
validates :latitude, numericality: true
validates :longitude, numericality: true
validates :name, presence: true, uniqueness: { scope: %i[country_id] }, length: { maximum: 255 }

# callbacks
Expand Down
14 changes: 14 additions & 0 deletions app/models/country.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,25 @@ class Country < ApplicationRecord
validates :name, presence: true, uniqueness: true, length: { maximum: 255 }
validates :alpha_2_code, presence: true, uniqueness: true, length: { is: 2 }
validates :alpha_3_code, presence: true, uniqueness: true, length: { is: 3 }
validates :continent, presence: true, length: { maximum: 255 }
validates :currency_code, presence: true, length: { is: 3 }
validates :latitude, numericality: true
validates :longitude, numericality: true
validates :phone_code, length: { maximum: 3 }
validates :region, length: { maximum: 255 }
validates :start_of_week, length: { maximum: 255 }
validates :subregion, length: { maximum: 255 }
validates :numeric_code, presence: true, uniqueness: true, length: { is: 3 },
numericality: { only_integer: true, greater_than: 0 }
validates :mernis_code, allow_nil: true, uniqueness: true, length: { is: 4 },
numericality: { only_integer: true, greater_than: 0 }
validates :sms_delivery_report, inclusion: { in: [true, false] }
validates :sms_alpha_sender_id, inclusion: { in: [true, false] }
validates :sms_unicode, inclusion: { in: [true, false] }
validates :sms_concatenation, inclusion: { in: [true, false] }
validates :un_locode, allow_nil: true, length: { is: 2 }
validates :yoksis_code, allow_nil: true, numericality: { only_integer: true, greater_than_or_equal_to: 1 }
validates :world_region, presence: true, length: { maximum: 255 }

private

Expand Down
10 changes: 10 additions & 0 deletions app/views/location/cities/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,15 @@
field: 'alpha_2_code',
width: 12,
required: true
},
{
field: 'latitude',
width: 6,
required: true
},
{
field: 'longitude',
width: 6,
required: true
}
] %>
64 changes: 59 additions & 5 deletions app/views/location/countries/_form.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,79 @@
},
{
field: 'alpha_2_code',
width: 3,
width: 4,
required: true
},
{
field: 'alpha_3_code',
width: 3,
width: 4,
required: true
},
{
field: 'numeric_code',
width: 3,
width: 4,
required: true
},
{
field: 'mernis_code',
width: 3
width: 4
},
{
field: 'yoksis_code',
width: 3
width: 4
},
{
field: 'un_locode',
width: 4
},
{
field: 'continent',
width: 6,
collection: continents,
required: true,
selected: @country.continent
},
{
field: 'region',
width: 6,
collection: regions,
selected: @country.region
},
{
field: 'subregion',
width: 6,
collection: subregions,
selected: @country.subregion
},
{
field: 'world_region',
width: 6,
collection: %w[APAC EMEA AMER],
selected: @country.world_region
},
{
field: 'currency_code',
width: 6,
required: true
},
{
field: 'phone_code',
width: 6
},
{
field: 'latitude',
width: 4,
required: true
},
{
field: 'longitude',
width: 4,
required: true
},
{
field: 'start_of_week',
width: 4,
collection: %w[Cumartesi Pazar Pazartesi],
selected: @country.start_of_week
}
] %>
26 changes: 22 additions & 4 deletions app/views/location/countries/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -14,26 +14,44 @@
<tr>
<td><%= t('activerecord.attributes.country.name') %></td>
<td><%= @country.name %></td>
<td><%= t('.continent') %> / <%= t('.world_region') %></td>
<td><%= @country.continent %> / <%= @country.world_region %></td>
</tr>
<tr>
<td><%= t('.alpha_2_code') %></td>
<td><%= @country.alpha_2_code %></td>
<td><%= t('.region') %> / <%= t('.subregion') %></td>
<td><%= @country.region %> / <%= @country.subregion %></td>
<td><%= t('.start_of_week') %></td>
<td><%= @country.start_of_week %></td>
</tr>
<tr>
<td><%= t('.alpha_2_code') %></td>
<td><%= @country.alpha_2_code %></td>
<td><%= t('.alpha_3_code') %></td>
<td><%= @country.alpha_3_code %></td>
</tr>
<tr>
<td><%= t('.numeric_code') %></td>
<td><%= @country.numeric_code %></td>
</tr>
<tr>
<td><%= t('.mernis_code') %></td>
<td><%= @country.mernis_code %></td>
</tr>
<tr>
<td><%= t('.yoksis_code') %></td>
<td><%= @country.yoksis_code %></td>
<td><%= t('.currency_code') %></td>
<td><%= @country.currency_code %></td>
</tr>
<tr>
<td><%= t('.phone_code') %></td>
<td><%= @country.phone_code %></td>
<td><%= t('.un_locode') %></td>
<td><%= @country.un_locode %></td>
</tr>
<tr>
<td><%= t('.latitude') %></td>
<td><%= @country.latitude %></td>
<td><%= t('.longitude') %></td>
<td><%= @country.longitude %></td>
</tr>
</tbody>
</table>
Expand Down
Loading

0 comments on commit f9b0ff9

Please sign in to comment.