cats_core 1.1.10 → 1.1.14
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 +4 -4
- data/app/controllers/cats/core/users_controller.rb +8 -3
- data/app/models/cats/core/allocation.rb +1 -0
- data/app/models/cats/core/notification_rule.rb +8 -0
- data/app/models/cats/core/rhn_request.rb +2 -1
- data/app/models/cats/core/user.rb +9 -3
- data/config/routes.rb +2 -1
- data/db/migrate/20210715114910_create_cats_core_users.rb +1 -1
- data/db/migrate/20210718042755_create_cats_core_rhn_requests.rb +1 -0
- data/db/migrate/20211002050739_create_cats_core_notification_rules.rb +10 -0
- data/lib/cats/core/version.rb +1 -1
- data/spec/factories/cats/core/notification_rules.rb +6 -0
- data/spec/factories/cats/core/rhn_requests.rb +1 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 849c78b04184a39a42337994d2cf68e4be874dff4e0420e34a890ce0584658cd
|
4
|
+
data.tar.gz: 85b1a1ff55a91d353329eaebb38e5ff19bb2590bfa8ab2942dd5feb31a7b11c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18cb896b37d1c7449e8955e7209bcf663e02b0e43d42fe0c7137f9f8a0e4be5ed1f664d8bc2b2f4e777e15b6f8b6c8efb57114cdb283cdffbc8f51dff6c75d7a
|
7
|
+
data.tar.gz: e477156c701bee3b6dfb5c337fb344bcb1e86d16978e0208e8a9616a7721af364ff63862045f85db2ac825dd8fc876b0198ec87f857a4844064cdf7336a8a315
|
@@ -1,15 +1,20 @@
|
|
1
1
|
module Cats
|
2
2
|
module Core
|
3
3
|
class UsersController < ApplicationController
|
4
|
-
before_action :set_user, only: %i[stores
|
4
|
+
before_action :set_user, only: %i[stores warehouse hub]
|
5
5
|
|
6
6
|
def stores
|
7
7
|
data = ActiveModelSerializers::SerializableResource.new(@user.stores)
|
8
8
|
render json: { success: true, data: data }
|
9
9
|
end
|
10
10
|
|
11
|
-
def
|
12
|
-
data = ActiveModelSerializers::SerializableResource.new(@user.
|
11
|
+
def warehouse
|
12
|
+
data = ActiveModelSerializers::SerializableResource.new(@user.warehouse)
|
13
|
+
render json: { success: true, data: data }
|
14
|
+
end
|
15
|
+
|
16
|
+
def hub
|
17
|
+
data = ActiveModelSerializers::SerializableResource.new(@user.hub)
|
13
18
|
render json: { success: true, data: data }
|
14
19
|
end
|
15
20
|
|
@@ -8,6 +8,7 @@ module Cats
|
|
8
8
|
belongs_to :rhn_request, optional: true
|
9
9
|
belongs_to :commodity
|
10
10
|
belongs_to :source, class_name: 'Cats::Core::Location'
|
11
|
+
has_many :allocation_items
|
11
12
|
|
12
13
|
validates :commodity_status, :allocation_status, presence: true
|
13
14
|
validates :reference_no, presence: true, uniqueness: true
|
@@ -3,8 +3,9 @@ module Cats
|
|
3
3
|
class RhnRequest < ApplicationRecord
|
4
4
|
belongs_to :commodity
|
5
5
|
|
6
|
-
validates :reference_no, :request_date, presence: true
|
6
|
+
validates :reference_no, :request_date, :quantity, presence: true
|
7
7
|
validates :reference_no, uniqueness: true
|
8
|
+
validates :quantity, numericality: { greater_than: 0 }
|
8
9
|
|
9
10
|
delegate(:batch_no, to: :commodity, prefix: true)
|
10
11
|
end
|
@@ -13,10 +13,10 @@ module Cats
|
|
13
13
|
validates :email, uniqueness: true, format: { with: URI::MailTo::EMAIL_REGEXP }
|
14
14
|
validate :validate_phone_number
|
15
15
|
|
16
|
-
def
|
17
|
-
return unless details.key?('
|
16
|
+
def warehouse
|
17
|
+
return unless details.key?('warehouse')
|
18
18
|
|
19
|
-
Cats::Core::Location.
|
19
|
+
Cats::Core::Location.find_by(id: details['warehouse'], location_type: Cats::Core::Location::WAREHOUSE)
|
20
20
|
end
|
21
21
|
|
22
22
|
def stores
|
@@ -25,6 +25,12 @@ module Cats
|
|
25
25
|
Cats::Core::Store.where(id: details['stores'])
|
26
26
|
end
|
27
27
|
|
28
|
+
def hub
|
29
|
+
return unless details.key?('hub')
|
30
|
+
|
31
|
+
Cats::Core::Location.find_by(id: details['hub'], location_type: Cats::Core::Location::HUB)
|
32
|
+
end
|
33
|
+
|
28
34
|
def validate_phone_number
|
29
35
|
return unless phone_number.present?
|
30
36
|
|
data/config/routes.rb
CHANGED
@@ -20,7 +20,8 @@ Cats::Core::Engine.routes.draw do
|
|
20
20
|
resources :users do
|
21
21
|
member do
|
22
22
|
get 'stores', controller: :users, action: :stores
|
23
|
-
get '
|
23
|
+
get 'warehouse', controller: :users, action: :warehouse
|
24
|
+
get 'hub', controller: :users, action: :hub
|
24
25
|
end
|
25
26
|
end
|
26
27
|
|
@@ -6,7 +6,7 @@ class CreateCatsCoreUsers < ActiveRecord::Migration[6.1]
|
|
6
6
|
t.string :email, unique: true
|
7
7
|
t.boolean :active, null: false, default: true
|
8
8
|
t.string :password_digest
|
9
|
-
t.jsonb :details
|
9
|
+
t.jsonb :details, null: false, default: {}
|
10
10
|
t.string :phone_number
|
11
11
|
t.references :application_module,
|
12
12
|
null: false,
|
@@ -6,6 +6,7 @@ class CreateCatsCoreRhnRequests < ActiveRecord::Migration[6.1]
|
|
6
6
|
null: false,
|
7
7
|
index: { name: 'commodity_on_rhn_indx' },
|
8
8
|
foreign_key: { to_table: :cats_core_commodities }
|
9
|
+
t.float :quantity, null: false
|
9
10
|
t.date :request_date, null: false
|
10
11
|
t.string :requested_by
|
11
12
|
|
data/lib/cats/core/version.rb
CHANGED
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.
|
4
|
+
version: 1.1.14
|
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-
|
11
|
+
date: 2021-10-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -266,6 +266,7 @@ files:
|
|
266
266
|
- app/models/cats/core/menu.rb
|
267
267
|
- app/models/cats/core/menu_item.rb
|
268
268
|
- app/models/cats/core/notification.rb
|
269
|
+
- app/models/cats/core/notification_rule.rb
|
269
270
|
- app/models/cats/core/operator.rb
|
270
271
|
- app/models/cats/core/program.rb
|
271
272
|
- app/models/cats/core/purchase_order.rb
|
@@ -339,6 +340,7 @@ files:
|
|
339
340
|
- db/migrate/20210727074646_create_cats_core_receipts.rb
|
340
341
|
- db/migrate/20210814160628_create_cats_core_receipt_transactions.rb
|
341
342
|
- db/migrate/20210814175406_create_cats_core_stack_transactions.rb
|
343
|
+
- db/migrate/20211002050739_create_cats_core_notification_rules.rb
|
342
344
|
- lib/cats/core.rb
|
343
345
|
- lib/cats/core/engine.rb
|
344
346
|
- lib/cats/core/version.rb
|
@@ -361,6 +363,7 @@ files:
|
|
361
363
|
- spec/factories/cats/core/locations.rb
|
362
364
|
- spec/factories/cats/core/menu_items.rb
|
363
365
|
- spec/factories/cats/core/menus.rb
|
366
|
+
- spec/factories/cats/core/notification_rules.rb
|
364
367
|
- spec/factories/cats/core/notifications.rb
|
365
368
|
- spec/factories/cats/core/operators.rb
|
366
369
|
- spec/factories/cats/core/programs.rb
|