cats_core 1.1.13 → 1.1.14
Sign up to get free protection for your applications and to get access to all the features.
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
|
|
@@ -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,
|
data/lib/cats/core/version.rb
CHANGED