sis_core 1.0.2 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/sis/core/application_controller.rb +10 -2
  3. data/app/controllers/sis/core/menus_controller.rb +22 -0
  4. data/app/controllers/sis/core/users_controller.rb +71 -0
  5. data/app/models/sis/core/academic_programme.rb +17 -0
  6. data/app/models/sis/core/academic_year.rb +7 -0
  7. data/app/models/sis/core/applicant.rb +8 -1
  8. data/app/models/sis/core/application.rb +50 -0
  9. data/app/models/sis/core/application_document.rb +12 -0
  10. data/app/models/sis/core/application_module.rb +8 -0
  11. data/app/models/sis/core/application_setup.rb +23 -0
  12. data/app/models/sis/core/course.rb +10 -0
  13. data/app/models/sis/core/course_registration.rb +9 -0
  14. data/app/models/sis/core/document_requirement.rb +13 -0
  15. data/app/models/sis/core/{program_type.rb → document_type.rb} +1 -1
  16. data/app/models/sis/core/exam.rb +17 -0
  17. data/app/models/sis/core/exam_result.rb +25 -0
  18. data/app/models/sis/core/exam_setup.rb +15 -0
  19. data/app/models/sis/core/instructor.rb +6 -0
  20. data/app/models/sis/core/instructor_course.rb +8 -0
  21. data/app/models/sis/core/menu.rb +11 -0
  22. data/app/models/sis/core/programme.rb +7 -0
  23. data/app/models/sis/core/programme_level.rb +6 -0
  24. data/app/models/sis/core/programme_type.rb +6 -0
  25. data/app/models/sis/core/semester.rb +11 -0
  26. data/app/models/sis/core/student.rb +7 -0
  27. data/app/models/sis/core/user.rb +13 -0
  28. data/app/models/sis/core/user_role.rb +10 -0
  29. data/app/services/sis/core/user_service.rb +25 -0
  30. data/app/uploaders/sis/core/application_document_uploader.rb +51 -0
  31. data/app/uploaders/sis/core/photo_uploader.rb +51 -0
  32. data/config/routes.rb +6 -0
  33. data/db/migrate/20200105072142_create_sis_core_academic_years.rb +10 -0
  34. data/db/migrate/20200106072246_create_sis_core_semesters.rb +14 -0
  35. data/db/migrate/20200106130428_create_sis_core_programmes.rb +10 -0
  36. data/db/migrate/20200106132035_create_sis_core_academic_programmes.rb +21 -0
  37. data/db/migrate/20200106132521_create_sis_core_application_setups.rb +19 -0
  38. data/db/migrate/20200106133034_create_sis_core_document_requirements.rb +19 -0
  39. data/db/migrate/20200106133937_create_sis_core_applicants.rb +14 -2
  40. data/db/migrate/20200107094449_create_sis_core_applications.rb +24 -0
  41. data/db/migrate/20200107101638_create_sis_core_application_documents.rb +16 -0
  42. data/db/migrate/20200107302251_create_sis_core_exam_setups.rb +15 -0
  43. data/db/migrate/20200107333411_create_sis_core_exams.rb +17 -0
  44. data/db/migrate/20200107434658_create_sis_core_exam_results.rb +18 -0
  45. data/db/migrate/20200307033100_create_sis_core_courses.rb +19 -0
  46. data/db/migrate/20200307071511_create_sis_core_instructors.rb +10 -0
  47. data/db/migrate/20200307071736_create_sis_core_instructor_courses.rb +16 -0
  48. data/db/migrate/20200307072006_create_sis_core_students.rb +16 -0
  49. data/db/migrate/20200307072317_create_sis_core_course_registrations.rb +20 -0
  50. data/db/migrate/20200507114003_create_sis_core_users.rb +17 -0
  51. data/db/migrate/20200511165121_create_sis_core_application_modules.rb +15 -0
  52. data/db/migrate/20200511165241_create_sis_core_user_roles.rb +15 -0
  53. data/db/migrate/20200511165450_create_sis_core_menus.rb +18 -0
  54. data/lib/authorize_request.rb +18 -0
  55. data/lib/json_web_token.rb +12 -0
  56. data/lib/sis/core/engine.rb +2 -2
  57. data/lib/sis/core/version.rb +1 -1
  58. data/lib/sis_core.rb +5 -0
  59. data/spec/factories/sis/core/academic_programmes.rb +8 -0
  60. data/spec/factories/sis/core/academic_years.rb +6 -0
  61. data/spec/factories/sis/core/applicants.rb +9 -2
  62. data/spec/factories/sis/core/application_documents.rb +7 -0
  63. data/spec/factories/sis/core/application_modules.rb +6 -0
  64. data/spec/factories/sis/core/application_setups.rb +9 -0
  65. data/spec/factories/sis/core/applications.rb +11 -0
  66. data/spec/factories/sis/core/course_registrations.rb +7 -0
  67. data/spec/factories/sis/core/courses.rb +12 -0
  68. data/spec/factories/sis/core/document_requirements.rb +9 -0
  69. data/spec/factories/sis/core/document_types.rb +5 -0
  70. data/spec/factories/sis/core/exam_results.rb +8 -0
  71. data/spec/factories/sis/core/exam_setups.rb +8 -0
  72. data/spec/factories/sis/core/exams.rb +10 -0
  73. data/spec/factories/sis/core/instructor_courses.rb +6 -0
  74. data/spec/factories/sis/core/instructors.rb +6 -0
  75. data/spec/factories/sis/core/menus.rb +9 -0
  76. data/spec/factories/sis/core/programme_levels.rb +5 -0
  77. data/spec/factories/sis/core/programme_types.rb +5 -0
  78. data/spec/factories/sis/core/programmes.rb +6 -0
  79. data/spec/factories/sis/core/semesters.rb +7 -0
  80. data/spec/factories/sis/core/students.rb +9 -0
  81. data/spec/factories/sis/core/user_roles.rb +6 -0
  82. data/spec/factories/sis/core/users.rb +9 -0
  83. metadata +169 -22
  84. data/app/models/sis/core/attached_document.rb +0 -8
  85. data/app/models/sis/core/enrollment_application.rb +0 -9
  86. data/app/models/sis/core/program.rb +0 -9
  87. data/app/models/user.rb +0 -9
  88. data/config/initializers/devise_token_auth.rb +0 -55
  89. data/db/migrate/20200106001016_create_sis_core_field_of_studies.rb +0 -9
  90. data/db/migrate/20200106130428_create_sis_core_programs.rb +0 -10
  91. data/db/migrate/20200108092202_devise_token_auth_create_users.rb +0 -53
  92. data/db/migrate/20200108094449_create_sis_core_enrollment_applications.rb +0 -10
  93. data/db/migrate/20200108101638_create_sis_core_attached_documents.rb +0 -11
  94. data/spec/factories/sis/core/attached_documents.rb +0 -7
  95. data/spec/factories/sis/core/enrollment_applications.rb +0 -7
  96. data/spec/factories/sis/core/field_of_studies.rb +0 -6
  97. data/spec/factories/sis/core/program_types.rb +0 -5
  98. data/spec/factories/sis/core/programs.rb +0 -7
@@ -0,0 +1,7 @@
1
+ module Sis
2
+ module Core
3
+ class Student < ApplicationRecord
4
+ belongs_to :program
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,13 @@
1
+ module Sis
2
+ module Core
3
+ class User < ApplicationRecord
4
+ validates :first_name, :last_name, :email, presence: true
5
+ validates :password, presence: true, on: :create
6
+ validates :email, uniqueness: true
7
+ has_and_belongs_to_many :application_modules
8
+ has_and_belongs_to_many :user_roles
9
+
10
+ has_secure_password
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,10 @@
1
+ module Sis
2
+ module Core
3
+ class UserRole < ApplicationRecord
4
+ validates :name, presence: true
5
+ has_and_belongs_to_many :users
6
+ has_and_belongs_to_many :menus
7
+ belongs_to :application_module
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,25 @@
1
+ module Sis
2
+ module Core
3
+ class UserService
4
+ def generate_password_token(user)
5
+ user.update({ reset_password_token: generate_token, reset_password_sent_at: Time.now.utc })
6
+ end
7
+
8
+ def password_token_valid?(user_id)
9
+ user = User.find(user_id)
10
+ (user.reset_password_sent_at + 4.hours) > Time.now.utc
11
+ end
12
+
13
+ def reset_password(user_id, password)
14
+ user = User.find(user_id)
15
+ user.reset_password_token = nil
16
+ user.password = password
17
+ user.save!
18
+ end
19
+
20
+ def generate_token
21
+ SecureRandom.hex(10)
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,51 @@
1
+ module Sis
2
+ module Core
3
+ class ApplicationDocumentUploader < CarrierWave::Uploader::Base
4
+ # Include RMagick or MiniMagick support:
5
+ # include CarrierWave::RMagick
6
+ # include CarrierWave::MiniMagick
7
+
8
+ # Choose what kind of storage to use for this uploader:
9
+ storage :file
10
+ # storage :fog
11
+
12
+ # Override the directory where uploaded files will be stored.
13
+ # This is a sensible default for uploaders that are meant to be mounted:
14
+ def store_dir
15
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
16
+ end
17
+
18
+ # Provide a default URL as a default if there hasn't been a file uploaded:
19
+ # def default_url(*args)
20
+ # # For Rails 3.1+ asset pipeline compatibility:
21
+ # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
22
+ #
23
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
24
+ # end
25
+
26
+ # Process files as they are uploaded:
27
+ # process scale: [200, 300]
28
+ #
29
+ # def scale(width, height)
30
+ # # do something
31
+ # end
32
+
33
+ # Create different versions of your uploaded files:
34
+ # version :thumb do
35
+ # process resize_to_fit: [50, 50]
36
+ # end
37
+
38
+ # Add a white list of extensions which are allowed to be uploaded.
39
+ # For images you might use something like this:
40
+ def extension_whitelist
41
+ %w[pdf]
42
+ end
43
+
44
+ # Override the filename of the uploaded files:
45
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
46
+ # def filename
47
+ # "something.jpg" if original_filename
48
+ # end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,51 @@
1
+ module Sis
2
+ module Core
3
+ class PhotoUploader < CarrierWave::Uploader::Base
4
+ # Include RMagick or MiniMagick support:
5
+ # include CarrierWave::RMagick
6
+ # include CarrierWave::MiniMagick
7
+
8
+ # Choose what kind of storage to use for this uploader:
9
+ storage :file
10
+ # storage :fog
11
+
12
+ # Override the directory where uploaded files will be stored.
13
+ # This is a sensible default for uploaders that are meant to be mounted:
14
+ def store_dir
15
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
16
+ end
17
+
18
+ # Provide a default URL as a default if there hasn't been a file uploaded:
19
+ # def default_url(*args)
20
+ # # For Rails 3.1+ asset pipeline compatibility:
21
+ # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
22
+ #
23
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
24
+ # end
25
+
26
+ # Process files as they are uploaded:
27
+ # process scale: [200, 300]
28
+ #
29
+ # def scale(width, height)
30
+ # # do something
31
+ # end
32
+
33
+ # Create different versions of your uploaded files:
34
+ # version :thumb do
35
+ # process resize_to_fit: [50, 50]
36
+ # end
37
+
38
+ # Add a white list of extensions which are allowed to be uploaded.
39
+ # For images you might use something like this:
40
+ def extension_whitelist
41
+ %w[jpg jpeg gif png]
42
+ end
43
+
44
+ # Override the filename of the uploaded files:
45
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
46
+ # def filename
47
+ # "something.jpg" if original_filename
48
+ # end
49
+ end
50
+ end
51
+ end
@@ -1,2 +1,8 @@
1
1
  Sis::Core::Engine.routes.draw do
2
+ resources :users, only: [:create]
3
+ post '/login', controller: :users, action: :login
4
+ get '/menus', controller: :menus, action: :menu
5
+ post '/sign_in', controller: :users, action: :sign_in
6
+ post '/generate_recovery_token', controller: :users, action: :generate_recovery_token
7
+ post '/reset_password', controller: :users, action: :reset_password
2
8
  end
@@ -0,0 +1,10 @@
1
+ class CreateSisCoreAcademicYears < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_academic_years do |t|
4
+ t.string :year, null: false, unique: true
5
+ t.string :label
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,14 @@
1
+ class CreateSisCoreSemesters < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_semesters do |t|
4
+ t.string :name, null: false
5
+ t.string :description
6
+ t.references :academic_year,
7
+ index: { name: 'ay_on_semester_indx' },
8
+ null: false,
9
+ foreign_key: { to_table: :sis_core_academic_years }
10
+
11
+ t.timestamps
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ class CreateSisCoreProgrammes < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_programmes do |t|
4
+ t.string :code, null: false, unique: true
5
+ t.string :name, null: false, unique: true
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,21 @@
1
+ class CreateSisCoreAcademicProgrammes < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_academic_programmes do |t|
4
+ t.integer :duration, null: false
5
+ t.references :programme,
6
+ null: false,
7
+ index: { name: 'ap_on_programme_indx' },
8
+ foreign_key: { to_table: :sis_core_programmes }
9
+ t.references :programme_type,
10
+ null: false,
11
+ index: { name: 'ap_on_pt_indx' },
12
+ foreign_key: { to_table: :sis_core_lookups }
13
+ t.references :programme_level,
14
+ null: false,
15
+ index: { name: 'ap_on_pl_indx' },
16
+ foreign_key: { to_table: :sis_core_lookups }
17
+
18
+ t.timestamps
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ class CreateSisCoreApplicationSetups < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_application_setups do |t|
4
+ t.date :start_date, null: false
5
+ t.date :end_date, null: false
6
+ t.string :status, null: false, default: 'Open'
7
+ t.references :academic_programme,
8
+ null: false,
9
+ index: { name: 'as_on_ap_indx' },
10
+ foreign_key: { to_table: :sis_core_academic_programmes }
11
+ t.references :target_semester,
12
+ null: false,
13
+ index: { name: 'as_on_ts_indx' },
14
+ foreign_key: { to_table: :sis_core_semesters }
15
+
16
+ t.timestamps
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,19 @@
1
+ class CreateSisCoreDocumentRequirements < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_document_requirements do |t|
4
+ t.integer :original, null: false, default: 0
5
+ t.integer :copy, null: false, default: 0
6
+ t.string :remark
7
+ t.references :document_type,
8
+ null: false,
9
+ index: { name: 'adr_on_dc_indx' },
10
+ foreign_key: { to_table: :sis_core_lookups }
11
+ t.references :application_setup,
12
+ null: false,
13
+ index: { name: 'adr_on_as_indx' },
14
+ foreign_key: { to_table: :sis_core_application_setups }
15
+
16
+ t.timestamps
17
+ end
18
+ end
19
+ end
@@ -4,8 +4,20 @@ class CreateSisCoreApplicants < ActiveRecord::Migration[6.0]
4
4
  t.string :first_name, null: false
5
5
  t.string :middle_name, null: false
6
6
  t.string :last_name, null: false
7
- t.string :email, null: false, unique: true
8
- t.string :phone_number, null: false
7
+ t.string :password_digest, null: false
8
+ t.string :email, null: false
9
+ t.string :alternative_email_address
10
+ t.string :primary_phone_number
11
+ t.string :alternative_telephone_number
12
+ t.date :date_of_birth
13
+ t.string :gender
14
+ t.string :nationality
15
+ t.string :address
16
+ t.string :photo
17
+ t.string :reset_password_token
18
+ t.datetime :reset_password_sent_at
19
+ t.string :secret_question
20
+ t.string :secret_question_answer
9
21
 
10
22
  t.timestamps
11
23
  end
@@ -0,0 +1,24 @@
1
+ class CreateSisCoreApplications < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_applications do |t|
4
+ t.string :status, null: false, default: 'Draft'
5
+ t.boolean :payment_made, null: false, default: false
6
+ t.string :payment_information
7
+ t.date :application_date
8
+ t.references :applicant,
9
+ null: false,
10
+ index: { name: 'applications_on_applicant_indx' },
11
+ foreign_key: { to_table: :sis_core_applicants }
12
+ t.references :academic_programme,
13
+ null: false,
14
+ index: { name: 'applications_on_ap_indx' },
15
+ foreign_key: { to_table: :sis_core_academic_programmes }
16
+ t.references :application_setup,
17
+ null: false,
18
+ index: { name: 'application_setup_on_ap_indx' },
19
+ foreign_key: { to_table: :sis_core_application_setups }
20
+
21
+ t.timestamps
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,16 @@
1
+ class CreateSisCoreApplicationDocuments < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_application_documents do |t|
4
+ t.string :document
5
+ t.references :document_requirement,
6
+ null: false,
7
+ index: { name: 'ad_on_adr_indx' },
8
+ foreign_key: { to_table: :sis_core_document_requirements }
9
+ t.references :application,
10
+ null: false,
11
+ index: { name: 'ad_on_application_indx' },
12
+ foreign_key: { to_table: :sis_core_applications }
13
+ t.timestamps
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,15 @@
1
+ class CreateSisCoreExamSetups < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_exam_setups do |t|
4
+ t.date :date, null: false
5
+ t.float :hours, null: false
6
+ t.string :venue, null: false
7
+ t.references :application_setup,
8
+ null: false,
9
+ index: { name: 'es_on_as_indx' },
10
+ foreign_key: { to_table: :sis_core_application_setups }
11
+
12
+ t.timestamps
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,17 @@
1
+ class CreateSisCoreExams < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_exams do |t|
4
+ t.string :title, null: false
5
+ t.datetime :start, null: false
6
+ t.datetime :finish, null: false
7
+ t.float :points, null: false
8
+ t.float :pass_point, null: false
9
+ t.references :exam_setup,
10
+ null: false,
11
+ index: { name: 'exams_on_es_indx' },
12
+ foreign_key: { to_table: :sis_core_exam_setups }
13
+
14
+ t.timestamps
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,18 @@
1
+ class CreateSisCoreExamResults < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_exam_results do |t|
4
+ t.float :points, null: false
5
+ t.string :status, null: false
6
+ t.references :exam,
7
+ null: false,
8
+ index: { name: 'er_on_exam_indx' },
9
+ foreign_key: { to_table: :sis_core_exams }
10
+ t.references :application,
11
+ null: false,
12
+ index: { name: 'er_on_application_indx' },
13
+ foreign_key: { to_table: :sis_core_applications }
14
+
15
+ t.timestamps
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,19 @@
1
+ class CreateSisCoreCourses < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_courses do |t|
4
+ t.string :code, null: false, unique: true
5
+ t.string :title, null: false
6
+ t.string :description, null: false
7
+ t.float :credit_hours, null: false
8
+ t.float :ects, null: false
9
+ t.float :lecture_hours, null: false
10
+ t.float :lab_hours, null: false
11
+ t.references :academic_programme,
12
+ index: { name: 'program_on_courses_indx' },
13
+ null: false,
14
+ foreign_key: { to_table: :sis_core_academic_programmes }
15
+
16
+ t.timestamps
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,10 @@
1
+ class CreateSisCoreInstructors < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_instructors do |t|
4
+ t.string :full_name, null: false
5
+ t.date :date_of_birth, null: false
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,16 @@
1
+ class CreateSisCoreInstructorCourses < ActiveRecord::Migration[6.0]
2
+ def change
3
+ create_table :sis_core_instructor_courses do |t|
4
+ t.references :instructor,
5
+ index: { name: 'instructor_on_ic_indx' },
6
+ null: false,
7
+ foreign_key: { to_table: :sis_core_instructors }
8
+ t.references :course,
9
+ index: { name: 'course_on_ic_indx' },
10
+ null: false,
11
+ foreign_key: { to_table: :sis_core_courses }
12
+
13
+ t.timestamps
14
+ end
15
+ end
16
+ end