gaku_core 0.2.2 → 0.2.3
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.
- checksums.yaml +4 -4
- data/app/controllers/gaku/core_controller.rb +3 -0
- data/app/models/gaku/country.rb +11 -1
- data/app/models/gaku/preset.rb +17 -0
- data/app/models/gaku/state.rb +14 -1
- data/db/default/gaku/countries.rb +14 -0
- data/db/default/gaku/presets.rb +1 -1
- data/db/default/gaku/states.rb +9 -0
- data/db/migrate/20150213095508_improve_countries_and_states.rb +5 -0
- data/lib/gaku/core.rb +1 -0
- metadata +19 -4
- data/db/default/gaku/countries.yml +0 -1357
- data/db/default/gaku/states.yml +0 -494
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 62259b8d3e4b700989fae5be8df0837d8898f000
|
4
|
+
data.tar.gz: 907f6db5e00791e00700934cadfde7fad86d0d18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bf1951ae5cb1c4d6dad60d38584fb7cd4e64ff5de3a462b077f28566b28999445c6d306459bbc1dbeba7f404c0ca93ea5dfd487fe0ea1a4f3ae41fd800e7409
|
7
|
+
data.tar.gz: 2af760ba5e089c8496df12b6e14af6a298e30a83420541546604ffb6c5013271e2e9ab1e5ddd161ed53d36aa395cd2c716c5a5e180d5f831529b22a148c6821e
|
@@ -34,12 +34,15 @@ module Gaku
|
|
34
34
|
def set_locale
|
35
35
|
if current_user && params[:locale]
|
36
36
|
I18n.locale = params[:locale]
|
37
|
+
Carmen.i18n_backend.locale = I18n.locale
|
37
38
|
current_user.settings[:locale] = params[:locale]
|
38
39
|
notice = "Language is set to #{t('languages.' + current_user.locale)}"
|
39
40
|
flash[:notice] = notice if current_user.save
|
40
41
|
elsif current_user
|
41
42
|
I18n.locale = current_user.settings[:locale]
|
43
|
+
Carmen.i18n_backend.locale = I18n.locale
|
42
44
|
else
|
45
|
+
Carmen.i18n_backend.locale = I18n.default_locale
|
43
46
|
I18n.default_locale
|
44
47
|
end
|
45
48
|
end
|
data/app/models/gaku/country.rb
CHANGED
data/app/models/gaku/preset.rb
CHANGED
@@ -44,5 +44,22 @@ module Gaku
|
|
44
44
|
active.address[key.to_s] unless active.nil?
|
45
45
|
end
|
46
46
|
|
47
|
+
def self.state
|
48
|
+
if active
|
49
|
+
State.find(active.address['state'])
|
50
|
+
else
|
51
|
+
State.first
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def self.country
|
56
|
+
if active
|
57
|
+
Country.find(active.address['country'])
|
58
|
+
else
|
59
|
+
Country.first
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
47
64
|
end
|
48
65
|
end
|
data/app/models/gaku/state.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
module Gaku
|
2
2
|
class State < ActiveRecord::Base
|
3
|
+
|
4
|
+
default_scope { order(:abbr) }
|
5
|
+
|
3
6
|
has_many :addresses
|
4
7
|
|
5
8
|
belongs_to :country, foreign_key: :country_iso, primary_key: :iso
|
@@ -26,7 +29,17 @@ module Gaku
|
|
26
29
|
end
|
27
30
|
|
28
31
|
def to_s
|
29
|
-
|
32
|
+
i18n_name
|
33
|
+
end
|
34
|
+
|
35
|
+
def i18n_name
|
36
|
+
carmen_country = Carmen::Country.coded(country_iso)
|
37
|
+
if carmen_country && carmen_country.subregions? && carmen_country.subregions.coded(abbr)
|
38
|
+
carmen_country.subregions.coded(abbr).name
|
39
|
+
else
|
40
|
+
name
|
41
|
+
end
|
30
42
|
end
|
43
|
+
|
31
44
|
end
|
32
45
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
require 'carmen'
|
2
|
+
|
3
|
+
Carmen::Country.all.each do |country|
|
4
|
+
unless Gaku::Country.exists?(iso: country.alpha_2_code)
|
5
|
+
|
6
|
+
Gaku::Country.create!(name: country.name,
|
7
|
+
iso3: country.alpha_3_code,
|
8
|
+
iso: country.alpha_2_code,
|
9
|
+
iso_name: country.name.upcase,
|
10
|
+
numcode: country.numeric_code,
|
11
|
+
states_required: country.subregions?)
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
data/db/default/gaku/presets.rb
CHANGED
@@ -12,7 +12,7 @@ if Gaku::Preset.count.zero?
|
|
12
12
|
changes: 25 },
|
13
13
|
person: { gender: true },
|
14
14
|
student: { id_code: '%year-%yearly_serial', increment_foreign_id_code: 1 },
|
15
|
-
address: { country: '
|
15
|
+
address: { country: '114', state: '1308', city: 'Nagoya' },
|
16
16
|
grading: { scheme: '', method: '' },
|
17
17
|
export_formats: { spreadsheets: 'xls', printables: 'pdf', documents: 'xls' },
|
18
18
|
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Gaku::Country.where(states_required: true).each do |country|
|
2
|
+
carmen_country = Carmen::Country.named(country.name)
|
3
|
+
|
4
|
+
carmen_country.subregions.each do |subregion|
|
5
|
+
unless Gaku::State.exists?(name: subregion.name, country_iso: country.iso)
|
6
|
+
Gaku::State.create!(name: subregion.name, abbr: subregion.code, country_iso: country.iso)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
data/lib/gaku/core.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gaku_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rei Kagetsuki
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-
|
14
|
+
date: 2015-03-27 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -69,6 +69,20 @@ dependencies:
|
|
69
69
|
- - "~>"
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: '3.2'
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: carmen
|
74
|
+
requirement: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - "~>"
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.0.2
|
79
|
+
type: :runtime
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - "~>"
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: 1.0.2
|
72
86
|
- !ruby/object:Gem::Dependency
|
73
87
|
name: globalize
|
74
88
|
requirement: !ruby/object:Gem::Requirement
|
@@ -406,14 +420,14 @@ files:
|
|
406
420
|
- db/default/gaku/attendance_types.rb
|
407
421
|
- db/default/gaku/commute_method_types.rb
|
408
422
|
- db/default/gaku/contact_types.yml
|
409
|
-
- db/default/gaku/countries.
|
423
|
+
- db/default/gaku/countries.rb
|
410
424
|
- db/default/gaku/departments.rb
|
411
425
|
- db/default/gaku/enrollment_status.rb
|
412
426
|
- db/default/gaku/master_school.rb
|
413
427
|
- db/default/gaku/presets.rb
|
414
428
|
- db/default/gaku/roles.yml
|
415
429
|
- db/default/gaku/scholarship_statuses.rb
|
416
|
-
- db/default/gaku/states.
|
430
|
+
- db/default/gaku/states.rb
|
417
431
|
- db/migrate/20120202111850_presets.rb
|
418
432
|
- db/migrate/20131014065028_translations.rb
|
419
433
|
- db/migrate/20131025073352_gaku_core.rb
|
@@ -437,6 +451,7 @@ files:
|
|
437
451
|
- db/migrate/20140715135152_create_semester_attendance_table.rb
|
438
452
|
- db/migrate/20140718105226_create_student_review_categories_table.rb
|
439
453
|
- db/migrate/20140728121353_create_student_review_table.rb
|
454
|
+
- db/migrate/20150213095508_improve_countries_and_states.rb
|
440
455
|
- db/schema.rb
|
441
456
|
- db/seeds.rb
|
442
457
|
- lib/gaku/class_name_detector.rb
|