cats_core 1.1.18 → 1.1.19

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eced600b25c5d8bf5d8a0b55ba7a5d116879c5ee3f346f9e5128144066c14d8c
4
- data.tar.gz: e88b60c25cd88cba88f0cce8ca83fe4acf6873b99b757c791a9806f3b22569c4
3
+ metadata.gz: 4ac17edba232672ae0f11dc2042dbb8c58f7a3bbe6f5f032e3407a23292b1db8
4
+ data.tar.gz: d35a4ea6ab6e34d1a3ea13b784056916a22dc60d9da2ab9e015d34863dd7173d
5
5
  SHA512:
6
- metadata.gz: fb400975341e0ee1361e41f9cf93fdd1473af06f0bed0f06d75d36b0622766556110b3a3f75ab8b283776ff2c23a3263b5d493dd0035b27b965d2c31141eca78
7
- data.tar.gz: edc3f5744ff0f9b4dde1f0b8d07649927b720540004fc891e357bcba30c9561963e4f3ece3238707496f23eb1fdf0d141fad44adbcf5c4ede25a59129c3e8717
6
+ metadata.gz: c46e405c2735c8a73c814c71429c2bfeebf2a39f8130aa574e750f996006722fed3bc7a90508fab437359c9530f50578060b3c619b5cc2a029f617515df92529
7
+ data.tar.gz: c53c84bc2f39768f72eaeab44bcee50e70d621028a72bace55aa263a618b4eaf69249ca5969defad1060bbe5428bb1d60ae15926de4028eabed76a4b7a7d8ad8
@@ -1,6 +1,8 @@
1
1
  module Cats
2
2
  module Core
3
3
  class RolesController < ApplicationController
4
+ include Common
5
+
4
6
  before_action :set_role, only: [:users]
5
7
 
6
8
  def users
@@ -13,6 +15,10 @@ module Cats
13
15
  def set_role
14
16
  @role = Role.find_by(name: params[:name])
15
17
  end
18
+
19
+ def model_params
20
+ params.require(:payload).permit(:name, :application_module_id)
21
+ end
16
22
  end
17
23
  end
18
24
  end
@@ -1,7 +1,26 @@
1
1
  module Cats
2
2
  module Core
3
3
  class UsersController < ApplicationController
4
- before_action :set_user, only: %i[stores warehouse hub]
4
+ include Common
5
+
6
+ before_action :set_user, only: %i[roles assign_role stores warehouse hub]
7
+
8
+ def index
9
+ users = Cats::Core::User.where(application_module_id: params[:id])
10
+ render json: { success: true, data: serialize(users) }
11
+ end
12
+
13
+ def roles
14
+ data = ActiveModelSerializers::SerializableResource.new(@user.roles)
15
+ render json: { success: true, data: data }
16
+ end
17
+
18
+ def assign_role
19
+ role = Cats::Core::Role.find(params[:role_id])
20
+ @user.roles << role
21
+ data = ActiveModelSerializers::SerializableResource.new(@user)
22
+ render json: { success: true, data: data }
23
+ end
5
24
 
6
25
  def stores
7
26
  data = ActiveModelSerializers::SerializableResource.new(@user.stores)
@@ -21,7 +40,14 @@ module Cats
21
40
  private
22
41
 
23
42
  def set_user
24
- @user = User.find(params[:id])
43
+ @user = Cats::Core::User.find(params[:id])
44
+ end
45
+
46
+ def model_params
47
+ params.require(:payload).permit(
48
+ :first_name, :last_name, :email, :phone_number, :active, :password, :password_confirmation, :details,
49
+ :application_module_id
50
+ )
25
51
  end
26
52
  end
27
53
  end
@@ -0,0 +1,3 @@
1
+ class RoleSerializer < ActiveModel::Serializer
2
+ attributes :id, :name, :application_module_id
3
+ end
@@ -0,0 +1,3 @@
1
+ class UserSerializer < ActiveModel::Serializer
2
+ attributes :id, :first_name, :last_name, :email, :phone_number, :active, :details, :application_module_id
3
+ end
data/config/routes.rb CHANGED
@@ -5,6 +5,8 @@ Cats::Core::Engine.routes.draw do
5
5
  get '/notifications/unread', controller: :notifications, action: :unread
6
6
  get '/notifications/read', controller: :notifications, action: :read
7
7
 
8
+ get '/application_modules/:id/users', controller: :users, action: :index, as: :application_users
9
+
8
10
  resources :menus, only: [:index]
9
11
  resources :notifications, only: [:index] do
10
12
  member do
@@ -12,6 +14,8 @@ Cats::Core::Engine.routes.draw do
12
14
  post 'mark_as_unread', controller: :notifications, action: :mark_as_unread
13
15
  end
14
16
  end
17
+
18
+ get '/roles/:id/', controller: :roles, action: :show
15
19
  resources :roles, param: :name do
16
20
  member do
17
21
  get 'users', controller: :roles, action: :users
@@ -19,9 +23,11 @@ Cats::Core::Engine.routes.draw do
19
23
  end
20
24
  resources :users do
21
25
  member do
26
+ get 'roles'
22
27
  get 'stores', controller: :users, action: :stores
23
28
  get 'warehouse', controller: :users, action: :warehouse
24
29
  get 'hub', controller: :users, action: :hub
30
+ post 'assign_role'
25
31
  end
26
32
  end
27
33
 
@@ -1,5 +1,5 @@
1
1
  module Cats
2
2
  module Core
3
- VERSION = '1.1.18'.freeze
3
+ VERSION = '1.1.19'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cats_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.18
4
+ version: 1.1.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henock L.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-02 00:00:00.000000000 Z
11
+ date: 2021-10-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -297,7 +297,9 @@ files:
297
297
  - app/serializers/cats/core/receipt_serializer.rb
298
298
  - app/serializers/cats/core/receipt_transaction_serializer.rb
299
299
  - app/serializers/cats/core/role_menu_serializer.rb
300
+ - app/serializers/cats/core/role_serializer.rb
300
301
  - app/serializers/cats/core/unit_of_measure_serializer.rb
302
+ - app/serializers/cats/core/user_serializer.rb
301
303
  - app/services/cats/core/dispatch_service.rb
302
304
  - app/services/cats/core/menu_service.rb
303
305
  - app/services/cats/core/notification_service.rb