gaku_core 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/gaku/admin/departments_controller.rb +55 -0
  3. data/app/controllers/gaku/admin/disposals_controller.rb +18 -45
  4. data/app/controllers/gaku/exams_controller.rb +2 -2
  5. data/app/controllers/gaku/syllabuses/exams_controller.rb +2 -2
  6. data/app/helpers/gaku/gaku_helper.rb +7 -0
  7. data/app/helpers/gaku/translations_helper.rb +4 -0
  8. data/app/models/gaku/address.rb +1 -1
  9. data/app/models/gaku/department.rb +13 -0
  10. data/app/models/gaku/disposal.rb +45 -0
  11. data/app/models/gaku/exam_portion.rb +1 -1
  12. data/app/models/gaku/student.rb +2 -2
  13. data/app/models/gaku/user.rb +1 -1
  14. data/app/models/gaku/versioning/student_version.rb +7 -12
  15. data/app/views/gaku/admin/departments/_department.html.slim +2 -0
  16. data/app/views/gaku/admin/departments/_form.html.slim +3 -0
  17. data/app/views/gaku/admin/departments/_form_fields.html.slim +1 -0
  18. data/app/views/gaku/admin/departments/_modal.html.slim +6 -0
  19. data/app/views/gaku/admin/departments/_table_fields.html.slim +5 -0
  20. data/app/views/gaku/admin/departments/create.js.erb +7 -0
  21. data/app/views/gaku/admin/departments/destroy.js.erb +2 -0
  22. data/app/views/gaku/admin/departments/edit.js.erb +3 -0
  23. data/app/views/gaku/admin/departments/index.html.slim +20 -0
  24. data/app/views/gaku/admin/departments/new.js.erb +3 -0
  25. data/app/views/gaku/admin/departments/update.js.erb +4 -0
  26. data/app/views/gaku/shared/menu/_admin.html.erb +1 -0
  27. data/{lib/generators/gaku/install/templates/log/sidekiq.log → app/views/gaku/shared/overrides/students/_import_link.html.slim} +0 -0
  28. data/app/views/gaku/shared/overrides/syllabuses/_import_link.html.slim +0 -0
  29. data/app/views/gaku/students/index.html.slim +1 -1
  30. data/app/views/gaku/syllabuses/index.html.slim +1 -1
  31. data/config/initializers/active_record.rb +1 -1
  32. data/config/locales/en.yml +8 -0
  33. data/config/routes.rb +2 -9
  34. data/db/default/gaku/attendance_types.rb +18 -8
  35. data/db/default/gaku/commute_method_types.rb +12 -20
  36. data/db/default/gaku/departments.rb +14 -0
  37. data/db/default/gaku/enrollment_status.rb +34 -31
  38. data/db/default/gaku/scholarship_statuses.rb +11 -8
  39. data/db/migrate/20120202111850_translated_tables.rb +62 -0
  40. data/db/migrate/{20120202111850_gaku_core.rb → 20131014065028_gaku_core.rb} +0 -86
  41. data/lib/gaku/core/version.rb +1 -1
  42. data/lib/gaku/core.rb +2 -3
  43. data/lib/gaku/testing/factories/department_factory.rb +11 -0
  44. data/lib/generators/gaku/install/install_generator.rb +1 -10
  45. metadata +218 -151
  46. data/app/controllers/gaku/students/importer_controller.rb +0 -75
  47. data/app/controllers/gaku/syllabuses/importer_controller.rb +0 -19
  48. data/app/models/gaku/import_file.rb +0 -5
  49. data/app/views/gaku/students/importer/index.html.slim +0 -26
  50. data/app/views/gaku/students/importer/roster_import_preview.html.slim +0 -4
  51. data/app/views/gaku/syllabuses/importer/index.html.slim +0 -14
  52. data/app/workers/gaku/importers/students/roster_worker.rb +0 -18
  53. data/app/workers/gaku/importers/students/school_station_zaikousei_worker.rb +0 -15
  54. data/config/initializers/sidekiq.rb +0 -6
  55. data/lib/gaku/exporters/roster_exporter.rb +0 -36
  56. data/lib/gaku/importers/key_mapper.rb +0 -19
  57. data/lib/gaku/importers/logger.rb +0 -10
  58. data/lib/gaku/importers/students/guardians.rb +0 -89
  59. data/lib/gaku/importers/students/personal_information.rb +0 -65
  60. data/lib/gaku/importers/students/roster.rb +0 -50
  61. data/lib/gaku/importers/students/roster_to_student.rb +0 -67
  62. data/lib/gaku/importers/students/school_station_zaikousei.rb +0 -109
  63. data/lib/gaku/importers/students/student_identity.rb +0 -17
  64. data/lib/gaku/testing/factories/import_file_factory.rb +0 -8
  65. data/lib/generators/gaku/install/templates/Procfile +0 -2
  66. data/lib/generators/gaku/install/templates/config/sidekiq.yml +0 -8
@@ -1,29 +1,21 @@
1
1
  # -*- encoding: utf-8 -*-
2
2
 
3
- #names = %w(Unknown Walking Bicycle Train Bus Car Metro)
4
-
5
- #names.each do |name|
6
- # Gaku::CommuteMethodType.where(name: name).first_or_create!
7
- #end
8
-
9
- # -*- encoding: utf-8 -*-
10
- # Array format ['en commute_method_type', 'ja commute_method_type', 'active?']
11
3
  commute_method_types = [
12
- ['Unknown', '不明'],
13
- ['Walking', '歩行'],
14
- ['Bicycle', '自転車'],
15
- ['Train', '列車'],
16
- ['Bus', 'バス'],
17
- ['Car', '車'],
18
- ['Metro', '地下鉄']
4
+ { name: 'Unknown', name_ja: '不明' },
5
+ { name: 'Walking', name_ja: '歩行' },
6
+ { name: 'Bicycle', name_ja: '自転車' },
7
+ { name: 'Train', name_ja: '列車' },
8
+ { name: 'Bus', name_ja: 'バス' },
9
+ { name: 'Car', name_ja: '車' },
10
+ { name: 'Metro', name_ja: '地下鉄'}
19
11
  ]
20
12
 
13
+
14
+
21
15
  commute_method_types.each do |type|
22
16
  I18n.locale = :en
23
- commute_method_type = Gaku::CommuteMethodType.find_or_create_by_name(type[0])
17
+ commute_method_type = Gaku::CommuteMethodType.create!(name: type[:name])
24
18
 
25
19
  I18n.locale = :ja
26
- commute_method_type.update_attributes(name: type[1])
27
- end
28
-
29
- I18n.locale = nil
20
+ commute_method_type.update_attributes(name: type[:name_ja])
21
+ end
@@ -0,0 +1,14 @@
1
+ departments = [
2
+ {
3
+ name: 'Mathematics',
4
+ name_ja: 'Japanese Mathematics'
5
+ }
6
+ ]
7
+
8
+ departments.each do |d|
9
+ I18n.locale = :en
10
+ department = Gaku::Department.create!(name: d[:name])
11
+
12
+ I18n.locale = :ja
13
+ department.update_attributes(name: d[:name_ja])
14
+ end
@@ -1,37 +1,40 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # Array format ['en status', 'ja status', 'active?']
2
+
3
3
  statuses = [
4
- ['applicant', 'Applicant', '志願', false ], #DO NOT CHANGE ORDER
5
- ['admitted', 'Admitted', '入学', true ],
6
- ['enrolled', 'Enrolled', '在学', true ],
7
- ['transferred_in', 'Transfered In', '転入', true ],
8
- ['transferred_out', 'Transfered Out', '転出', false ],
9
- ['course_transfer_in', 'Course Transfer In', '編入', true ],
10
- ['course_transfer_out', 'Course Transfer Out', '編出', false ],
11
- ['visiting', 'Visiting', '留学', true ],
12
- ['re_admitted', 'Re-Admitted', '再入学', true ],
13
- ['for_credit_exchange', 'For-Credit Exchange', '単位認定留学', true ],
14
- ['non_credit_exchange', 'Non-Credit Exchange', '休学留学', true ],
15
- ['repeat', 'Repeat', '留年', true ],
16
- ['held_back', 'Held Back', '原級留置', true ],
17
- ['inactive', 'Inactive', '休学', false ],
18
- ['graduated', 'Graduated', '卒業', false ],
19
- ['re_enrolled', 'Re-Enrolled', '復学', true ],
20
- ['suspended', 'Suspended', '退学', false ],
21
- ['expelled', 'Expelled', '停学', false ],
22
- ['dropped_out', 'Dropped Out', '自主退学', false ],
23
- ['terminal_leave', 'Terminal Leave', '除籍', false ],
24
- ['on_leave', 'On Leave', '一時自主退学', false ],
25
- ['extended_absence', 'Extended Absence', '長期自主退学', false ],
26
- ['deleted', 'Deleted', '削除' , false ]
4
+ { code: 'applicant', name: 'Applicant', name_ja: '志願', active: false },
5
+ { code: 'admitted', name: 'Admitted', name_ja: '入学', active: true },
6
+ { code: 'enrolled', name: 'Enrolled', name_ja: '在学', active: true },
7
+ { code: 'transferred_in', name: 'Transfered In', name_ja: '転入', active: true },
8
+ { code: 'transferred_out', name: 'Transfered Out', name_ja: '転出', active: false },
9
+ { code: 'course_transfer_in', name: 'Course Transfer In', name_ja: '編入', active: true },
10
+ { code: 'course_transfer_out', name: 'Course Transfer Out', name_ja: '編出', active: false },
11
+ { code: 'visiting', name: 'Visiting', name_ja: '留学', active: true },
12
+ { code: 're_admitted', name: 'Re-Admitted', name_ja: '再入学', active: true },
13
+ { code: 'for_credit_exchange', name: 'For-Credit Exchange', name_ja: '単位認定留学', active: true },
14
+ { code: 'non_credit_exchange', name: 'Non-Credit Exchange', name_ja: '休学留学', active: true },
15
+ { code: 'repeat', name: 'Repeat', name_ja: '留年', active: true },
16
+ { code: 'held_back', name: 'Held Back', name_ja: '原級留置', active: true },
17
+ { code: 'inactive', name: 'Inactive', name_ja: '休学', active: false },
18
+ { code: 'graduated', name: 'Graduated', name_ja: '卒業', active: false },
19
+ { code: 're_enrolled', name: 'Re-Enrolled', name_ja: '復学', active: true },
20
+ { code: 'suspended', name: 'Suspended', name_ja: '退学', active: false },
21
+ { code: 'expelled', name: 'Expelled', name_ja: '停学', active: false },
22
+ { code: 'dropped_out', name: 'Dropped Out', name_ja: '自主退学', active: false },
23
+ { code: 'terminal_leave', name: 'Terminal Leave', name_ja: '除籍', active: false },
24
+ { code: 'on_leave', name: 'On Leave', name_ja: '一時自主退学', active: false },
25
+ { code: 'extended_absence', name: 'Extended Absence', name_ja: '長期自主退学', active: false },
26
+ { code: 'deleted', name: 'Deleted', name_ja: '削除' , active: false }
27
27
  ]
28
28
 
29
29
  statuses.each do |status|
30
- I18n.locale = :en
31
- es = Gaku::EnrollmentStatus.where(code: status[0], name: status[1], active: status[3], immutable: true).first_or_create!
32
-
33
- I18n.locale = :ja
34
- es.update_attribute(:name, status[2])
35
- end
30
+ I18n.locale = :en
31
+ es = Gaku::EnrollmentStatus.create(
32
+ code: status[:code],
33
+ name: status[:name],
34
+ active: status[:active],
35
+ immutable: true
36
+ )
36
37
 
37
- I18n.locale = nil
38
+ I18n.locale = :ja
39
+ es.update_attribute(:name, status[:name_ja])
40
+ end
@@ -1,19 +1,22 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # Array format ['en scholarship_status', 'ja scholarship_status', 'default']
2
+
3
3
  scholarship_statuses = [
4
- ['Self Paid', '自己支払い', true ],
5
- ['Government Scholarship', '政府奨学金', false],
6
- ['School Scholarship', '学校の奨学金', false],
7
- ['Organizational Scholarship', '組織の奨学金', false],
8
- ['Charity Scholarship', 'チャリティー奨学金', false],
4
+ { name: 'Self Paid', name_ja: '自己支払い', default: true },
5
+ { name: 'Government Scholarship', name_ja: '政府奨学金', default: false },
6
+ { name: 'School Scholarship', name_ja: '学校の奨学金', default: false },
7
+ { name: 'Organizational Scholarship', name_ja: '組織の奨学金', default: false },
8
+ { name: 'Charity Scholarship', name_ja: 'チャリティー奨学金', default: false }
9
9
  ]
10
10
 
11
11
  scholarship_statuses.each do |status|
12
12
  I18n.locale = :en
13
- scholarship_status = Gaku::ScholarshipStatus.where(name: status[0], default: status[2]).first_or_create!
13
+ scholarship_status = Gaku::ScholarshipStatus.create!(
14
+ name: status[:name],
15
+ default: status[:default]
16
+ )
14
17
 
15
18
  I18n.locale = :ja
16
- scholarship_status.update_attribute(:name, status[1])
19
+ scholarship_status.update_attribute(:name, status[:name_ja])
17
20
  end
18
21
 
19
22
  I18n.locale = nil
@@ -0,0 +1,62 @@
1
+ class TranslatedTables < ActiveRecord::Migration
2
+
3
+ def up
4
+ create_table :gaku_attendance_types do |t|
5
+ t.string :name
6
+ t.string :color_code
7
+ t.boolean :counted_absent
8
+ t.boolean :disable_credit
9
+ t.float :credit_rate
10
+ t.boolean :auto_credit
11
+ t.timestamps
12
+ end
13
+ Gaku::AttendanceType.create_translation_table! name: :string
14
+
15
+ create_table :gaku_commute_method_types do |t|
16
+ t.string :name
17
+ t.timestamps
18
+ end
19
+ Gaku::CommuteMethodType.create_translation_table! name: :string
20
+
21
+ create_table :gaku_enrollment_statuses do |t|
22
+ t.string :code
23
+ t.string :name
24
+ t.boolean :active
25
+ t.boolean :immutable
26
+ t.timestamps
27
+ end
28
+ Gaku::EnrollmentStatus.create_translation_table! name: :string
29
+
30
+ create_table :gaku_scholarship_statuses do |t|
31
+ t.string :name
32
+ t.boolean :default
33
+ t.timestamps
34
+ end
35
+ Gaku::ScholarshipStatus.create_translation_table! name: :string
36
+
37
+ create_table :gaku_departments do |t|
38
+ t.string :name
39
+ t.timestamps
40
+ end
41
+ Gaku::Department.create_translation_table! name: :string
42
+
43
+ end
44
+
45
+ def down
46
+ drop_table :gaku_attendance_types
47
+ Gaku::AttendanceType.drop_translation_table!
48
+
49
+ drop_table :gaku_commute_method_types
50
+ Gaku::CommuteMethodType.drop_translation_table!
51
+
52
+ drop_table :gaku_enrollment_statuses
53
+ Gaku::EnrollmentStatus.drop_translation_table!
54
+
55
+ drop_table :gaku_scholarship_statuses
56
+ Gaku::ScholarshipStatus.drop_translation_table!
57
+
58
+ drop_table :gaku_departments
59
+ Gaku::Department.drop_translation_table!
60
+ end
61
+
62
+ end
@@ -59,28 +59,6 @@ class GakuCore < ActiveRecord::Migration
59
59
  t.datetime 'asset_updated_at'
60
60
  end
61
61
 
62
- create_table 'gaku_attendance_type_translations' do |t|
63
- t.integer 'gaku_attendance_type_id', null: false
64
- t.string 'locale', null: false
65
- t.datetime 'created_at'
66
- t.datetime 'updated_at'
67
- t.string 'name'
68
- end
69
-
70
- add_index 'gaku_attendance_type_translations', ['gaku_attendance_type_id'], name: 'index_144d49f40337496bacec02aefc694f93f07d0581', using: :btree
71
- add_index 'gaku_attendance_type_translations', ['locale'], name: 'index_gaku_attendance_type_translations_on_locale', using: :btree
72
-
73
- create_table 'gaku_attendance_types' do |t|
74
- t.string 'name'
75
- t.string 'color_code'
76
- t.boolean 'counted_absent'
77
- t.boolean 'disable_credit'
78
- t.float 'credit_rate'
79
- t.boolean 'auto_credit'
80
- t.datetime 'created_at'
81
- t.datetime 'updated_at'
82
- end
83
-
84
62
  create_table 'gaku_attendances' do |t|
85
63
  t.text 'reason'
86
64
  t.integer 'attendancable_id'
@@ -130,23 +108,6 @@ class GakuCore < ActiveRecord::Migration
130
108
  t.integer 'notes_count', default: 0
131
109
  end
132
110
 
133
- create_table 'gaku_commute_method_type_translations' do |t|
134
- t.integer 'gaku_commute_method_type_id', null: false
135
- t.string 'locale', null: false
136
- t.datetime 'created_at'
137
- t.datetime 'updated_at'
138
- t.string 'name'
139
- end
140
-
141
- add_index 'gaku_commute_method_type_translations', ['gaku_commute_method_type_id'], name: 'index_27960af5d7e19e965cc26c8f98c7d21e3a0ce580', using: :btree
142
- add_index 'gaku_commute_method_type_translations', ['locale'], name: 'index_gaku_commute_method_type_translations_on_locale', using: :btree
143
-
144
- create_table 'gaku_commute_method_types' do |t|
145
- t.string 'name'
146
- t.datetime 'created_at'
147
- t.datetime 'updated_at'
148
- end
149
-
150
111
  create_table 'gaku_contact_types' do |t|
151
112
  t.string 'name'
152
113
  end
@@ -203,26 +164,6 @@ class GakuCore < ActiveRecord::Migration
203
164
  t.integer 'students_count', default: 0
204
165
  end
205
166
 
206
- create_table 'gaku_enrollment_status_translations' do |t|
207
- t.integer 'gaku_enrollment_status_id', null: false
208
- t.string 'locale', null: false
209
- t.datetime 'created_at'
210
- t.datetime 'updated_at'
211
- t.string 'name'
212
- end
213
-
214
- add_index 'gaku_enrollment_status_translations', ['gaku_enrollment_status_id'], name: 'index_7865fd45090cea7b7810b5288a698bba41d45b8e', using: :btree
215
- add_index 'gaku_enrollment_status_translations', ['locale'], name: 'index_gaku_enrollment_status_translations_on_locale', using: :btree
216
-
217
- create_table 'gaku_enrollment_statuses' do |t|
218
- t.string 'code'
219
- t.string 'name'
220
- t.boolean 'active'
221
- t.boolean 'immutable'
222
- t.datetime 'created_at'
223
- t.datetime 'updated_at'
224
- end
225
-
226
167
  create_table 'gaku_exam_portion_scores' do |t|
227
168
  t.float 'score'
228
169
  t.string 'entry_number'
@@ -368,15 +309,6 @@ class GakuCore < ActiveRecord::Migration
368
309
  t.integer 'contacts_count', default: 0
369
310
  end
370
311
 
371
- create_table 'gaku_import_files' do |t|
372
- t.string 'context'
373
- t.string 'importer_type'
374
- t.string 'data_file_file_name'
375
- t.string 'data_file_content_type'
376
- t.integer 'data_file_file_size'
377
- t.datetime 'data_file_updated_at'
378
- end
379
-
380
312
  create_table 'gaku_installs' do |t|
381
313
  t.string 'email', default: '', null: false
382
314
  t.string 'encrypted_password', default: '', null: false
@@ -476,24 +408,6 @@ class GakuCore < ActiveRecord::Migration
476
408
  t.datetime 'updated_at'
477
409
  end
478
410
 
479
- create_table 'gaku_scholarship_status_translations' do |t|
480
- t.integer 'gaku_scholarship_status_id', null: false
481
- t.string 'locale', null: false
482
- t.datetime 'created_at'
483
- t.datetime 'updated_at'
484
- t.string 'name'
485
- end
486
-
487
- add_index 'gaku_scholarship_status_translations', ['gaku_scholarship_status_id'], name: 'index_fd3bb92292a989ddcdc49aabf021ceb1ce5f0d04', using: :btree
488
- add_index 'gaku_scholarship_status_translations', ['locale'], name: 'index_gaku_scholarship_status_translations_on_locale', using: :btree
489
-
490
- create_table 'gaku_scholarship_statuses' do |t|
491
- t.string 'name'
492
- t.datetime 'created_at'
493
- t.datetime 'updated_at'
494
- t.boolean 'default'
495
- end
496
-
497
411
  create_table 'gaku_school_histories' do |t|
498
412
  t.date 'beginning'
499
413
  t.date 'ending'
@@ -1,5 +1,5 @@
1
1
  module Gaku
2
2
  def self.version
3
- '0.0.1'
3
+ '0.0.3'
4
4
  end
5
5
  end
data/lib/gaku/core.rb CHANGED
@@ -18,16 +18,15 @@ require 'inherited_resources'
18
18
  require 'draper'
19
19
  require 'kaminari'
20
20
  require 'rails4_client_side_validations'
21
- require 'sidekiq/web'
22
21
  require 'paper_trail'
23
- require 'globalize3'
24
- require 'thinreports-rails'
22
+ require 'globalize'
25
23
  require 'bootstrap-sass'
26
24
  require 'bootstrap-datepicker-rails'
27
25
  require 'nested_form'
28
26
  require 'gaku_helpers'
29
27
  require 'gaku_forms'
30
28
  require 'gaku_nested_forms'
29
+ require 'thinreports-rails'
31
30
 
32
31
  module Gaku
33
32
 
@@ -0,0 +1,11 @@
1
+ FactoryGirl.define do
2
+
3
+ factory :department, class: Gaku::Department do
4
+ name 'Mathematics'
5
+
6
+ factory :invalid_department do
7
+ name nil
8
+ end
9
+ end
10
+
11
+ end
@@ -34,16 +34,6 @@ module Gaku
34
34
  remove_file 'public/index.html'
35
35
  end
36
36
 
37
- def clear_logs
38
- remove_file 'log/sidekiq.log'
39
- add_file 'log/sidekiq.log'
40
- end
41
-
42
- def add_files
43
- template 'config/sidekiq.yml', 'config/sidekiq.yml'
44
- template 'Procfile', 'Procfile'
45
- end
46
-
47
37
  def setup_assets
48
38
  @lib_name = 'gaku'
49
39
  %w{javascripts stylesheets images}.each do |path|
@@ -58,6 +48,7 @@ module Gaku
58
48
  empty_directory 'app/overrides'
59
49
  end
60
50
 
51
+
61
52
  def configure_application
62
53
  application <<-APP
63
54