geopolitical 2.0.0 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (108) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG.md +28 -0
  3. data/README.md +152 -73
  4. data/app/controllers/geopolitical/application_controller.rb +8 -0
  5. data/app/controllers/geopolitical/cities_controller.rb +44 -10
  6. data/app/controllers/geopolitical/geopolitical_controller.rb +11 -9
  7. data/app/controllers/geopolitical/hoods_controller.rb +47 -9
  8. data/app/controllers/geopolitical/nations_controller.rb +45 -7
  9. data/app/controllers/geopolitical/regions_controller.rb +47 -7
  10. data/app/helpers/geopolitical/application_helper.rb +2 -0
  11. data/app/models/city.rb +149 -48
  12. data/app/models/concerns/geopolitocracy.rb +121 -34
  13. data/app/models/hood.rb +44 -18
  14. data/app/models/nation.rb +96 -17
  15. data/app/models/region.rb +42 -14
  16. data/app/views/geopolitical/cities/_city.html.haml +2 -5
  17. data/app/views/geopolitical/cities/_form.html.haml +25 -28
  18. data/app/views/geopolitical/cities/edit.html.haml +1 -0
  19. data/app/views/geopolitical/cities/index.html.haml +17 -20
  20. data/app/views/geopolitical/cities/new.html.haml +1 -0
  21. data/app/views/geopolitical/cities/show.html.haml +7 -7
  22. data/app/views/geopolitical/geopolitical/index.html.haml +7 -9
  23. data/app/views/geopolitical/hoods/_city.html.haml +2 -5
  24. data/app/views/geopolitical/hoods/_form.html.haml +21 -22
  25. data/app/views/geopolitical/hoods/edit.html.haml +1 -0
  26. data/app/views/geopolitical/hoods/index.html.haml +13 -18
  27. data/app/views/geopolitical/hoods/new.html.haml +1 -0
  28. data/app/views/geopolitical/hoods/show.html.haml +5 -5
  29. data/app/views/geopolitical/nations/_form.html.haml +11 -8
  30. data/app/views/geopolitical/nations/_nation.html.haml +5 -0
  31. data/app/views/geopolitical/nations/edit.html.haml +1 -0
  32. data/app/views/geopolitical/nations/index.html.haml +16 -20
  33. data/app/views/geopolitical/nations/new.html.haml +1 -0
  34. data/app/views/geopolitical/nations/show.html.haml +7 -7
  35. data/app/views/geopolitical/regions/_form.html.haml +10 -8
  36. data/app/views/geopolitical/regions/_region.html.haml +2 -5
  37. data/app/views/geopolitical/regions/edit.html.haml +1 -0
  38. data/app/views/geopolitical/regions/index.html.haml +12 -15
  39. data/app/views/geopolitical/regions/new.html.haml +1 -0
  40. data/app/views/geopolitical/regions/show.html.haml +5 -5
  41. data/app/views/layouts/geopolitical.html.haml +13 -15
  42. data/config/locales/geopolitical.en.yml +76 -0
  43. data/config/locales/geopolitical.pt.yml +77 -0
  44. data/geopolitical.gemspec +14 -12
  45. data/lib/geopolitical/engine.rb +3 -0
  46. data/lib/geopolitical/version.rb +3 -2
  47. data/lib/geopolitical.rb +23 -3
  48. metadata +42 -118
  49. data/.coveralls.yml +0 -1
  50. data/.gitignore +0 -11
  51. data/.rspec +0 -1
  52. data/.travis.yml +0 -26
  53. data/Gemfile +0 -15
  54. data/Guardfile +0 -24
  55. data/Rakefile +0 -25
  56. data/app/serializers/city_serializer.rb +0 -8
  57. data/app/serializers/nation_serializer.rb +0 -4
  58. data/app/serializers/region_serializer.rb +0 -4
  59. data/bin/rails +0 -8
  60. data/lib/tasks/geopolitical_tasks.rake +0 -4
  61. data/spec/dummy/README.rdoc +0 -28
  62. data/spec/dummy/Rakefile +0 -6
  63. data/spec/dummy/app/assets/images/.keep +0 -0
  64. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  65. data/spec/dummy/app/assets/stylesheets/application.css +0 -13
  66. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  67. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  68. data/spec/dummy/app/mailers/.keep +0 -0
  69. data/spec/dummy/app/models/.keep +0 -0
  70. data/spec/dummy/app/models/concerns/.keep +0 -0
  71. data/spec/dummy/app/views/layouts/application.html.erb +0 -14
  72. data/spec/dummy/bin/bundle +0 -3
  73. data/spec/dummy/bin/rails +0 -4
  74. data/spec/dummy/bin/rake +0 -4
  75. data/spec/dummy/config/application.rb +0 -27
  76. data/spec/dummy/config/boot.rb +0 -5
  77. data/spec/dummy/config/environment.rb +0 -5
  78. data/spec/dummy/config/environments/development.rb +0 -29
  79. data/spec/dummy/config/environments/production.rb +0 -80
  80. data/spec/dummy/config/environments/test.rb +0 -36
  81. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  82. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  83. data/spec/dummy/config/initializers/inflections.rb +0 -16
  84. data/spec/dummy/config/initializers/mime_types.rb +0 -5
  85. data/spec/dummy/config/initializers/secret_token.rb +0 -12
  86. data/spec/dummy/config/initializers/session_store.rb +0 -3
  87. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  88. data/spec/dummy/config/locales/en.yml +0 -23
  89. data/spec/dummy/config/mongoid.yml +0 -63
  90. data/spec/dummy/config/routes.rb +0 -56
  91. data/spec/dummy/config.ru +0 -4
  92. data/spec/dummy/lib/assets/.keep +0 -0
  93. data/spec/dummy/log/.keep +0 -0
  94. data/spec/dummy/log/development.log +0 -0
  95. data/spec/dummy/log/test.log +0 -23532
  96. data/spec/dummy/public/404.html +0 -58
  97. data/spec/dummy/public/422.html +0 -58
  98. data/spec/dummy/public/500.html +0 -57
  99. data/spec/dummy/public/favicon.ico +0 -0
  100. data/spec/fabricators/city_fabricator.rb +0 -6
  101. data/spec/fabricators/hood_fabricator.rb +0 -5
  102. data/spec/fabricators/nation_fabricator.rb +0 -4
  103. data/spec/fabricators/region_fabricator.rb +0 -5
  104. data/spec/models/city_spec.rb +0 -158
  105. data/spec/models/hood_spec.rb +0 -47
  106. data/spec/models/nation_spec.rb +0 -53
  107. data/spec/models/region_spec.rb +0 -20
  108. data/spec/spec_helper.rb +0 -57
data/app/models/region.rb CHANGED
@@ -1,32 +1,60 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Represents a region, province, or state within a nation.
1
4
  #
2
- # Region/Province/Estado
3
- #
5
+ # Regions belong to a nation and can have multiple cities. They can also have
6
+ # a designated capital city. Regions inherit common geopolitical attributes
7
+ # from the `Geopolitocracy` concern (like `name`, `abbr`, `slug`, `pop`, `phone`, `postal`).
4
8
  class Region
5
9
  include Mongoid::Document
6
- include Geopolitocracy
10
+ include Geopolitocracy # Provides common geopolitical fields like name, abbr, slug, etc.
7
11
 
12
+ # @!attribute [rw] timezone
13
+ # @return [String, nil] The primary IANA timezone identifier for the region (e.g., "America/New_York").
8
14
  field :timezone, type: String
9
15
 
16
+ # @!attribute [rw] nation
17
+ # @return [Nation] The nation this region belongs to. Required.
10
18
  belongs_to :nation
11
19
 
20
+ # @!attribute [rw] cities
21
+ # @return [Mongoid::Relations::Targets::Enumerable<City>] The cities within this region.
22
+ # Cities are destroyed if the region is destroyed.
12
23
  has_many :cities, dependent: :destroy
13
24
 
14
- belongs_to :capital, inverse_of: :region_capital, class_name: 'City',
15
- optional: true
25
+ # @!attribute [rw] capital
26
+ # @return [City, nil] The capital city of this region. Optional.
27
+ belongs_to :capital, inverse_of: :region_governancy, class_name: 'City', optional: true
16
28
 
17
29
  validates :nation, presence: true
18
- validates :name, uniqueness: { scope: :nation_id }
19
- validates :abbr, uniqueness: { scope: :nation_id, allow_nil: true }
20
-
21
- index abbr: 1
22
- index nation_id: 1, name: 1
23
-
24
- # National dialing code / or International
30
+ validates :name, uniqueness: { scope: :nation_id, message: 'must be unique within its nation' }
31
+ # `abbr` (from Geopolitocracy) should also be unique within its nation if present.
32
+ validates :abbr,
33
+ uniqueness: { scope: :nation_id, allow_nil: true, message: 'must be unique within its nation if provided' }
34
+ # Slug (from Geopolitocracy) should be unique within its nation. Presence is already validated by Geopolitocracy.
35
+ validates :slug, uniqueness: { scope: :nation_id, message: 'must be unique within its nation' }
36
+
37
+ index({ slug: 1 }) # For .search; global uniqueness is not required, see the compound index below
38
+ index({ abbr: 1 }, { sparse: true }) # Sparse index as abbr can be nil
39
+ index({ nation_id: 1, name: 1 }, { unique: true }) # Enforce uniqueness of name within nation
40
+ index({ nation_id: 1, abbr: 1 }, { unique: true, sparse: true }) # Enforce uniqueness of abbr within nation
41
+ index({ nation_id: 1, slug: 1 }, { unique: true }) # Enforce uniqueness of slug within nation
42
+
43
+ # Retrieves the phone dialing code for the region.
44
+ # Falls back to the nation's phone code if the region's is not set.
45
+ # Assumes `phone` field is provided by `Geopolitocracy`.
46
+ #
47
+ # @return [String, nil] The phone dialing code.
25
48
  def phone
26
- self[:phone] || nation.phone
49
+ self[:phone] || nation&.phone
27
50
  end
28
51
 
52
+ # Retrieves the primary postal code scheme or prefix for the region.
53
+ # Falls back to the nation's postal code scheme if the region's is not set.
54
+ # Assumes `postal` field is provided by `Geopolitocracy`.
55
+ #
56
+ # @return [String, nil] The postal code scheme or prefix.
29
57
  def postal
30
- self[:postal] || nation.postal
58
+ self[:postal] || nation&.postal
31
59
  end
32
60
  end
@@ -1,7 +1,4 @@
1
1
  .city
2
- %h4= link_to city.name, city
3
- %span.gray
2
+ %h4= link_to city.name, city_path(city)
4
3
  .right
5
- = link_to "Editar", edit_city_path(city) if admin?
6
- .right
7
- .gray= time_ago_in_words city.created_at
4
+ = link_to t('geopolitical.actions.edit'), edit_city_path(city)
@@ -1,31 +1,28 @@
1
1
  .container
2
2
  .row
3
3
  .page-header
4
- %h1= @city.new_record? ? "Nova Cidade" : "Editando Cidade"
5
- .container_16
6
- .box.secondary.shadow
7
- = form_for(@city, :html => {:class => "form"}) do |f|
8
- - f.object.errors.each do |err|
9
- = err
10
- .grid_3
11
- =# hidden_field_tag 'city_geom_xy', @city.ll, :name => "city[xy]", :class => "geom_xy"
12
- =# hidden_field_tag 'city_geom_y', @city.y, :name => "city[y]", :class => "geom_y"
13
- =# hidden_field_tag 'city_geom_z', @city.z, :name => "city[z]", :class => "geom_z"
14
-
15
- .forms_btns
16
- .citydata
17
- .field{"data-role" => "fieldcontain"}
18
- = f.label :region
19
- = f.select :region_id, @regions
20
- .group
21
- = f.label :name
22
- = f.text_field :name, :size => 30
23
- .group
24
- = f.label :slug
25
- = f.text_field :slug, :size => 30
26
- .field
27
- = f.label :souls
28
- = f.text_field :souls, :size => 30
29
- = f.submit
30
- .grid_8
31
- #map=# gmaps(@map, false, false)
4
+ %h1
5
+ - key = @city.new_record? ? 'new' : 'edit'
6
+ = t("geopolitical.forms.#{key}", model: City.model_name.human)
7
+ .row
8
+ = form_with model: @city, url: (@city.persisted? ? city_path(@city) : cities_path), html: { class: 'form' } do |f|
9
+ - if @city.errors.any?
10
+ %ul
11
+ - @city.errors.full_messages.each do |message|
12
+ %li= message
13
+ .form-group
14
+ = f.label :nation_id
15
+ = f.select :nation_id, @nations, include_blank: true
16
+ .form-group
17
+ = f.label :region_id
18
+ = f.select :region_id, @regions, include_blank: true
19
+ .form-group
20
+ = f.label :name
21
+ = f.text_field :name
22
+ .form-group
23
+ = f.label :slug
24
+ = f.text_field :slug
25
+ .form-group
26
+ = f.label :souls
27
+ = f.number_field :souls
28
+ = f.submit t('geopolitical.actions.save')
@@ -0,0 +1 @@
1
+ = render 'form'
@@ -1,35 +1,32 @@
1
1
  .container
2
2
  .row
3
3
  .page-header
4
- %h1.title Cities
5
- =# render "shared/filter"
6
- = link_to "New City", new_city_path
4
+ %h1.title= City.model_name.human(count: 2)
5
+ = link_to t('geopolitical.actions.new', model: City.model_name.human), new_city_path
7
6
  .row
8
7
  .content
9
8
  %table.table
10
9
  %thead
11
10
  %tr
12
- %th Nome
13
- %th ZIP
14
- %th Region
15
- %th Nation
16
- %th Population
11
+ %th= City.human_attribute_name(:name)
12
+ %th= City.human_attribute_name(:postal)
13
+ %th= City.human_attribute_name(:region_id)
14
+ %th= City.human_attribute_name(:nation_id)
15
+ %th= City.human_attribute_name(:souls)
17
16
  %th
18
17
  %tbody
19
- - for city in @cities
18
+ - @cities.each do |city|
20
19
  %tr
21
20
  %td
22
21
  = city.name
23
- = link_to city.slug , city
24
- %td= city.zip
25
- %td= city.region.name if city.region
26
- %td= city.nation.name
22
+ = link_to city.slug, city_path(city)
23
+ %td= city.postal
24
+ %td= city.region&.name
25
+ %td= city.nation&.name
27
26
  %td= city.souls
28
- %td{:align => 'right'}
29
- = link_to 'Edit', edit_city_path(city)
30
- = link_to 'Destroy', city, :confirm => 'Destroy city?', :method => :delete
31
-
27
+ %td{align: 'right'}
28
+ = link_to t('geopolitical.actions.edit'), edit_city_path(city)
29
+ = button_to t('geopolitical.actions.destroy'), city_path(city), method: :delete,
30
+ data: { turbo_confirm: t('geopolitical.actions.confirm_destroy', model: City.model_name.human) }
32
31
  .row
33
- .pagination= paginate @cities
34
- .row
35
- = link_to 'Back', root_path
32
+ = link_to t('geopolitical.actions.back'), root_path
@@ -0,0 +1 @@
1
+ = render 'form'
@@ -3,15 +3,15 @@
3
3
  %h1= @city.name
4
4
  .row
5
5
  %p
6
- %b Slug:
6
+ %b #{City.human_attribute_name(:slug)}:
7
7
  = @city.slug
8
8
  %p
9
- %b Nation:
10
- = link_to @city.nation, @city.nation
9
+ %b #{City.human_attribute_name(:nation_id)}:
10
+ = link_to @city.nation, nation_path(@city.nation) if @city.nation
11
11
  %p
12
- %b Region:
13
- = link_to @city.region, @city.region
12
+ %b #{City.human_attribute_name(:region_id)}:
13
+ = link_to @city.region, region_path(@city.region) if @city.region
14
14
  .row
15
- = link_to 'Edit', edit_city_path(@city)
15
+ = link_to t('geopolitical.actions.edit'), edit_city_path(@city)
16
16
  |
17
- = link_to 'Back', cities_path
17
+ = link_to t('geopolitical.actions.back'), cities_path
@@ -1,21 +1,19 @@
1
- %h1 Geopolitical
1
+ %h1= t('geopolitical.title')
2
2
  %hr
3
3
 
4
4
  - [Nation, Region, City, Hood].each do |klass|
5
5
  .block
6
6
  %h3.title
7
- = link_to klass.model_name.human.pluralize, send("#{klass.to_s.downcase.pluralize}_path")
7
+ = link_to klass.model_name.human(count: 2), send("#{klass.to_s.downcase.pluralize}_path")
8
8
  %small= klass.count
9
9
  .right.links
10
- = link_to "+ #{klass.model_name.human}", send("new_#{klass.to_s.downcase}_path"), :class => "small blue nice button radius"
11
-
10
+ = link_to t('geopolitical.actions.new', model: klass.model_name.human),
11
+ send("new_#{klass.to_s.downcase}_path")
12
12
 
13
13
  %br
14
14
  %h4
15
- Use Geonames_local to populate data easily!
16
- %small= link_to "geonames_local", "http://github.com/nofxx/geonames_local"
15
+ = t('geopolitical.dashboard.populate')
16
+ %small= link_to 'geonames_local', 'https://github.com/nofxx/geonames_local'
17
17
 
18
18
  %hr
19
- %p Minimalist layout by NoCSS Co.
20
- %p= link_to "fireho/geopolitical", "http://github.com/fireho/geopolitical"
21
- %p= link_to "< Back", "/"
19
+ %p= link_to 'fireho/geopolitical', 'https://github.com/fireho/geopolitical'
@@ -1,7 +1,4 @@
1
1
  .hood
2
- %h4= link_to hood.name, hood
3
- %span.gray
2
+ %h4= link_to hood.name, hood_path(hood)
4
3
  .right
5
- = link_to "Editar", edit_hood_path(hood) if admin?
6
- .right
7
- .gray= time_ago_in_words hood.created_at
4
+ = link_to t('geopolitical.actions.edit'), edit_hood_path(hood)
@@ -1,27 +1,26 @@
1
1
  .container
2
2
  .row
3
3
  .page-header
4
- %h1= @hood.new_record? ? "New Hood" : "Editing Hood"
4
+ %h1
5
+ - key = @hood.new_record? ? 'new' : 'edit'
6
+ = t("geopolitical.forms.#{key}", model: Hood.model_name.human)
5
7
  .row
6
8
  .content
7
- = form_for(@hood, :html => {:class => "form"}) do |f|
8
- - f.object.errors.each do |err|
9
- = err
10
- .grid_3
11
- .forms_btns
12
- .hooddata
13
- .field{"data-role" => "fieldcontain"}
14
- = f.label :city
15
- = f.select :city_id, @cities
16
- .group
17
- = f.label :name
18
- = f.text_field :name, :size => 30
19
- .group
20
- = f.label :slug
21
- = f.text_field :slug, :size => 30
22
- .field
23
- = f.label :souls
24
- = f.text_field :souls, :size => 30
25
- = f.submit
26
- .grid_8
27
- #map=# gmaps(@map, false, false)
9
+ = form_with model: @hood, url: (@hood.persisted? ? hood_path(@hood) : hoods_path), html: { class: 'form' } do |f|
10
+ - if @hood.errors.any?
11
+ %ul
12
+ - @hood.errors.full_messages.each do |message|
13
+ %li= message
14
+ .form-group
15
+ = f.label :city_id
16
+ = f.select :city_id, @cities, include_blank: true
17
+ .form-group
18
+ = f.label :name
19
+ = f.text_field :name
20
+ .form-group
21
+ = f.label :slug
22
+ = f.text_field :slug
23
+ .form-group
24
+ = f.label :souls
25
+ = f.number_field :souls
26
+ = f.submit t('geopolitical.actions.save')
@@ -0,0 +1 @@
1
+ = render 'form'
@@ -1,33 +1,28 @@
1
1
  .container
2
2
  .row
3
3
  .page-header
4
- %h1.title Hoods
5
- =# render "shared/filter"
6
- = link_to "New Hood", new_hood_path
4
+ %h1.title= Hood.model_name.human(count: 2)
5
+ = link_to t('geopolitical.actions.new', model: Hood.model_name.human), new_hood_path
7
6
  .row
8
7
  .content
9
8
  %table.table
10
9
  %thead
11
10
  %tr
12
- %th Nome
13
- %th Region
14
- %th Nation
15
- %th Population
11
+ %th= Hood.human_attribute_name(:name)
12
+ %th= Hood.human_attribute_name(:city_id)
13
+ %th= Hood.human_attribute_name(:souls)
16
14
  %th
17
15
  %tbody
18
- - for hood in @hoods
16
+ - @hoods.each do |hood|
19
17
  %tr
20
18
  %td
21
19
  = hood.name
22
- = link_to hood.slug , hood
23
- %td= hood.city.name if hood.city
24
- %td= hood.city.name
20
+ = link_to hood.slug, hood_path(hood)
21
+ %td= hood.city&.name
25
22
  %td= hood.souls
26
- %td{:align => 'right'}
27
- = link_to 'Edit', edit_hood_path(hood)
28
- = link_to 'Destroy', hood, :confirm => 'Destroy hood?', :method => :delete
29
-
23
+ %td{align: 'right'}
24
+ = link_to t('geopolitical.actions.edit'), edit_hood_path(hood)
25
+ = button_to t('geopolitical.actions.destroy'), hood_path(hood), method: :delete,
26
+ data: { turbo_confirm: t('geopolitical.actions.confirm_destroy', model: Hood.model_name.human) }
30
27
  .row
31
- .pagination= paginate @hoods
32
- .row
33
- = link_to 'Back', root_path
28
+ = link_to t('geopolitical.actions.back'), root_path
@@ -0,0 +1 @@
1
+ = render 'form'
@@ -3,12 +3,12 @@
3
3
  %h1= @hood.name
4
4
  .row
5
5
  %p
6
- %b Slug:
6
+ %b #{Hood.human_attribute_name(:slug)}:
7
7
  = @hood.slug
8
8
  %p
9
- %b City:
10
- = link_to @hood.city, @hood.city
9
+ %b #{Hood.human_attribute_name(:city_id)}:
10
+ = link_to @hood.city, city_path(@hood.city) if @hood.city
11
11
  .row
12
- = link_to 'Edit', edit_hood_path(@hood)
12
+ = link_to t('geopolitical.actions.edit'), edit_hood_path(@hood)
13
13
  |
14
- = link_to 'Back', hood_path
14
+ = link_to t('geopolitical.actions.back'), hoods_path
@@ -1,11 +1,15 @@
1
1
  .container
2
2
  .row
3
3
  .page-header
4
- %h1= @nation.new_record? ? "New Nation" : "Editing '#{@nation}'"
4
+ %h1
5
+ - key = @nation.new_record? ? 'new' : 'edit'
6
+ = t("geopolitical.forms.#{key}", model: Nation.model_name.human)
5
7
  .row
6
-
7
- = form_for(@nation) do |f|
8
- =# f.error_messages
8
+ = form_with model: @nation, url: (@nation.persisted? ? nation_path(@nation) : nations_path) do |f|
9
+ - if @nation.errors.any?
10
+ %ul
11
+ - @nation.errors.full_messages.each do |message|
12
+ %li= message
9
13
  .form-group
10
14
  = f.label :name
11
15
  = f.text_field :name
@@ -19,8 +23,7 @@
19
23
  = f.label :lang
20
24
  = f.text_field :lang
21
25
  .form-group
22
- = f.label :abbr
23
- = f.text_field :abbr
24
-
26
+ = f.label :cash
27
+ = f.text_field :cash
25
28
  .forms-buttons
26
- = f.submit
29
+ = f.submit t('geopolitical.actions.save')
@@ -0,0 +1,5 @@
1
+ .nation
2
+ %h4= link_to nation.name, nation_path(nation)
3
+ %span.gray= nation.abbr
4
+ .right
5
+ = link_to t('geopolitical.actions.edit'), edit_nation_path(nation)
@@ -0,0 +1 @@
1
+ = render 'form'
@@ -1,36 +1,32 @@
1
1
  .container
2
2
  .row
3
3
  .page-header
4
- %h1.title Nations
5
- =# render "shared/filter"
6
- = link_to "New Nation", new_nation_path
4
+ %h1.title= Nation.model_name.human(count: 2)
5
+ = link_to t('geopolitical.actions.new', model: Nation.model_name.human), new_nation_path
7
6
  .row
8
7
  .content
9
8
  %table.table
10
9
  %thead
11
10
  %tr
12
- %th Abbr
13
- %th ISO
14
- %th Name
15
- %th Postal
16
- %th Lang
17
- %th Cash
11
+ %th= Nation.human_attribute_name(:abbr)
12
+ %th= Nation.human_attribute_name(:code3)
13
+ %th= Nation.human_attribute_name(:name)
14
+ %th= Nation.human_attribute_name(:postal)
15
+ %th= Nation.human_attribute_name(:lang)
16
+ %th= Nation.human_attribute_name(:cash)
18
17
  %th
19
18
  %tbody
20
- - for nation in @nations
19
+ - @nations.each do |nation|
21
20
  %tr
22
- %td
23
- =# image_tag nation.flag.nano if nation.flag?
24
- = nation.abbr
25
- %td= nation.code
21
+ %td= nation.abbr
22
+ %td= nation.code3.presence || nation.code
26
23
  %td
27
24
  = nation.name
28
- = link_to nation.slug, nation
29
- %td= nation.zip
30
- %td= truncate(nation.lang)
25
+ = link_to nation.slug, nation_path(nation)
26
+ %td= nation.postal
27
+ %td= truncate(nation.lang.to_s)
31
28
  %td= nation.cash
32
29
  %td.last
33
- =# link_to "Destroy!", nation_path(nation), :method => :delete
34
- = link_to "Edit", edit_nation_path(nation)
30
+ = link_to t('geopolitical.actions.edit'), edit_nation_path(nation)
35
31
  .row
36
- = link_to 'Voltar', root_path
32
+ = link_to t('geopolitical.actions.back'), root_path
@@ -0,0 +1 @@
1
+ = render 'form'
@@ -3,18 +3,18 @@
3
3
  %h1= @nation.name
4
4
  .row
5
5
  %p
6
- %b Abbr:
7
- #{@nation.abbr} #{@nation.code}
6
+ %b #{Nation.human_attribute_name(:abbr)}:
7
+ #{@nation.abbr} #{@nation.code3}
8
8
  %p
9
- %b Slug:
9
+ %b #{Nation.human_attribute_name(:slug)}:
10
10
  = @nation.slug
11
11
  %p
12
- %b Lang:
12
+ %b #{Nation.human_attribute_name(:lang)}:
13
13
  = @nation.lang
14
14
  %p
15
- %b Cash:
15
+ %b #{Nation.human_attribute_name(:cash)}:
16
16
  = @nation.cash
17
17
  .row
18
- = link_to 'Edit', edit_nation_path(@nation)
18
+ = link_to t('geopolitical.actions.edit'), edit_nation_path(@nation)
19
19
  |
20
- = link_to 'Back', nations_path
20
+ = link_to t('geopolitical.actions.back'), nations_path
@@ -1,12 +1,15 @@
1
1
  .container
2
2
  .row
3
3
  .page-header
4
- %h1= @region.new_record? ? "New Region" : "Editing '#{@region}'"
4
+ %h1
5
+ - key = @region.new_record? ? 'new' : 'edit'
6
+ = t("geopolitical.forms.#{key}", model: Region.model_name.human)
5
7
  .row
6
-
7
- = form_for(@region) do |f|
8
- - f.object.errors.each do |err|
9
- = err
8
+ = form_with model: @region, url: (@region.persisted? ? region_path(@region) : regions_path) do |f|
9
+ - if @region.errors.any?
10
+ %ul
11
+ - @region.errors.full_messages.each do |message|
12
+ %li= message
10
13
  .form-group
11
14
  = f.label :name
12
15
  = f.text_field :name
@@ -18,7 +21,6 @@
18
21
  = f.text_field :slug
19
22
  .form-group
20
23
  = f.label :nation_id
21
- = f.select :nation_id, @nations
22
-
24
+ = f.select :nation_id, @nations, include_blank: true
23
25
  .forms-buttons
24
- = f.submit
26
+ = f.submit t('geopolitical.actions.save')
@@ -1,7 +1,4 @@
1
1
  .region
2
- %h4= link_to region.name, region
3
- %span.gray
2
+ %h4= link_to region.name, region_path(region)
4
3
  .right
5
- .gray= time_ago_in_words region.created_at
6
- .right
7
- = link_to "Editar", edit_region_path(region) if admin?
4
+ = link_to t('geopolitical.actions.edit'), edit_region_path(region)
@@ -0,0 +1 @@
1
+ = render 'form'
@@ -1,31 +1,28 @@
1
1
  .container
2
2
  .row
3
3
  .page-header
4
- %h1.title Regions
5
- =# render "shared/filter"
6
- = link_to "New Regions", new_region_path
4
+ %h1.title= Region.model_name.human(count: 2)
5
+ = link_to t('geopolitical.actions.new', model: Region.model_name.human), new_region_path
7
6
  .row
8
7
  .content
9
8
  %table.table
10
9
  %thead
11
10
  %tr
12
- %th Abbr
13
- %th Name
14
- %th Country
15
- %th Cities
11
+ %th= Region.human_attribute_name(:abbr)
12
+ %th= Region.human_attribute_name(:name)
13
+ %th= Region.human_attribute_name(:nation_id)
14
+ %th= Region.human_attribute_name(:cities)
16
15
  %th
17
16
  %tbody
18
- - for region in @regions
17
+ - @regions.each do |region|
19
18
  %tr
20
- %td
21
- = region.abbr
19
+ %td= region.abbr
22
20
  %td
23
21
  = region.name
24
- = link_to region.slug, region
25
- %td= region.nation.try(:name)
22
+ = link_to region.slug, region_path(region)
23
+ %td= region.nation&.name
26
24
  %td= region.cities.count
27
25
  %td.last
28
- =# link_to "Destroy!", nation_path(nation), :method => :delete
29
- = link_to 'Edit', edit_region_path(region)
26
+ = link_to t('geopolitical.actions.edit'), edit_region_path(region)
30
27
  .row
31
- = link_to 'Back', root_path
28
+ = link_to t('geopolitical.actions.back'), root_path
@@ -0,0 +1 @@
1
+ = render 'form'
@@ -3,15 +3,15 @@
3
3
  %h1= @region.name
4
4
  .row
5
5
  %p
6
- %b Slug:
6
+ %b #{Region.human_attribute_name(:slug)}:
7
7
  = @region.slug
8
8
  %p
9
- %b Nation:
9
+ %b #{Region.human_attribute_name(:nation_id)}:
10
10
  = link_to @region.nation, @region.nation
11
11
  %p
12
- %b Sigla:
12
+ %b #{Region.human_attribute_name(:abbr)}:
13
13
  = @region.abbr
14
14
  .row
15
- = link_to 'Edit', edit_region_path(@region)
15
+ = link_to t('geopolitical.actions.edit'), edit_region_path(@region)
16
16
  |
17
- = link_to 'Back', regions_path
17
+ = link_to t('geopolitical.actions.back'), regions_path