gaku 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 (65) hide show
  1. checksums.yaml +4 -4
  2. data/.rspec +1 -3
  3. data/.travis.yml +11 -8
  4. data/README.md +2 -4
  5. data/VERSION +1 -1
  6. data/core/Guardfile +24 -14
  7. data/core/Rakefile +0 -3
  8. data/core/app/controllers/gaku/admin/disposals_controller.rb +18 -45
  9. data/core/app/controllers/gaku/exams_controller.rb +2 -2
  10. data/core/app/controllers/gaku/syllabuses/exams_controller.rb +2 -2
  11. data/core/app/models/gaku/address.rb +1 -1
  12. data/core/app/models/gaku/disposal.rb +45 -0
  13. data/core/app/models/gaku/exam_portion.rb +1 -1
  14. data/core/app/models/gaku/student.rb +2 -2
  15. data/core/app/models/gaku/user.rb +1 -1
  16. data/core/app/models/gaku/versioning/student_version.rb +7 -12
  17. data/core/app/views/gaku/shared/overrides/students/_import_link.html.slim +0 -0
  18. data/core/app/views/gaku/shared/overrides/syllabuses/_import_link.html.slim +0 -0
  19. data/core/app/views/gaku/students/index.html.slim +1 -1
  20. data/core/app/views/gaku/syllabuses/index.html.slim +1 -1
  21. data/core/config/initializers/active_record.rb +1 -1
  22. data/core/config/routes.rb +1 -9
  23. data/core/db/default/gaku/attendance_types.rb +18 -8
  24. data/core/db/default/gaku/commute_method_types.rb +12 -20
  25. data/core/db/default/gaku/enrollment_status.rb +34 -31
  26. data/core/db/default/gaku/scholarship_statuses.rb +11 -8
  27. data/core/db/migrate/20120202111850_translated_tables.rb +52 -0
  28. data/core/db/migrate/{20120202111850_gaku_core.rb → 20131014065028_gaku_core.rb} +0 -86
  29. data/core/gaku_core.gemspec +43 -40
  30. data/core/lib/gaku/core.rb +2 -3
  31. data/core/lib/gaku/core/version.rb +1 -1
  32. data/core/lib/generators/gaku/install/install_generator.rb +1 -10
  33. data/core/spec/models/address_spec.rb +1 -1
  34. data/core/spec/spec_helper.rb +3 -3
  35. data/gaku_dependencies.rb +2 -12
  36. data/sample/db/sample/gaku/changes/student_changes.rb +3 -3
  37. data/sample/gaku_sample.gemspec +0 -1
  38. data/sample/lib/shared_sample_data.rb +2 -2
  39. metadata +12 -35
  40. data/core/app/controllers/gaku/students/importer_controller.rb +0 -75
  41. data/core/app/controllers/gaku/syllabuses/importer_controller.rb +0 -19
  42. data/core/app/models/gaku/import_file.rb +0 -5
  43. data/core/app/views/gaku/students/importer/index.html.slim +0 -26
  44. data/core/app/views/gaku/students/importer/roster_import_preview.html.slim +0 -4
  45. data/core/app/views/gaku/syllabuses/importer/index.html.slim +0 -14
  46. data/core/app/workers/gaku/importers/students/roster_worker.rb +0 -18
  47. data/core/app/workers/gaku/importers/students/school_station_zaikousei_worker.rb +0 -15
  48. data/core/config/initializers/sidekiq.rb +0 -6
  49. data/core/lib/gaku/exporters/roster_exporter.rb +0 -36
  50. data/core/lib/gaku/importers/key_mapper.rb +0 -19
  51. data/core/lib/gaku/importers/logger.rb +0 -10
  52. data/core/lib/gaku/importers/students/guardians.rb +0 -89
  53. data/core/lib/gaku/importers/students/personal_information.rb +0 -65
  54. data/core/lib/gaku/importers/students/roster.rb +0 -50
  55. data/core/lib/gaku/importers/students/roster_to_student.rb +0 -67
  56. data/core/lib/gaku/importers/students/school_station_zaikousei.rb +0 -109
  57. data/core/lib/gaku/importers/students/student_identity.rb +0 -17
  58. data/core/lib/gaku/testing/factories/import_file_factory.rb +0 -8
  59. data/core/lib/generators/gaku/install/templates/Procfile +0 -2
  60. data/core/lib/generators/gaku/install/templates/config/sidekiq.yml +0 -8
  61. data/core/spec/integration/importers/roster_spec.rb +0 -41
  62. data/core/spec/models/import_file_spec.rb +0 -9
  63. data/core/spec/requests/students/import_export.rb +0 -37
  64. data/core/spec/support/sample_roster.xls +0 -0
  65. data/core/spec/workers/roster_spec.rb +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5474503b8dd52288efd403fe8747063aeac22208
4
- data.tar.gz: 5ee33d43e57e47d42fcbb4924639f579470c7962
3
+ metadata.gz: 59cd64203ab111b1fb870b931e9353c54cab08bc
4
+ data.tar.gz: a73fd03a09e8b864ebff4d417139624a8fac2d92
5
5
  SHA512:
6
- metadata.gz: 3fcc49533fa2d448820ed37720eb52fe340004e478945104279071e44ae3c2fad2924258f92cd0707c96d180fd220704f6c62d8bceef4708e3f0ebdecedfe14c
7
- data.tar.gz: 42de59feb61a93ca0e63ee97278ccd3694b8d3263798fd24085df3cf3b87fb54a70b698d34d034cb0784f8f908ca8e28070ae9d79dba457974bf1126fa09ea07
6
+ metadata.gz: 2f325c7034f3fcfdecd9b8e7373476a847fe72faa7db8b9854b4bd356712f4f7d6d1cce35c338657c4bb72636cc10db16356b58d1f807ba05edd4d96038f9314
7
+ data.tar.gz: 597b0c1cae22019f6803504505ac21290476b5749e3252cba57d08a8a1f387fdb6715d873422ff385c8b88e3e10ebd9caadb11fd0ed2c95934ed89e17ee34623
data/.rspec CHANGED
@@ -1,4 +1,2 @@
1
1
  --colour
2
- --format documentation
3
- --profile
4
- --tag ~performance
2
+ --format documentation
@@ -2,22 +2,25 @@ before_script:
2
2
  - sh -e /etc/init.d/xvfb start
3
3
  - export DISPLAY=:99.0
4
4
  - psql -c 'create database gaku_test;' -U postgres
5
- bundler_args: --without development production
5
+ bundler_args: --without production
6
6
  env:
7
- - GEM=core DB=postgres
7
+ - TEST_SUITE=models GEM=core DB=postgres
8
+ - TEST_SUITE=controllers GEM=core DB=postgres
9
+ - TEST_SUITE=integration GEM=core DB=postgres
10
+ - TEST_SUITE=routing GEM=core DB=postgres
11
+ - TEST_SUITE=requests GEM=core DB=postgres
8
12
  before_install:
9
- - gem install bundler --pre
13
+ - travis_retry gem install bundler --pre
10
14
  - cd $GEM; export BUNDLE_GEMFILE="`pwd`/Gemfile"
11
15
  script:
12
16
  - bundle exec rake test_app
13
- - SELENIUM=1 I18N=1 bundle exec rspec
17
+ - SELENIUM=1 I18N=1 bundle exec rspec spec/$TEST_SUITE
14
18
 
15
19
  notifications:
16
- email:
17
- - false
20
+ email: false
18
21
  irc:
19
- use_notice: true
20
- skip_join: true
22
+ on_success: change
23
+ on_failure: always
21
24
  channels:
22
25
  - "irc.freenode.org#gaku"
23
26
  rvm:
data/README.md CHANGED
@@ -66,13 +66,11 @@ Create a new Rails application:
66
66
 
67
67
  Then add GAKU to your Gemfile:
68
68
  ```ruby
69
- gem 'globalize3', github: 'globalize/globalize', branch: 'rails4', ref: '82b3b36308677745b261bd147dda00ed4560a25d'
70
- gem 'gaku', '~> 0.0.2'
69
+ gem 'gaku', '~> 0.0.3'
71
70
  ```
72
71
 
73
- Or use the master branch:
72
+ Or use the master branch:
74
73
  ```ruby
75
- gem 'globalize3', github: 'globalize/globalize', branch: 'rails4', ref: '82b3b36308677745b261bd147dda00ed4560a25d'
76
74
  gem 'gaku', github: 'Genshin/gaku'
77
75
  ```
78
76
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -1,21 +1,31 @@
1
- guard 'rspec', :version => 2, :spec_paths => %w(spec),
2
- :cli => (File.read('.rspec').split("\n").join(' ') if File.exists?('.rspec')) do
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'bundler' do
5
+ watch('Gemfile')
6
+ # Uncomment next line if Gemfile contain `gemspec' command
7
+ # watch(/^.+\.gemspec/)
8
+ end
9
+
10
+ guard :rspec do
3
11
  watch(%r{^spec/.+_spec\.rb$})
12
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
13
+ watch('spec/spec_helper.rb') { "spec" }
14
+
15
+ # Rails example
4
16
  watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
5
- watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
6
- watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/requests/#{m[1]}_spec.rb"] }
17
+ watch(%r{^app/(.*)(\.erb|\.haml|\.slim)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
18
+ watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
7
19
  watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
8
- watch("spec/spec_helper.rb") { "spec" }
9
- watch("config/routes.rb")
10
- watch("app/controllers/application_controller.rb") { "spec/controllers" }
11
- # Capybara request specs
12
- watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
13
- watch(%r{^app/assets/javascripts/(.+)/.*\.(js|coffee|erb)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
14
- end
20
+ watch('config/routes.rb') { "spec/routing" }
21
+ watch('app/controllers/application_controller.rb') { "spec/controllers" }
15
22
 
16
- guard 'bundler' do
17
- watch('Gemfile')
18
- watch(/^.+\.gemspec/)
23
+ # Capybara features specs
24
+ watch(%r{^app/views/(.+)/.*\.(erb|haml|slim)$}) { |m| "spec/features/#{m[1]}_spec.rb" }
25
+
26
+ # Turnip features and steps
27
+ watch(%r{^spec/acceptance/(.+)\.feature$})
28
+ watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
19
29
  end
20
30
 
21
31
  guard :rubocop do
@@ -4,12 +4,9 @@ require 'rake'
4
4
  require 'rake/testtask'
5
5
  require 'rake/packagetask'
6
6
  require 'rubygems/package_task'
7
- require 'rspec/core/rake_task'
8
- require 'rspec/core/runner'
9
7
  require 'gaku/testing/common_rake'
10
8
 
11
9
  Bundler::GemHelper.install_tasks
12
- RSpec::Core::RakeTask.new
13
10
 
14
11
  spec = eval(File.read('gaku_core.gemspec'))
15
12
  Gem::PackageTask.new(spec) do |p|
@@ -8,74 +8,47 @@ module Gaku
8
8
  end
9
9
 
10
10
  def students
11
- @students = Student.deleted
12
- .page(params[:page])
13
- .per(Preset.default_per_page)
11
+ @students = Disposal.students.page(params[:page])
14
12
  end
15
13
 
16
14
  def teachers
17
- @teachers = Teacher.deleted
18
- .page(params[:page])
19
- .per(Preset.default_per_page)
15
+ @teachers = Disposal.teachers.page(params[:page])
20
16
  end
21
17
 
22
18
  def guardians
23
- @guardians = Guardian.deleted
24
- .page(params[:page])
25
- .per(Preset.default_per_page)
19
+ @guardians = Disposal.guardians.page(params[:page])
26
20
  end
27
21
 
28
22
  def exams
29
- @exams = Exam.deleted
30
- .page(params[:page])
31
- .per(Preset.default_per_page)
23
+ @exams = Disposal.exams.page(params[:page])
32
24
  end
33
25
 
34
26
  def course_groups
35
- @course_groups = CourseGroup.deleted
36
- .page(params[:page])
37
- .per(Preset.default_per_page)
27
+ @course_groups = Disposal.course_groups.page(params[:page])
38
28
  end
39
29
 
40
30
  def attachments
41
- @attachments = Attachment.includes(:attachable)
42
- .deleted
43
- .page(params[:page])
44
- .per(Preset.default_per_page)
31
+ @attachments = Disposal.attachments.page(params[:page])
32
+
45
33
  end
46
34
 
47
35
  def addresses
48
- @student_addresses = Address.includes(:addressable, :country)
49
- .deleted
50
- .students
51
- .page(params[:page])
52
- .per(Preset.default_per_page)
53
-
54
- @teacher_addresses = Address.includes(:addressable, :country)
55
- .deleted
56
- .teachers
57
- .page(params[:page])
58
- .per(Preset.default_per_page)
59
-
60
- @students_count = Address.deleted.students.count
61
- @teachers_count = Address.deleted.teachers.count
36
+ @student_addresses = Disposal.student_addresses.page(params[:page])
37
+ @teacher_addresses = Disposal.teacher_addresses.page(params[:page])
38
+ set_student_and_teacher_count('Gaku::Address')
62
39
  end
63
40
 
64
41
  def contacts
65
- @student_contacts = Contact.includes(:contactable, :contact_type)
66
- .deleted
67
- .students
68
- .page(params[:page])
69
- .per(Preset.default_per_page)
42
+ @student_contacts = Disposal.student_contacts.page(params[:page])
43
+ @teacher_contacts = Disposal.teacher_contacts.page(params[:page])
44
+ set_student_and_teacher_count('Gaku::Contact')
45
+ end
70
46
 
71
- @teacher_contacts = Contact.includes(:contactable, :contact_type)
72
- .deleted
73
- .teachers
74
- .page(params[:page]).
75
- per(Preset.default_per_page)
47
+ private
76
48
 
77
- @students_count = Contact.deleted.students.count
78
- @teachers_count = Contact.deleted.teachers.count
49
+ def set_student_and_teacher_count(klass)
50
+ @students_count = klass.constantize.deleted.students.count
51
+ @teachers_count = klass.constantize.deleted.teachers.count
79
52
  end
80
53
 
81
54
  end
@@ -131,9 +131,9 @@ module Gaku
131
131
 
132
132
  def find_exams
133
133
  if params[:id] != nil
134
- @exams = Exam.find_all_by_id(params[:id])
134
+ @exams = Exam.where(id: params[:id])
135
135
  else
136
- @exams = @course.syllabus.exams.all
136
+ @exams = @course.syllabus.exams
137
137
  end
138
138
  end
139
139
  end
@@ -37,7 +37,7 @@ module Gaku
37
37
  end
38
38
 
39
39
  def load_data
40
- @grading_methods = GradingMethod.all.map { |s| [s.name, s.id] }
40
+ @grading_methods = GradingMethod.pluck(:name, :id)
41
41
  end
42
42
 
43
43
  def syllabus
@@ -45,7 +45,7 @@ module Gaku
45
45
  end
46
46
 
47
47
  def exam_syllabus
48
- @exam_syllabus = ExamSyllabus.find_by_exam_id_and_syllabus_id(params[:id], params[:syllabus_id])
48
+ @exam_syllabus = ExamSyllabus.find_by(exam_id: params[:id], syllabus_id: params[:syllabus_id])
49
49
  end
50
50
 
51
51
 
@@ -18,7 +18,7 @@ module Gaku
18
18
 
19
19
  default_scope -> { where(deleted: false) }
20
20
 
21
- validates :address1, :country_id, :city, presence: true
21
+ validates :address1, :country, :city, presence: true
22
22
 
23
23
  accepts_nested_attributes_for :country
24
24
 
@@ -0,0 +1,45 @@
1
+ module Gaku
2
+ class Disposal
3
+
4
+ def self.students
5
+ Student.deleted
6
+ end
7
+
8
+ def self.teachers
9
+ Teacher.deleted
10
+ end
11
+
12
+ def self.guardians
13
+ Guardian.deleted
14
+ end
15
+
16
+ def self.exams
17
+ Exam.deleted
18
+ end
19
+
20
+ def self.course_groups
21
+ CourseGroup.deleted
22
+ end
23
+
24
+ def self.attachments
25
+ Attachment.includes(:attachable).deleted
26
+ end
27
+
28
+ def self.student_addresses
29
+ Address.includes(:addressable, :country).deleted.students
30
+ end
31
+
32
+ def self.teacher_addresses
33
+ Address.includes(:addressable, :country).deleted.teachers
34
+ end
35
+
36
+ def self.student_contacts
37
+ Contact.includes(:contactable, :contact_type).deleted.students
38
+ end
39
+
40
+ def self.teacher_contacts
41
+ Contact.includes(:contactable, :contact_type).deleted.teachers
42
+ end
43
+
44
+ end
45
+ end
@@ -78,7 +78,7 @@ module Gaku
78
78
  def refresh_positions
79
79
  exam_portions = exam.exam_portions
80
80
  exam_portions.pluck(:id).each_with_index do |id, index|
81
- exam_portions.update_all({position: index}, {id: id})
81
+ exam_portions.where(id: id).update_all(position: index)
82
82
  end
83
83
  end
84
84
 
@@ -78,11 +78,11 @@ module Gaku
78
78
  end
79
79
 
80
80
  def set_scholarship_status
81
- self.scholarship_status = ScholarshipStatus.find_by_default(true)
81
+ self.scholarship_status = ScholarshipStatus.find_by(default: true)
82
82
  end
83
83
 
84
84
  def active
85
- enrollment_status = EnrollmentStatus.find_by_code(enrollment_status_code)
85
+ enrollment_status = EnrollmentStatus.find_by(code: enrollment_status_code)
86
86
  if enrollment_status
87
87
  enrollment_status.active?
88
88
  else
@@ -33,7 +33,7 @@ module Gaku
33
33
  end
34
34
 
35
35
  def role?(role)
36
- !!self.roles.find_by_name(role.to_s.camelize)
36
+ !!self.roles.find_by(name: role.to_s.camelize)
37
37
  end
38
38
 
39
39
  private
@@ -21,9 +21,9 @@ module Gaku::Versioning
21
21
  when 'enrollment_status_code'
22
22
  enrollment_status_code_change(key0, key1)
23
23
  when 'commute_method_type_id'
24
- commute_method_change(key0, key1)
24
+ common_change('CommuteMethodType', key0, key1)
25
25
  when 'scholarship_status_id'
26
- scholarship_status_change(key0, key1)
26
+ common_change('ScholarshipStatus', key0, key1)
27
27
  else
28
28
  @human_changes[key] = [key0, key1]
29
29
  end
@@ -38,16 +38,11 @@ module Gaku::Versioning
38
38
  @human_changes[:enrollment_status] = [from, to]
39
39
  end
40
40
 
41
- def commute_method_change(key0, key1)
42
- from = Gaku::CommuteMethodType.find(key0).to_s if key0
43
- to = Gaku::CommuteMethodType.find(key1).to_s if key1
44
- @human_changes[:commute_method_type] = [from, to]
45
- end
46
-
47
- def scholarship_status_change(key0, key1)
48
- from = Gaku::ScholarshipStatus.find(key0).to_s if key0
49
- to = Gaku::ScholarshipStatus.find(key1).to_s if key1
50
- @human_changes[:scholarship_status] = [from, to]
41
+ def common_change(klass_name, key0, key1)
42
+ klass = "Gaku::#{klass_name}".constantize
43
+ from = klass.find(key0).to_s if key0
44
+ to = klass.find(key1).to_s if key1
45
+ @human_changes[klass_name.underscore.to_sym] = [from, to]
51
46
  end
52
47
 
53
48
  end
@@ -6,7 +6,7 @@
6
6
  = print_count @count, t(:'student.list')
7
7
  .pull-right
8
8
  = ajax_link_to_new t(:'student.new'), new_student_path, id: "new-student-link"
9
- = link_to_import t(:'import'), importer_index_path, id: "import-students-link"
9
+ = render 'gaku/shared/overrides/students/import_link'
10
10
 
11
11
  = content_for :new_form do
12
12
  #new-student.hide
@@ -6,7 +6,7 @@
6
6
  = print_count @count, t_syllabus_list
7
7
  .pull-right
8
8
  = ajax_link_to_new t(:'syllabus.new'), [:new, :syllabus], id: "new-syllabus-link"
9
- = button t(:'syllabus.import'), "syllabuses/importer", id: "import-syllabuses-link"
9
+ = render 'gaku/shared/overrides/syllabuses/import_link'
10
10
 
11
11
  = content_for :new_form do
12
12
  #new-syllabus.hide
@@ -19,7 +19,7 @@ class ActiveRecord::Associations::HasManyThroughAssociation
19
19
  def delete_records(records, method)
20
20
  ensure_not_nested
21
21
 
22
- scope = through_association.scoped.where(construct_join_attributes(*records))
22
+ scope = through_association.scope.where(construct_join_attributes(*records))
23
23
 
24
24
  case method
25
25
  when :destroy
@@ -1,7 +1,5 @@
1
1
  Gaku::Core::Engine.routes.draw do
2
2
 
3
- mount Sidekiq::Web => '/sidekiq'
4
-
5
3
  concern :addressable do
6
4
  resources :addresses do
7
5
  member do
@@ -124,7 +122,6 @@ Gaku::Core::Engine.routes.draw do
124
122
  resources :exams, controller: 'syllabuses/exams'
125
123
  resources :exam_syllabuses, controller: 'syllabuses/exam_syllabuses'
126
124
  resources :notes
127
- resources :importer, controller: 'syllabuses/importer'
128
125
  end
129
126
 
130
127
  resources :teachers, concerns: %i( addressable contactable ) do
@@ -150,12 +147,7 @@ Gaku::Core::Engine.routes.draw do
150
147
  get 'page/:page', action: :index
151
148
  get :load_autocomplete_data
152
149
 
153
- resources :importer, controller: 'students/importer' do
154
- collection do
155
- get :get_roster
156
- get :get_registration_roster
157
- end
158
- end
150
+
159
151
  end
160
152
 
161
153
  resources :simple_grades, controller: 'students/simple_grades'