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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 14faad0cf0f85f1e88fd5c68b66340052d1965d9
4
- data.tar.gz: 2f51003756ab6cba95b33d8633bd4af029977bb2
3
+ metadata.gz: b8ec2a924579efe2c5e618e4ebf79066ffd3bc19
4
+ data.tar.gz: dd6421683b81443905db7df3b1ea9bfd43acc09b
5
5
  SHA512:
6
- metadata.gz: f80add224aa2321f0aca9615ac847994831072983da47a050c7fba7f783bb094ee7fc8cd785ab95a7b0d3f5b5acd182269799dc26fe2a21798b2e11f39e5c17c
7
- data.tar.gz: 273ec20c3a8fc976c82ecc392507581d234b6bc41e774aed271f8e15ccf240c4d79d78e69770438f3b0530c63cf9bed7b81104e7cee284c480c89fa816c8a92f
6
+ metadata.gz: 43e5b0dfef9b6856697da0fc162ce9948ff44534d0eddcde86bff31bf46a2aed4c941a7e79c96a532187f08e8abe6ab6467122dee914ea4a9587dc036afeaf7d
7
+ data.tar.gz: 5126158bc5f912f6f5e716fa53f3c6eec2c4d4dd9efd91e1bb9b5a65f96fd4f4488f4bde7b04d931eec3a9a58c3a302127f40ae2c9cbcd508e6ff97fe57e6611
@@ -0,0 +1,55 @@
1
+ module Gaku
2
+ class Admin::DepartmentsController < Admin::BaseController
3
+
4
+ #load_and_authorize_resource class: Department
5
+
6
+ respond_to :js, only: %i( new create edit update destroy )
7
+ respond_to :html, only: :index
8
+
9
+ before_action :set_department, only: %i( edit update destroy )
10
+
11
+ def index
12
+ @departments = Department.all
13
+ @count = Department.count
14
+ respond_with @departments
15
+ end
16
+
17
+ def new
18
+ @department = Department.new
19
+ respond_with @department
20
+ end
21
+
22
+ def create
23
+ @department = Department.new(department_params)
24
+ @department.save
25
+ @count = Department.count
26
+ respond_with @department
27
+ end
28
+
29
+ def edit
30
+ end
31
+
32
+ def update
33
+ @department.update(department_params)
34
+ respond_with @department
35
+ end
36
+
37
+ def destroy
38
+ @department.destroy
39
+ @count = Department.count
40
+ respond_with @department
41
+ end
42
+
43
+ private
44
+
45
+ def set_department
46
+ @department = Department.find(params[:id])
47
+ end
48
+
49
+ def department_params
50
+ params.require(:department).permit(:name)
51
+ end
52
+
53
+
54
+ end
55
+ end
@@ -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
 
@@ -5,6 +5,13 @@ module Gaku
5
5
  include TranslationsHelper
6
6
  include FlashHelper
7
7
 
8
+ def tr_for(resource, &block)
9
+ content_tag :tr, id: "#{resource.class.to_s.demodulize.underscore.dasherize}-#{resource.id}" do
10
+ block.call
11
+ end
12
+ end
13
+
14
+
8
15
  def current_parent_controller
9
16
  controller.controller_path.split('/').second
10
17
  end
@@ -177,5 +177,9 @@ module Gaku
177
177
  t(:'template.list')
178
178
  end
179
179
 
180
+ def t_department_list
181
+ t(:'department.list')
182
+ end
183
+
180
184
  end
181
185
  end
@@ -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,13 @@
1
+ module Gaku
2
+ class Department < ActiveRecord::Base
3
+
4
+ translates :name
5
+
6
+ validates :name, presence: true, uniqueness: true
7
+
8
+ def to_s
9
+ name
10
+ end
11
+
12
+ end
13
+ end
@@ -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
@@ -0,0 +1,2 @@
1
+ =tr_for department do
2
+ = render 'table_fields', department: department
@@ -0,0 +1,3 @@
1
+ = remote_form_for [:admin, @department] do |f|
2
+ = render 'form_fields', f: f
3
+ = buttons_for @department, nested_id: 'admin-department'
@@ -0,0 +1 @@
1
+ = f.text_field :name, label: t(:'department.name')
@@ -0,0 +1,6 @@
1
+ = modal_for 'edit-department-modal' do
2
+ = modal_header t(:'department.edit')
3
+ = modal_form_for [:admin, @department] do |f|
4
+ = modal_body do
5
+ = render 'form_fields', f: f
6
+ = modal_buttons_for @department, nested_id: 'admin-department'
@@ -0,0 +1,5 @@
1
+ td = department.name
2
+ td
3
+ = ajax_link_to_edit [:edit, :admin, department]
4
+ = ajax_link_to_delete [:admin, department]
5
+
@@ -0,0 +1,7 @@
1
+ $('#admin-departments-index tbody').append('<%= j render("department", {department: @department}) %>');
2
+
3
+ $('#new-admin-department').slide();
4
+ $('#new-admin-department-link').show();
5
+
6
+ $('.admin-departments-count').html('<%= print_count(@count, t_department_list) %>');
7
+ showNotice("<%= render_flash %>");
@@ -0,0 +1,2 @@
1
+ $('.admin-departments-count').html('<%= print_count(@count, t_department_list) %>');
2
+ showNotice("<%= render_flash %>");
@@ -0,0 +1,3 @@
1
+ $('#modal-dialogs').html('<%= j render("modal", {department: @department}) %>');
2
+ $('#edit-department-modal').modal('show');
3
+ $('.remote-form').enableValidations();
@@ -0,0 +1,20 @@
1
+ = content_for :index_header do
2
+ .pull-left
3
+ = count_div 'admin-departments-count' do
4
+ = print_count @count, t_department_list
5
+ .pull-right
6
+ = ajax_link_to_new t(:'department.add'), [:new, :admin, :department], id: 'new-admin-department-link'
7
+
8
+ = content_for :new_form do
9
+ #new-admin-department.hide
10
+
11
+ #admin-departments
12
+ = table_for 'admin-departments-index' do
13
+ thead
14
+ tr
15
+ = th t(:'department.name')
16
+
17
+ = th_actions 2
18
+ tbody
19
+ = render partial: 'gaku/admin/departments/department', collection: @departments, as: :department
20
+
@@ -0,0 +1,3 @@
1
+ $('#new-admin-department').html('<%= j render("form") %>').slide();
2
+ $('#new-admin-department-link').hide();
3
+ $('.remote-form').enableValidations();
@@ -0,0 +1,4 @@
1
+ $('tr#department-<%= @department.id %>').html('<%= j render("table_fields", {department: @department}) %>');
2
+ $("#edit-department-modal").modal("hide");
3
+ showNotice("<%= render_flash %>");
4
+
@@ -10,6 +10,7 @@
10
10
  <li data-hook="specialties"><%= link_to t('menu.admin.specialties'), admin_specialties_path %></li>
11
11
  <li data-hook="achievement"><%= link_to t('menu.admin.achievements'), admin_achievements_path %></li>
12
12
  <li data-hook="template"><%= link_to t('menu.admin.templates'), admin_templates_path %></li>
13
+ <li data-hook="deparment"><%= link_to t('menu.admin.departments'), admin_departments_path %></li>
13
14
 
14
15
  <li class="dropdown-submenu" data-hook="grading_sub_menu">
15
16
  <a tabindex='-1' href='#'><%= t('menu.admin.grading.grading') %></a>
@@ -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
@@ -245,6 +245,13 @@ en:
245
245
  singular: Course Group
246
246
  course_group_enrollment:
247
247
  save: Save to Course Group
248
+ department:
249
+ singular: Department
250
+ add: Add department
251
+ list: Departments list
252
+ name: Department name
253
+ edit: Edit department
254
+ save: Save department
248
255
  date:
249
256
  formats:
250
257
  default: '%Y-%m-%d'
@@ -538,6 +545,7 @@ en:
538
545
  student_addresses: Student Addresses
539
546
  student_contacts: Student Contacts
540
547
  students: Students
548
+ departments: Departments
541
549
  disposals:
542
550
  address: Addresses Disposals
543
551
  attachment: Attachment Disposals
data/config/routes.rb CHANGED
@@ -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'
@@ -230,6 +222,7 @@ Gaku::Core::Engine.routes.draw do
230
222
  resources :contact_types
231
223
  resources :enrollment_statuses
232
224
  resources :attendance_types
225
+ resources :departments
233
226
  resources :users do
234
227
  get 'page/:page', action: :index, on: :collection
235
228
  end
@@ -1,6 +1,7 @@
1
1
  types = [
2
2
  {
3
3
  name: 'Present',
4
+ name_ja: 'Japanese Present',
4
5
  color_code: '#006e54',
5
6
  counted_absent: false,
6
7
  disable_credit: false,
@@ -10,6 +11,7 @@ types = [
10
11
 
11
12
  {
12
13
  name: 'Present for Credit',
14
+ name_ja: 'Japanese Present for Credit',
13
15
  color_code: '#00a497',
14
16
  counted_absent: false,
15
17
  disable_credit: false,
@@ -19,6 +21,7 @@ types = [
19
21
 
20
22
  {
21
23
  name: 'Excused',
24
+ name_ja: 'Japanese Excused',
22
25
  color_code: '#2c4f54',
23
26
  counted_absent: false,
24
27
  disable_credit: false,
@@ -28,6 +31,7 @@ types = [
28
31
 
29
32
  {
30
33
  name: 'Illness',
34
+ name_ja: 'Japanese Illness',
31
35
  color_code: '#4d4398',
32
36
  counted_absent: true,
33
37
  disable_credit: false,
@@ -37,6 +41,7 @@ types = [
37
41
 
38
42
  {
39
43
  name: 'Injury',
44
+ name: 'Japanese Injury',
40
45
  color_code: '#c85179',
41
46
  counted_absent: true,
42
47
  disable_credit: false,
@@ -46,6 +51,7 @@ types = [
46
51
 
47
52
  {
48
53
  name: 'Mourning',
54
+ name_ja: 'Japanese Mourning',
49
55
  color_code: '#7d7d7d',
50
56
  counted_absent: true,
51
57
  disable_credit: false,
@@ -55,6 +61,7 @@ types = [
55
61
 
56
62
  {
57
63
  name: 'Absent',
64
+ name_ja: 'Japanese Absent',
58
65
  color_code: '#e60033',
59
66
  counted_absent: true,
60
67
  disable_credit: true,
@@ -62,16 +69,19 @@ types = [
62
69
  auto_credit: false
63
70
  }
64
71
  ]
65
- japanese_attendance_types = ['Japanese Present', 'Japanese Present for Credit',
66
- 'Japanese Excused', 'Japanese Illness',
67
- 'Japanese Injury', 'Japanese Mourning',
68
- 'Japanese Absent'
69
- ]
70
72
 
71
- types.each_with_index do |type, index|
73
+
74
+ types.each do |type|
72
75
  I18n.locale = :en
73
- attendance_type = Gaku::AttendanceType.where(type).first_or_create!
76
+ attendance_type = Gaku::AttendanceType.create!(
77
+ name: type[:name],
78
+ color_code: type[:color_code],
79
+ counted_absent: type[:counted_absent],
80
+ disable_credit: type[:disable_credit],
81
+ credit_rate: type[:credit_rate],
82
+ auto_credit: type[:auto_credit]
83
+ )
74
84
 
75
85
  I18n.locale = :ja
76
- attendance_type.update_attributes(name: japanese_attendance_types[index])
86
+ attendance_type.update_attributes(name: type[:name_ja])
77
87
  end