gaku 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/admin/app/assets/javascripts/gaku/admin/base.js.coffee +12 -1
- data/admin/app/controllers/gaku/admin/campuses/addresses_controller.rb +2 -0
- data/admin/app/controllers/gaku/admin/presets_controller.rb +18 -1
- data/admin/app/controllers/gaku/admin/states_list_controller.rb +20 -0
- data/admin/app/helpers/gaku/shared_helper.rb +14 -4
- data/admin/app/views/gaku/admin/campuses/addresses/_addresses.html.slim +1 -1
- data/admin/app/views/gaku/admin/campuses/addresses/_form_fields.html.slim +10 -11
- data/admin/app/views/gaku/admin/home/index.html.slim +4 -3
- data/admin/app/views/gaku/admin/presets/_address.html.slim +4 -2
- data/admin/app/views/gaku/admin/presets/_no_states_select.html.slim +1 -0
- data/admin/app/views/gaku/admin/presets/_states_select.html.slim +3 -0
- data/admin/app/views/gaku/admin/presets/edit.js.erb +7 -1
- data/admin/app/views/gaku/admin/presets/states_list.js.erb +5 -0
- data/admin/app/views/gaku/admin/states_list/_no_states_select.html.slim +4 -0
- data/admin/app/views/gaku/admin/states_list/_states_select.html.slim +3 -0
- data/admin/app/views/gaku/admin/states_list/index.js.erb +5 -0
- data/admin/config/routes.rb +5 -3
- data/admin/gaku_admin.gemspec +2 -2
- data/admin/lib/tasks/admin_user.rake +3 -2
- data/admin/spec/features/presets/address_preset_spec.rb +6 -6
- data/admin/spec/features/schools/campuses/addresses_spec.rb +3 -3
- data/common_gaku_dependencies.rb +1 -1
- data/core/app/controllers/gaku/core_controller.rb +3 -0
- data/core/app/models/gaku/country.rb +11 -1
- data/core/app/models/gaku/preset.rb +17 -0
- data/core/app/models/gaku/state.rb +14 -1
- data/core/db/default/gaku/countries.rb +14 -0
- data/core/db/default/gaku/presets.rb +1 -1
- data/core/db/default/gaku/states.rb +9 -0
- data/core/db/migrate/20150213095508_improve_countries_and_states.rb +5 -0
- data/core/gaku_core.gemspec +1 -0
- data/core/lib/gaku/core.rb +1 -0
- data/frontend/app/assets/javascripts/gaku/frontend/base.js.coffee +12 -1
- data/frontend/app/controllers/gaku/addresses_controller.rb +3 -2
- data/{admin/app/controllers/gaku/states_controller.rb → frontend/app/controllers/gaku/states_list_controller.rb} +6 -4
- data/frontend/app/views/gaku/addresses/_form_fields.html.slim +2 -3
- data/frontend/app/views/gaku/addresses/edit.js.erb +1 -1
- data/frontend/app/views/gaku/home/index.html.slim +1 -3
- data/frontend/app/views/gaku/states_list/_no_states_select.html.slim +4 -0
- data/frontend/app/views/gaku/states_list/_states_select.html.slim +3 -0
- data/frontend/app/views/gaku/states_list/index.js.erb +5 -0
- data/frontend/config/routes.rb +2 -0
- data/frontend/gaku_frontend.gemspec +2 -2
- data/sample/lib/shared_sample_data.rb +1 -1
- metadata +27 -23
- data/admin/app/views/gaku/states/_no_states_select.html.slim +0 -1
- data/admin/app/views/gaku/states/_states_select.html.slim +0 -1
- data/admin/app/views/gaku/states/index.js.erb +0 -5
- data/core/db/default/gaku/countries.yml +0 -1357
- data/core/db/default/gaku/states.yml +0 -494
- data/frontend/app/controllers/gaku/states_controller.rb +0 -17
- data/frontend/app/views/gaku/states/_no_states_select.html.slim +0 -1
- data/frontend/app/views/gaku/states/_states_select.html.slim +0 -1
- data/frontend/app/views/gaku/states/index.js.erb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dbff8e8ff7cf34e1fe4acb9ecb46a37454abd4a2
|
4
|
+
data.tar.gz: f2e535cb9bddff0a65bbd344a34578f20a48ccbc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 524ce4dc1e52790b22fffb7e69f9543b4fcf3396a9e9ed4962ffb4683541c890680b9a8596b8f1997da566fe08180bc5cd909e2c362563967c39718bb31676c7
|
7
|
+
data.tar.gz: 64afc20707a2fa9b66264a67b2973f5756cb87a7b462e7abcd758fae3a161d154a25dafe9a05526c03b375e22eb0c40478f3849db8e3d2035ba37611d3f1e6d9
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
@@ -26,12 +26,23 @@ $.fn.datepicker_i18n = ->
|
|
26
26
|
|
27
27
|
$.fn.datepicker.defaults.format = "yyyy-mm-dd"
|
28
28
|
|
29
|
+
window.load_preset_states = (preset_id)->
|
30
|
+
countryCode = $("#country_dropdown option:selected").val()
|
31
|
+
if countryCode
|
32
|
+
$.ajax
|
33
|
+
type: 'get'
|
34
|
+
url: '/admin/presets/states_list'
|
35
|
+
dataType: 'script'
|
36
|
+
data:
|
37
|
+
country_id: countryCode
|
38
|
+
preset_id: preset_id
|
39
|
+
|
29
40
|
window.load_states = ->
|
30
41
|
countryCode = $("#country_dropdown option:selected").val()
|
31
42
|
if countryCode
|
32
43
|
$.ajax
|
33
44
|
type: 'get'
|
34
|
-
url: '/
|
45
|
+
url: '/admin/states_list'
|
35
46
|
dataType: 'script'
|
36
47
|
data:
|
37
48
|
country_id: countryCode
|
@@ -2,7 +2,7 @@ module Gaku
|
|
2
2
|
class Admin::PresetsController < Admin::BaseController
|
3
3
|
|
4
4
|
respond_to :js, only: %i( index edit update )
|
5
|
-
before_action :set_preset, except:
|
5
|
+
before_action :set_preset, except: %i( index states_list )
|
6
6
|
|
7
7
|
def index
|
8
8
|
@presets = Preset.all
|
@@ -13,6 +13,8 @@ module Gaku
|
|
13
13
|
def edit
|
14
14
|
@per_page_values = [10, 25, 50, 100]
|
15
15
|
@countries = Country.all
|
16
|
+
@country = @preset['address']['country'] ? Country.find(@preset['address']['country']) : Country.first
|
17
|
+
@state = @preset['address']['state'] ? State.find(@preset['address']['state']) : nil
|
16
18
|
end
|
17
19
|
|
18
20
|
def update
|
@@ -20,6 +22,21 @@ module Gaku
|
|
20
22
|
respond_with @preset, location: [:edit, :admin, @preset]
|
21
23
|
end
|
22
24
|
|
25
|
+
def states_list
|
26
|
+
if params[:country_id]
|
27
|
+
@country = Country.find(params[:country_id])
|
28
|
+
|
29
|
+
if params[:preset_id]
|
30
|
+
@preset = Preset.find(params[:preset_id])
|
31
|
+
@state = @preset['address']['state'] ? State.find(@preset['address']['state']) : nil
|
32
|
+
end
|
33
|
+
|
34
|
+
@states = State.where(country_iso: @country.iso)
|
35
|
+
else
|
36
|
+
@states = State.all
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
23
40
|
private
|
24
41
|
|
25
42
|
def preset_params
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module Gaku
|
2
|
+
module Admin
|
3
|
+
class StatesListController < Admin::BaseController
|
4
|
+
|
5
|
+
respond_to :js, :json
|
6
|
+
|
7
|
+
def index
|
8
|
+
if params[:country_id]
|
9
|
+
@country = Country.find(params[:country_id])
|
10
|
+
|
11
|
+
@states = State.where(country_iso: @country.iso).order('name asc')
|
12
|
+
@state = Preset.state
|
13
|
+
else
|
14
|
+
@states = State.all
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -9,12 +9,22 @@ module Gaku
|
|
9
9
|
{ t(:'gender.female') => false, t(:'gender.male') => true }
|
10
10
|
end
|
11
11
|
|
12
|
-
def state_load(
|
13
|
-
|
12
|
+
def state_load(country_preset)
|
13
|
+
country = Gaku::Country.find_by(iso: country_preset)
|
14
|
+
if country
|
15
|
+
country.states
|
16
|
+
else
|
17
|
+
Gaku::State.none
|
18
|
+
end
|
14
19
|
end
|
15
20
|
|
16
|
-
def disabled?(
|
17
|
-
|
21
|
+
def disabled?(country_preset)
|
22
|
+
country = Gaku::Country.find_by(iso: country_preset)
|
23
|
+
if country
|
24
|
+
country.states_required
|
25
|
+
else
|
26
|
+
true
|
27
|
+
end
|
18
28
|
end
|
19
29
|
|
20
30
|
def render_flash
|
@@ -3,23 +3,22 @@
|
|
3
3
|
= f.text_field :title, label: t(:'address.title')
|
4
4
|
|
5
5
|
.row
|
6
|
-
.col-md-
|
7
|
-
= f.select :country_id, options_from_collection_for_select(@countries, :id, :
|
8
|
-
.col-md-
|
6
|
+
.col-md-4
|
7
|
+
= f.select :country_id, options_from_collection_for_select(@countries, :id, :i18n_name, (f.object.country_id || @default_country.try(:id))) , { prompt: t(:'address.choose_country') }, { id: "country_dropdown", label: t(:'address.country') }
|
8
|
+
.col-md-4
|
9
9
|
#state-dropdown
|
10
|
-
= f.
|
11
|
-
|
12
|
-
|
10
|
+
= f.select :state_id, options_from_collection_for_select(state_load(f.object), :id, :i18n_name, (f.object.state_id || @default_state.try(:id))), { prompt: t(:'address.state.choose') }, { class: 'form-control', disabled: disabled?(f.object), label: t(:'address.state.singular') }
|
11
|
+
.col-md-4
|
12
|
+
= f.object.state_id || @default_state.try(:id)
|
13
|
+
/ = f.object.to_json
|
13
14
|
= f.text_field :zipcode, label: t(:'address.zipcode')
|
14
|
-
.col-md-3
|
15
|
-
button.col-md-12.btn.btn-primary = t(:'address.search')
|
16
15
|
|
17
16
|
.row
|
18
|
-
.col-md-
|
17
|
+
.col-md-4
|
19
18
|
= f.text_field :city, value: f.object.city || Gaku::Preset.address('city'), label: t(:'address.city')
|
20
|
-
.col-md-
|
19
|
+
.col-md-4
|
21
20
|
= f.text_field :address1, label: t(:'address.address1')
|
22
|
-
.col-md-
|
21
|
+
.col-md-4
|
23
22
|
= f.text_field :address2, label: t(:'address.address2')
|
24
23
|
|
25
24
|
javascript:
|
@@ -4,12 +4,14 @@
|
|
4
4
|
.col-md-4
|
5
5
|
= f.fields_for :address do |a|
|
6
6
|
= a.label t(:'preset.address.country')
|
7
|
-
= a.select :country, @countries,
|
7
|
+
= a.select :country, options_from_collection_for_select(@countries, :id, :i18n_name, @country.try(:id)) , { prompt: t(:'address.choose_country') }, { id: "country_dropdown", class: 'form-control', label: t(:'address.country') }
|
8
8
|
|
9
9
|
.col-md-4
|
10
10
|
= f.fields_for :address do |a|
|
11
11
|
= a.label t(:'preset.address.state')
|
12
|
-
|
12
|
+
#state-dropdown
|
13
|
+
= a.select :state, options_from_collection_for_select(state_load(@preset['address']['country']), :id, :i18n_name, @state.try(:id)), { prompt: t(:'address.state.choose') }, { class: 'form-control', disabled: disabled?(a.object), label: t(:'address.state') }
|
14
|
+
|
13
15
|
|
14
16
|
.col-md-4
|
15
17
|
= f.fields_for :address do |a|
|
@@ -0,0 +1 @@
|
|
1
|
+
= collection_select(:address, :state, states, :id, :name, {prompt: t(:'address.state.choose') }, disabled: true, class: 'span12 form-control')
|
data/admin/config/routes.rb
CHANGED
@@ -17,11 +17,11 @@ Gaku::Core::Engine.routes.draw do
|
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
|
-
resources :states, only: :index
|
21
|
-
|
22
20
|
namespace :admin do
|
23
21
|
root to: 'home#index'
|
24
22
|
|
23
|
+
resources :states_list, only: :index
|
24
|
+
|
25
25
|
get 'school_details', to: 'schools#show_master'
|
26
26
|
get 'school_details/edit', to: 'schools#edit_master'
|
27
27
|
patch 'school_details/update', to: 'schools#update_master'
|
@@ -71,7 +71,9 @@ Gaku::Core::Engine.routes.draw do
|
|
71
71
|
resources :semesters, controller: 'school_years/semesters', except: %i( show )
|
72
72
|
end
|
73
73
|
|
74
|
-
resources :presets
|
74
|
+
resources :presets do
|
75
|
+
get :states_list, on: :collection
|
76
|
+
end
|
75
77
|
|
76
78
|
end
|
77
79
|
end
|
data/admin/gaku_admin.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_dependency 'sass-rails', '~> 5.0.0'
|
24
24
|
s.add_dependency 'sass', '~> 3.2'
|
25
25
|
s.add_dependency 'sprockets', '2.11.0'
|
26
|
-
s.add_dependency 'slim', '
|
26
|
+
s.add_dependency 'slim', '~> 3.0'
|
27
27
|
s.add_dependency 'responders', '~> 2.0'
|
28
28
|
|
29
29
|
s.add_dependency 'rails4_client_side_validations', '~> 4.2'
|
@@ -36,7 +36,7 @@ Gem::Specification.new do |s|
|
|
36
36
|
|
37
37
|
s.add_dependency 'jquery-rails', '~> 3.1'
|
38
38
|
s.add_dependency 'jquery-ui-rails', '~> 4.2'
|
39
|
-
s.add_dependency 'jquery-minicolors-rails', '2.1.
|
39
|
+
s.add_dependency 'jquery-minicolors-rails', '2.1.4'
|
40
40
|
s.add_dependency 'bootstrap-sass', '3.1.1.0'
|
41
41
|
s.add_dependency 'bootstrap-datepicker-rails', '~> 1.3.0.1'
|
42
42
|
s.add_dependency 'nprogress-rails'
|
@@ -91,10 +91,11 @@ def create_admin_user
|
|
91
91
|
say "\nWARNING: There is already a user with the username: #{username}, so no account changes were made. If you wish to create an additional admin user, please run rake gaku:generate_admin again with a different username.\n\n"
|
92
92
|
else
|
93
93
|
say "Creating user..."
|
94
|
-
creator = Gaku::UserCreator.new(attributes)
|
94
|
+
creator = Gaku::UserCreator.new(attributes)
|
95
|
+
creator.save
|
95
96
|
admin = creator.get_user
|
96
97
|
# create an admin role and and assign the admin user to that role
|
97
|
-
role = Gaku::Role.
|
98
|
+
role = Gaku::Role.where(name: 'Admin').first_or_initialize
|
98
99
|
admin.roles << role
|
99
100
|
if admin.save
|
100
101
|
say "User Created"
|
@@ -17,20 +17,20 @@ describe 'Admin Presets Students' do
|
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'saves', js: true do
|
20
|
-
select country.name, from: '
|
21
|
-
|
20
|
+
select country.name, from: 'country_dropdown'
|
21
|
+
select state.name, from: 'preset_address_state'
|
22
22
|
fill_in 'preset_address_city', with: 'Varna'
|
23
23
|
click submit
|
24
24
|
|
25
25
|
flash_updated?
|
26
26
|
click '#admin-preset-address-tab-link'
|
27
|
-
expect(find_field('
|
28
|
-
expect(find_field('preset_address_state').value).to eq state.
|
27
|
+
expect(find_field('country_dropdown').value).to eq "#{country.id}"
|
28
|
+
expect(find_field('preset_address_state').value).to eq "#{state.id}"
|
29
29
|
expect(find_field('preset_address_city').value).to eq 'Varna'
|
30
30
|
|
31
31
|
preset.reload
|
32
|
-
expect(preset['address']['country']). to eq country.
|
33
|
-
expect(preset['address']['state']). to eq state.
|
32
|
+
expect(preset['address']['country']). to eq "#{country.id}"
|
33
|
+
expect(preset['address']['state']). to eq "#{state.id}"
|
34
34
|
expect(preset['address']['city']). to eq 'Varna'
|
35
35
|
end
|
36
36
|
|
@@ -7,7 +7,7 @@ describe 'Admin School Campuses Address' do
|
|
7
7
|
|
8
8
|
let!(:country) { create(:country, name: 'USA', iso: 'US') }
|
9
9
|
let(:country_without_state) { create(:country, name: 'Japan', iso: 'JP') }
|
10
|
-
let!(:state) { create(:state, name: 'Florida', country: country) }
|
10
|
+
let!(:state) { create(:state, name: 'Florida', abbr: 'FL', country: country) }
|
11
11
|
|
12
12
|
before(:all) { set_resource 'admin-school-campus-address' }
|
13
13
|
before { as :admin }
|
@@ -47,7 +47,7 @@ describe 'Admin School Campuses Address' do
|
|
47
47
|
it 'changes country without state' do
|
48
48
|
select "#{country_without_state}", from: 'country_dropdown'
|
49
49
|
within('#state-dropdown') do
|
50
|
-
expect(page).to have_css('select#address_state_id
|
50
|
+
expect(page).to have_css('select#address_state_id', visible: false)
|
51
51
|
has_no_content? state.name
|
52
52
|
end
|
53
53
|
end
|
@@ -98,7 +98,7 @@ describe 'Admin School Campuses Address' do
|
|
98
98
|
it 'changes country without state' do
|
99
99
|
select "#{country_without_state}", from: 'country_dropdown'
|
100
100
|
within('#state-dropdown') do
|
101
|
-
expect(page).to have_css('select#address_state_id
|
101
|
+
expect(page).to have_css('select#address_state_id', visible: false)
|
102
102
|
has_no_content? state.name
|
103
103
|
end
|
104
104
|
end
|
data/common_gaku_dependencies.rb
CHANGED
@@ -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
|
@@ -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
|
@@ -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
|