sis_core 1.0.4 → 1.0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) 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 +15 -5
  6. data/app/models/sis/core/academic_year.rb +1 -1
  7. data/app/models/sis/core/applicant.rb +18 -1
  8. data/app/models/sis/core/application.rb +6 -3
  9. data/app/models/sis/core/application_document.rb +3 -1
  10. data/app/models/sis/core/application_module.rb +8 -0
  11. data/app/models/sis/core/application_setup.rb +18 -9
  12. data/app/models/sis/core/document_requirement.rb +4 -1
  13. data/app/models/sis/core/exam.rb +7 -1
  14. data/app/models/sis/core/exam_result.rb +7 -1
  15. data/app/models/sis/core/exam_setup.rb +12 -4
  16. data/app/models/sis/core/menu.rb +11 -0
  17. data/app/models/sis/core/programme_level.rb +1 -1
  18. data/app/models/sis/core/semester.rb +2 -0
  19. data/app/models/sis/core/user.rb +13 -0
  20. data/app/models/sis/core/user_role.rb +10 -0
  21. data/app/services/sis/core/user_service.rb +25 -0
  22. data/app/uploaders/sis/core/application_document_uploader.rb +51 -0
  23. data/app/uploaders/sis/core/photo_uploader.rb +51 -0
  24. data/config/routes.rb +6 -0
  25. data/db/migrate/20200106133937_create_sis_core_applicants.rb +17 -3
  26. data/db/migrate/20200107094449_create_sis_core_applications.rb +4 -6
  27. data/db/migrate/20200107101638_create_sis_core_application_documents.rb +1 -1
  28. data/db/migrate/20200507114003_create_sis_core_users.rb +17 -0
  29. data/db/migrate/20200511165121_create_sis_core_application_modules.rb +15 -0
  30. data/db/migrate/20200511165241_create_sis_core_user_roles.rb +15 -0
  31. data/db/migrate/20200511165450_create_sis_core_menus.rb +18 -0
  32. data/lib/authorize_request.rb +18 -0
  33. data/lib/json_web_token.rb +12 -0
  34. data/lib/sis/core/engine.rb +2 -0
  35. data/lib/sis/core/version.rb +1 -1
  36. data/lib/sis_core.rb +4 -2
  37. data/spec/factories/sis/core/academic_years.rb +1 -1
  38. data/spec/factories/sis/core/applicants.rb +11 -2
  39. data/spec/factories/sis/core/application_modules.rb +6 -0
  40. data/spec/factories/sis/core/applications.rb +1 -6
  41. data/spec/factories/sis/core/menus.rb +9 -0
  42. data/spec/factories/sis/core/programme_levels.rb +1 -1
  43. data/spec/factories/sis/core/user_roles.rb +6 -0
  44. data/spec/factories/sis/core/users.rb +9 -0
  45. metadata +87 -14
  46. data/app/models/sis/core/staff.rb +0 -21
  47. data/app/models/user.rb +0 -12
  48. data/config/initializers/devise_token_auth.rb +0 -55
  49. data/db/migrate/20200108092202_devise_token_auth_create_users.rb +0 -53
  50. data/db/migrate/20200316120805_create_sis_core_staffs.rb +0 -31
  51. data/db/migrate/20200319074334_modify_user.rb +0 -16
  52. data/spec/factories/sis/core/staffs.rb +0 -35
  53. data/spec/factories/users.rb +0 -11
@@ -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,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,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,35 +0,0 @@
1
- FactoryBot.define do
2
- factory :staff, class: 'Sis::Core::Staff' do
3
-
4
- end
5
- # SINGLE = 'Single'.freeze
6
- # MARRIED = 'Married'.freeze
7
- # MARITAL_STATUS = [SINGLE, MARRIED].freeze
8
- # factory :staff, class: 'Sis::Core::Staff' do
9
- # user
10
- # job_title { FFaker::Job.title }
11
- # job_level { FFaker::Company.position }
12
- # department { FFaker::Education.school_name }
13
- # date_of_employment { FFaker::Time.date }
14
- # salary { [2000, 5500.5, 10_000, 20_000].sample }
15
- # remark { FFaker::Lorem.sentence }
16
- # mothers_name { FFaker::Name.name }
17
- # education_level { FFaker::Education.degree }
18
- # phone_number { FFaker::PhoneNumber.phone_number }
19
- # place_of_birth { FFaker::Address.city }
20
- # marital_status { %w[Single Married].sample }
21
- # region { FFaker::Address.city }
22
- # zone { FFaker::Address.neighborhood }
23
- # wereda { [1, 2, 5, 13].sample }
24
- # kebele { [1, 2, 5, 13].sample }
25
- # passport_number { FFaker::Guid.guid }
26
- # id_number { FFaker::Guid.guid }
27
- # emergency_contact_name { FFaker::Name.name }
28
- # emergency_contact_phone { FFaker::PhoneNumber.phone_number }
29
- # relation_to_emergency_contact do
30
- # %w[mother,father,brother,spouse].sample
31
- # end
32
- # created_at { FFaker::Time.datetime }
33
- # updated_at { FFaker::Time.datetime }
34
- # end
35
- 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