sis_core 1.0.3 → 1.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (93) 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 +1 -0
  7. data/app/models/sis/core/applicant.rb +18 -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/document_requirement.rb +13 -0
  13. data/app/models/sis/core/{program_type.rb → document_type.rb} +1 -1
  14. data/app/models/sis/core/exam.rb +17 -0
  15. data/app/models/sis/core/exam_result.rb +25 -0
  16. data/app/models/sis/core/exam_setup.rb +15 -0
  17. data/app/models/sis/core/menu.rb +11 -0
  18. data/app/models/sis/core/programme.rb +7 -0
  19. data/app/models/sis/core/programme_level.rb +6 -0
  20. data/app/models/sis/core/programme_type.rb +6 -0
  21. data/app/models/sis/core/semester.rb +4 -0
  22. data/app/models/sis/core/user.rb +13 -0
  23. data/app/models/sis/core/user_role.rb +10 -0
  24. data/app/services/sis/core/user_service.rb +25 -0
  25. data/app/uploaders/sis/core/application_document_uploader.rb +51 -0
  26. data/app/uploaders/sis/core/photo_uploader.rb +51 -0
  27. data/config/routes.rb +6 -0
  28. data/db/migrate/{20200307072142_create_sis_core_academic_years.rb → 20200105072142_create_sis_core_academic_years.rb} +2 -1
  29. data/db/migrate/{20200307072246_create_sis_core_semesters.rb → 20200106072246_create_sis_core_semesters.rb} +0 -0
  30. data/db/migrate/20200106130428_create_sis_core_programmes.rb +10 -0
  31. data/db/migrate/20200106132035_create_sis_core_academic_programmes.rb +21 -0
  32. data/db/migrate/20200106132521_create_sis_core_application_setups.rb +19 -0
  33. data/db/migrate/20200106133034_create_sis_core_document_requirements.rb +19 -0
  34. data/db/migrate/20200106133937_create_sis_core_applicants.rb +14 -2
  35. data/db/migrate/20200107094449_create_sis_core_applications.rb +24 -0
  36. data/db/migrate/20200107101638_create_sis_core_application_documents.rb +16 -0
  37. data/db/migrate/20200107302251_create_sis_core_exam_setups.rb +15 -0
  38. data/db/migrate/20200107333411_create_sis_core_exams.rb +17 -0
  39. data/db/migrate/20200107434658_create_sis_core_exam_results.rb +18 -0
  40. data/db/migrate/20200307033100_create_sis_core_courses.rb +2 -2
  41. data/db/migrate/20200307072006_create_sis_core_students.rb +2 -2
  42. data/db/migrate/20200507114003_create_sis_core_users.rb +17 -0
  43. data/db/migrate/20200511165121_create_sis_core_application_modules.rb +15 -0
  44. data/db/migrate/20200511165241_create_sis_core_user_roles.rb +15 -0
  45. data/db/migrate/20200511165450_create_sis_core_menus.rb +18 -0
  46. data/lib/authorize_request.rb +18 -0
  47. data/lib/json_web_token.rb +12 -0
  48. data/lib/sis/core/engine.rb +2 -2
  49. data/lib/sis/core/version.rb +1 -1
  50. data/lib/sis_core.rb +5 -0
  51. data/spec/factories/sis/core/academic_programmes.rb +8 -0
  52. data/spec/factories/sis/core/academic_years.rb +3 -2
  53. data/spec/factories/sis/core/applicants.rb +9 -2
  54. data/spec/factories/sis/core/application_documents.rb +7 -0
  55. data/spec/factories/sis/core/application_modules.rb +6 -0
  56. data/spec/factories/sis/core/application_setups.rb +9 -0
  57. data/spec/factories/sis/core/applications.rb +11 -0
  58. data/spec/factories/sis/core/document_requirements.rb +9 -0
  59. data/spec/factories/sis/core/document_types.rb +5 -0
  60. data/spec/factories/sis/core/exam_results.rb +8 -0
  61. data/spec/factories/sis/core/exam_setups.rb +8 -0
  62. data/spec/factories/sis/core/exams.rb +10 -0
  63. data/spec/factories/sis/core/instructor_courses.rb +2 -2
  64. data/spec/factories/sis/core/instructors.rb +2 -2
  65. data/spec/factories/sis/core/menus.rb +9 -0
  66. data/spec/factories/sis/core/programme_levels.rb +5 -0
  67. data/spec/factories/sis/core/programme_types.rb +5 -0
  68. data/spec/factories/sis/core/programmes.rb +6 -0
  69. data/spec/factories/sis/core/semesters.rb +1 -1
  70. data/spec/factories/sis/core/students.rb +5 -5
  71. data/spec/factories/sis/core/user_roles.rb +6 -0
  72. data/spec/factories/sis/core/users.rb +9 -0
  73. metadata +150 -29
  74. data/app/models/sis/core/attached_document.rb +0 -8
  75. data/app/models/sis/core/enrollment_application.rb +0 -9
  76. data/app/models/sis/core/program.rb +0 -9
  77. data/app/models/sis/core/staff.rb +0 -21
  78. data/app/models/user.rb +0 -12
  79. data/config/initializers/devise_token_auth.rb +0 -55
  80. data/db/migrate/20200106001016_create_sis_core_field_of_studies.rb +0 -9
  81. data/db/migrate/20200106130428_create_sis_core_programs.rb +0 -10
  82. data/db/migrate/20200108092202_devise_token_auth_create_users.rb +0 -53
  83. data/db/migrate/20200108094449_create_sis_core_enrollment_applications.rb +0 -10
  84. data/db/migrate/20200108101638_create_sis_core_attached_documents.rb +0 -11
  85. data/db/migrate/20200316120805_create_sis_core_staffs.rb +0 -31
  86. data/db/migrate/20200319074334_modify_user.rb +0 -16
  87. data/spec/factories/sis/core/attached_documents.rb +0 -7
  88. data/spec/factories/sis/core/enrollment_applications.rb +0 -7
  89. data/spec/factories/sis/core/field_of_studies.rb +0 -6
  90. data/spec/factories/sis/core/program_types.rb +0 -5
  91. data/spec/factories/sis/core/programs.rb +0 -7
  92. data/spec/factories/sis/core/staffs.rb +0 -32
  93. data/spec/factories/users.rb +0 -11
@@ -1,8 +0,0 @@
1
- module Sis
2
- module Core
3
- class AttachedDocument < ApplicationRecord
4
- validates :document, :document_type, presence: true
5
- belongs_to :enrollment_application, class_name: 'Sis::Core::EnrollmentApplication'
6
- end
7
- end
8
- end
@@ -1,9 +0,0 @@
1
- module Sis
2
- module Core
3
- class EnrollmentApplication < ApplicationRecord
4
- validates :status, presence: true
5
- belongs_to :applicant, class_name: 'Sis::Core::Applicant'
6
- belongs_to :program, class_name: 'Sis::Core::Program'
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- module Sis
2
- module Core
3
- class Program < ApplicationRecord
4
- belongs_to :program_type, class_name: 'Sis::Core::ProgramType', foreign_key: 'lookup_id'
5
- belongs_to :field_of_study, class_name: 'Sis::Core::FieldOfStudy'
6
- validates :mode_of_attendance, presence: true
7
- end
8
- end
9
- end
@@ -1,21 +0,0 @@
1
- module Sis
2
- module Core
3
- class Staff < ApplicationRecord
4
- belongs_to :user, class_name: 'User'
5
- SINGLE = 'Single'.freeze
6
- MARRIED = 'Married'.freeze
7
- MARITAL_STATUS = [SINGLE, MARRIED].freeze
8
- validates :job_title, :job_level, :department, :date_of_employment, :salary,
9
- :remark, :mothers_name, :education_level, :phone_number,
10
- :place_of_birth, :marital_status, :region, :zone, :wereda,
11
- :kebele, :id_number,
12
- :emergency_contact_name, :emergency_contact_phone,
13
- :relation_to_emergency_contact, :user_id,
14
- presence: true
15
- validates :salary, numericality: true
16
- validates :marital_status, inclusion: { in: MARITAL_STATUS }
17
- validates :id_number, uniqueness: true
18
- validates :passport_number, uniqueness: true, if: :passport_number?
19
- end
20
- end
21
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- class User < ActiveRecord::Base
4
- extend Devise::Models
5
- # Include default devise modules. Others available are:
6
- # :confirmable, :lockable, :timeoutable and :omniauthable
7
- devise :database_authenticatable, :registerable,
8
- :recoverable, :rememberable, :trackable, :validatable
9
- include DeviseTokenAuth::Concerns::User
10
-
11
- validates :first_name, :middle_name, :last_name, :password, :email, :gender, :date_of_birth, presence: true
12
- end
@@ -1,55 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- DeviseTokenAuth.setup do |config|
4
- # By default the authorization headers will change after each request. The
5
- # client is responsible for keeping track of the changing tokens. Change
6
- # this to false to prevent the Authorization header from changing after
7
- # each request.
8
- # config.change_headers_on_each_request = true
9
-
10
- # By default, users will need to re-authenticate after 2 weeks. This setting
11
- # determines how long tokens will remain valid after they are issued.
12
- # config.token_lifespan = 2.weeks
13
-
14
- # Limiting the token_cost to just 4 in testing will increase the performance of
15
- # your test suite dramatically. The possible cost value is within range from 4
16
- # to 31. It is recommended to not use a value more than 10 in other environments.
17
- config.token_cost = Rails.env.test? ? 4 : 10
18
-
19
- # Sets the max number of concurrent devices per user, which is 10 by default.
20
- # After this limit is reached, the oldest tokens will be removed.
21
- # config.max_number_of_devices = 10
22
-
23
- # Sometimes it's necessary to make several requests to the API at the same
24
- # time. In this case, each request in the batch will need to share the same
25
- # auth token. This setting determines how far apart the requests can be while
26
- # still using the same auth token.
27
- # config.batch_request_buffer_throttle = 5.seconds
28
-
29
- # This route will be the prefix for all oauth2 redirect callbacks. For
30
- # example, using the default '/omniauth', the github oauth2 provider will
31
- # redirect successful authentications to '/omniauth/github/callback'
32
- # config.omniauth_prefix = "/omniauth"
33
-
34
- # By default sending current password is not needed for the password update.
35
- # Uncomment to enforce current_password param to be checked before all
36
- # attribute updates. Set it to :password if you want it to be checked only if
37
- # password is updated.
38
- # config.check_current_password_before_update = :attributes
39
-
40
- # By default we will use callbacks for single omniauth.
41
- # It depends on fields like email, provider and uid.
42
- # config.default_callbacks = true
43
-
44
- # Makes it possible to change the headers names
45
- # config.headers_names = {:'access-token' => 'access-token',
46
- # :'client' => 'client',
47
- # :'expiry' => 'expiry',
48
- # :'uid' => 'uid',
49
- # :'token-type' => 'token-type' }
50
-
51
- # By default, only Bearer Token authentication is implemented out of the box.
52
- # If, however, you wish to integrate with legacy Devise authentication, you can
53
- # do so by enabling this flag. NOTE: This feature is highly experimental!
54
- # config.enable_standard_devise_support = false
55
- end
@@ -1,9 +0,0 @@
1
- class CreateSisCoreFieldOfStudies < ActiveRecord::Migration[6.0]
2
- def change
3
- create_table :sis_core_field_of_studies do |t|
4
- t.string :name
5
- t.references :lookup, index: true, null: false, foreign_key: { to_table: :sis_core_lookups }
6
- t.timestamps
7
- end
8
- end
9
- end
@@ -1,10 +0,0 @@
1
- class CreateSisCorePrograms < ActiveRecord::Migration[6.0]
2
- def change
3
- create_table :sis_core_programs do |t|
4
- t.string :mode_of_attendance, null: false
5
- t.references :lookup, index: true, null: false, foreign_key: { to_table: :sis_core_lookups }
6
- t.references :field_of_study, index: true, null: false, foreign_key: { to_table: :sis_core_field_of_studies }
7
- t.timestamps
8
- end
9
- end
10
- end
@@ -1,53 +0,0 @@
1
- class DeviseTokenAuthCreateUsers < ActiveRecord::Migration[6.0]
2
- def change
3
- create_table(:users) do |t|
4
- ## Required
5
- t.string :provider, null: false, default: 'email'
6
- t.string :uid, null: false, default: ''
7
-
8
- ## Database authenticatable
9
- t.string :encrypted_password, null: false, default: ''
10
-
11
- ## Recoverable
12
- t.string :reset_password_token
13
- t.datetime :reset_password_sent_at
14
- t.boolean :allow_password_change, default: false
15
-
16
- ## Rememberable
17
- t.datetime :remember_created_at
18
-
19
- ## Confirmable
20
- t.string :confirmation_token
21
- t.datetime :confirmed_at
22
- t.datetime :confirmation_sent_at
23
- t.string :unconfirmed_email # Only if using reconfirmable
24
- ## Trackable
25
- t.integer :sign_in_count, default: 0, null: false
26
- t.datetime :current_sign_in_at
27
- t.datetime :last_sign_in_at
28
- t.string :current_sign_in_ip
29
- t.string :last_sign_in_ip
30
- ## Lockable
31
- # t.integer :failed_attempts, :default => 0, :null => false # Only if lock strategy is :failed_attempts
32
- # t.string :unlock_token # Only if unlock strategy is :email or :both
33
- # t.datetime :locked_at
34
-
35
- ## User Info
36
- t.string :name
37
- t.string :nickname
38
- t.string :image
39
- t.string :email
40
-
41
- ## Tokens
42
- t.text :tokens
43
-
44
- t.timestamps
45
- end
46
-
47
- add_index :users, :email, unique: true
48
- add_index :users, %i[uid provider], unique: true
49
- add_index :users, :reset_password_token, unique: true
50
- add_index :users, :confirmation_token, unique: true
51
- # add_index :users, :unlock_token, unique: true
52
- end
53
- end
@@ -1,10 +0,0 @@
1
- class CreateSisCoreEnrollmentApplications < ActiveRecord::Migration[6.0]
2
- def change
3
- create_table :sis_core_enrollment_applications do |t|
4
- t.string :status, null: false
5
- t.references :applicant, index: true, null: false, foreign_key: { to_table: :sis_core_applicants }
6
- t.references :program, index: true, null: false, foreign_key: { to_table: :sis_core_programs }
7
- t.timestamps
8
- end
9
- end
10
- end
@@ -1,11 +0,0 @@
1
- class CreateSisCoreAttachedDocuments < ActiveRecord::Migration[6.0]
2
- def change
3
- create_table :sis_core_attached_documents do |t|
4
- t.string :document, null: false
5
- t.string :document_type, null: false
6
- t.references :enrollment_application, index: true, null: false,
7
- foreign_key: { to_table: :sis_core_enrollment_applications }
8
- t.timestamps
9
- end
10
- end
11
- end
@@ -1,31 +0,0 @@
1
- class CreateSisCoreStaffs < ActiveRecord::Migration[6.0]
2
- def change
3
- create_table :sis_core_staffs do |t|
4
- t.string :job_title, null: false
5
- t.string :job_level, null: false
6
- t.string :department, null: false
7
- t.date :date_of_employment, null: false
8
- t.float :salary, null: false
9
- t.text :remark, null: false
10
- t.string :mothers_name, null: false
11
- t.string :education_level, null: false
12
- t.string :phone_number, null: false
13
- t.string :place_of_birth, null: false
14
- t.string :marital_status, null: false
15
- t.string :region, null: false
16
- t.string :zone, null: false
17
- t.string :wereda, null: false
18
- t.string :kebele, null: false
19
- t.string :passport_number
20
- t.string :id_number, null: false, unique: true
21
- t.string :emergency_contact_name, null: false
22
- t.string :emergency_contact_phone, null: false
23
- t.string :relation_to_emergency_contact, null: false
24
- t.references :user,
25
- index: { name: 'user_on_staff_indx' },
26
- null: false,
27
- foreign_key: { to_table: :users }
28
- t.timestamps
29
- end
30
- end
31
- end
@@ -1,16 +0,0 @@
1
- class ModifyUser < ActiveRecord::Migration[6.0]
2
- def change
3
- remove_column :users, :name, :string
4
- remove_column :users, :nickname, :string
5
- add_column :users, :first_name, :string
6
- add_column :users, :middle_name, :string
7
- add_column :users, :last_name, :string
8
- add_column :users, :gender, :string
9
- add_column :users, :date_of_birth, :date
10
- change_column :users, :first_name, :string, null: false
11
- change_column :users, :middle_name, :string, null: false
12
- change_column :users, :last_name, :string, null: false
13
- change_column :users, :gender, :string, null: false
14
- change_column :users, :date_of_birth, :date, null: false
15
- end
16
- end
@@ -1,7 +0,0 @@
1
- FactoryBot.define do
2
- factory :attached_document, class: 'Sis::Core::AttachedDocument' do
3
- document { FFaker::Name.name }
4
- document_type { FFaker::Name.name }
5
- association :enrollment_application
6
- end
7
- end
@@ -1,7 +0,0 @@
1
- FactoryBot.define do
2
- factory :enrollment_application, class: 'Sis::Core::EnrollmentApplication' do
3
- status { FFaker::Name.name }
4
- association :applicant
5
- association :program
6
- end
7
- end
@@ -1,6 +0,0 @@
1
- FactoryBot.define do
2
- factory :field_of_study, class: 'Sis::Core::FieldOfStudy' do
3
- name { FFaker::Name.name }
4
- association :program_type
5
- end
6
- end
@@ -1,5 +0,0 @@
1
- FactoryBot.define do
2
- factory :program_type, class: 'Sis::Core::ProgramType', parent: :lookup do
3
- type { 'Sis::Core::ProgramType' }
4
- end
5
- end
@@ -1,7 +0,0 @@
1
- FactoryBot.define do
2
- factory :program, class: 'Sis::Core::Program' do
3
- mode_of_attendance { FFaker::Name.name }
4
- association :program_type
5
- association :field_of_study
6
- end
7
- end
@@ -1,32 +0,0 @@
1
- FactoryBot.define do
2
- SINGLE = 'Single'.freeze
3
- MARRIED = 'Married'.freeze
4
- MARITAL_STATUS = [SINGLE, MARRIED].freeze
5
- factory :staff, class: 'Sis::Core::Staff' do
6
- user
7
- job_title { FFaker::Job.title }
8
- job_level { FFaker::Company.position }
9
- department { FFaker::Education.school_name }
10
- date_of_employment { FFaker::Time.date }
11
- salary { [2000, 5500.5, 10_000, 20_000].sample }
12
- remark { FFaker::Lorem.sentence }
13
- mothers_name { FFaker::Name.name }
14
- education_level { FFaker::Education.degree }
15
- phone_number { FFaker::PhoneNumber.phone_number }
16
- place_of_birth { FFaker::Address.city }
17
- marital_status { %w[Single Married].sample }
18
- region { FFaker::Address.city }
19
- zone { FFaker::Address.neighborhood }
20
- wereda { [1, 2, 5, 13].sample }
21
- kebele { [1, 2, 5, 13].sample }
22
- passport_number { FFaker::Guid.guid }
23
- id_number { FFaker::Guid.guid }
24
- emergency_contact_name { FFaker::Name.name }
25
- emergency_contact_phone { FFaker::PhoneNumber.phone_number }
26
- relation_to_emergency_contact do
27
- %w[mother,father,brother,spouse].sample
28
- end
29
- created_at { FFaker::Time.datetime }
30
- updated_at { FFaker::Time.datetime }
31
- end
32
- end
@@ -1,11 +0,0 @@
1
- FactoryBot.define do
2
- factory :user, class: 'User' do
3
- first_name { FFaker::Name.first_name }
4
- middle_name { FFaker::Name.name }
5
- last_name { FFaker::Name.last_name }
6
- password { FFaker::Internet.password }
7
- email { FFaker::Internet.email }
8
- gender { %w[male,female].sample }
9
- date_of_birth { FFaker::Time.date }
10
- end
11
- end