comee_core 0.2.52 → 0.2.53
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/comee/core/access_controller.rb +6 -1
- data/app/controllers/comee/core/application_controller.rb +14 -0
- data/app/controllers/comee/core/notifications_controller.rb +17 -0
- data/app/controllers/comee/core/sales_order_items_controller.rb +15 -0
- data/app/controllers/comee/core/users_controller.rb +1 -1
- data/app/mailers/comee/core/notification_mailer.rb +5 -3
- data/app/models/comee/core/application_module.rb +8 -0
- data/app/models/comee/core/role.rb +10 -0
- data/app/models/comee/core/user.rb +15 -2
- data/app/models/comee/core/user_application_role.rb +9 -0
- data/app/serializers/comee/core/purchase_order_item_serializer.rb +9 -0
- data/app/serializers/comee/core/sales_order_item_detail_serializer.rb +10 -0
- data/app/serializers/comee/core/shipment_item_serializer.rb +1 -0
- data/app/serializers/comee/core/user_serializer.rb +1 -1
- data/config/routes.rb +1 -0
- data/db/migrate/20230411123525_create_comee_core_application_modules.rb +10 -0
- data/db/migrate/20230411132211_create_comee_core_roles.rb +14 -0
- data/db/migrate/{20230728014330_create_comee_core_users.rb → 20230428014330_create_comee_core_users.rb} +0 -1
- data/db/migrate/20230428140341_create_comee_core_user_application_roles.rb +20 -0
- data/lib/comee/core/version.rb +1 -1
- data/spec/factories/comee/core/application_modules.rb +6 -0
- data/spec/factories/comee/core/roles.rb +7 -0
- data/spec/factories/comee/core/user_application_roles.rb +7 -0
- data/spec/factories/comee/core/users.rb +0 -1
- metadata +14 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cbd504feaf226234a948351b3f05dc7e4bebedbb77943f990c909b49c522b35e
|
4
|
+
data.tar.gz: 16479be863225ad791359456c2aeb019a71304b40478fc5fb478a4309600be95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d7dc57f1d6b2d96de96a0f81dcffeddfd89b0b311f71adb88acc5b66a4f8a0d0e2031a2af3ea21f23b4133c75c19a9d4ea3943e62d14a8ceea0093a1a8a88f2
|
7
|
+
data.tar.gz: 7455743f13220ab7add40bb70450fbd73c588c37f9caeebde3a89e90548cb2e4b574ef38a0a664f3a9605d030447260020d7d555c8f716df05dea12a1d69eb68
|
@@ -6,12 +6,17 @@ module Comee
|
|
6
6
|
def login
|
7
7
|
user = User.find_by(email: auth_params[:email])
|
8
8
|
if user
|
9
|
+
unless user.application_roles?(current_application)
|
10
|
+
render(json: {error: "User does not have access to this application."}, status: 400) and return
|
11
|
+
end
|
12
|
+
|
13
|
+
roles = user.application_roles(current_application).map(&:code)
|
9
14
|
if user.authenticate(auth_params[:password])
|
10
15
|
payload = {
|
11
16
|
id: user.id,
|
12
17
|
name: user.name,
|
13
18
|
email: user.email,
|
14
|
-
|
19
|
+
roles: roles
|
15
20
|
}
|
16
21
|
jwt = TokenService.issue(payload)
|
17
22
|
render json: {token: jwt, user: payload}
|
@@ -29,6 +29,20 @@ module Comee
|
|
29
29
|
@current_user ||= user
|
30
30
|
end
|
31
31
|
|
32
|
+
def application_code
|
33
|
+
code = Rails.application.config.application_code
|
34
|
+
raise(StandardError, "Code is not set for the current application.") unless code
|
35
|
+
|
36
|
+
code
|
37
|
+
end
|
38
|
+
|
39
|
+
def current_application
|
40
|
+
app_code = application_code
|
41
|
+
return ApplicationModule.find_by(code: app_code) if app_code
|
42
|
+
|
43
|
+
nil
|
44
|
+
end
|
45
|
+
|
32
46
|
def authenticate
|
33
47
|
render json: {error: "Unauthorized"}, status: 401 if current_user.nil?
|
34
48
|
end
|
@@ -28,11 +28,28 @@ module Comee
|
|
28
28
|
render json: {success: true, data: @notification.message}
|
29
29
|
end
|
30
30
|
|
31
|
+
def notify
|
32
|
+
NotificationMailer.with(
|
33
|
+
user: current_user,
|
34
|
+
recipients: notify_params[:recipients],
|
35
|
+
subject: notify_params[:subject],
|
36
|
+
email_body: notify_params[:body],
|
37
|
+
files: notify_params[:files]
|
38
|
+
).notify.deliver_now
|
39
|
+
render json: {success: true}
|
40
|
+
rescue StandardError => e
|
41
|
+
render_error(e)
|
42
|
+
end
|
43
|
+
|
31
44
|
private
|
32
45
|
|
33
46
|
def set_notification
|
34
47
|
@notification = Notification.find(params[:id])
|
35
48
|
end
|
49
|
+
|
50
|
+
def notify_params
|
51
|
+
params.require(:payload).permit(:subject, :body, recipients: [], files: {filename: :file})
|
52
|
+
end
|
36
53
|
end
|
37
54
|
end
|
38
55
|
end
|
@@ -15,6 +15,21 @@ module Comee
|
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
18
|
+
def shipment_details
|
19
|
+
details = SalesOrderItem.includes(shipment_items: :item_statuses, purchase_order_item: :purchase_order)
|
20
|
+
.find(params[:id])
|
21
|
+
data = ActiveModelSerializers::SerializableResource.new(
|
22
|
+
details,
|
23
|
+
{
|
24
|
+
serializer: SalesOrderItemDetailSerializer,
|
25
|
+
include: ["shipment_items.item_statuses", "purchase_order_item.purchase_order"]
|
26
|
+
}
|
27
|
+
)
|
28
|
+
render json: {success: true, data: data}
|
29
|
+
|
30
|
+
# render_content(details, fields: ["shipment_items.item_statuses", "purchase_order_items.purchase_order"])
|
31
|
+
end
|
32
|
+
|
18
33
|
def suggest_values
|
19
34
|
service = CustomerOrderService.new
|
20
35
|
result = service.suggest_values(params[:id], suggest_params[:unit_id])
|
@@ -3,15 +3,17 @@ module Comee
|
|
3
3
|
class NotificationMailer < ApplicationMailer
|
4
4
|
def notify
|
5
5
|
user = params[:user]
|
6
|
+
files = params[:files]
|
7
|
+
files&.each { |k, v| attachments[k] = v }
|
6
8
|
|
7
9
|
mail(
|
8
10
|
from: email_address_with_name(user.email, user.name),
|
9
11
|
to: params[:recipients],
|
10
12
|
subject: params[:subject],
|
11
|
-
body: params[:email_body],
|
12
|
-
content_type: "text/html",
|
13
13
|
delivery_method_options: user.delivery_options
|
14
|
-
)
|
14
|
+
) do |format|
|
15
|
+
format.html { render(html: params[:email_body].html_safe) }
|
16
|
+
end
|
15
17
|
end
|
16
18
|
end
|
17
19
|
end
|
@@ -1,13 +1,14 @@
|
|
1
1
|
module Comee
|
2
2
|
module Core
|
3
3
|
class User < ApplicationRecord
|
4
|
-
enum :user_type, {supplier: 0, admin: 1, client: 2, clerk: 3, order_manager: 4}
|
5
4
|
has_one :email_setting
|
6
5
|
|
7
6
|
has_secure_password
|
8
7
|
has_many :notifications, as: :recipient, dependent: :destroy
|
8
|
+
has_many :user_application_roles
|
9
|
+
has_many :roles, through: :user_application_roles
|
9
10
|
|
10
|
-
validates :name, :email,
|
11
|
+
validates :name, :email, presence: true
|
11
12
|
validates :email, uniqueness: true
|
12
13
|
|
13
14
|
def delivery_options
|
@@ -23,6 +24,18 @@ module Comee
|
|
23
24
|
read_timeout: setting.read_timeout
|
24
25
|
}
|
25
26
|
end
|
27
|
+
|
28
|
+
def application_roles?(application)
|
29
|
+
roles.references(:user_application_roles)
|
30
|
+
.where(comee_core_user_application_roles: {application_module_id: application.id})
|
31
|
+
.count
|
32
|
+
.positive?
|
33
|
+
end
|
34
|
+
|
35
|
+
def application_roles(application)
|
36
|
+
roles.references(:user_application_roles)
|
37
|
+
.where(comee_core_user_application_roles: {application_module_id: application.id})
|
38
|
+
end
|
26
39
|
end
|
27
40
|
end
|
28
41
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
module Comee
|
2
|
+
module Core
|
3
|
+
class SalesOrderItemDetailSerializer < ActiveModel::Serializer
|
4
|
+
attributes :id, :customer_item_no, :customer_item_description, :quantity, :quantity_delivered, :quantity_canceled
|
5
|
+
|
6
|
+
has_many :shipment_items
|
7
|
+
belongs_to :purchase_order_item
|
8
|
+
end
|
9
|
+
end
|
10
|
+
end
|
data/config/routes.rb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
class CreateComeeCoreRoles < ActiveRecord::Migration[7.1]
|
2
|
+
def change
|
3
|
+
create_table :comee_core_roles do |t|
|
4
|
+
t.string :code
|
5
|
+
t.string :name
|
6
|
+
t.references :application_module,
|
7
|
+
null: false,
|
8
|
+
index: {name: "am_on_ccr_indx"},
|
9
|
+
foreign_key: {to_table: :comee_core_application_modules}
|
10
|
+
|
11
|
+
t.timestamps
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class CreateComeeCoreUserApplicationRoles < ActiveRecord::Migration[7.1]
|
2
|
+
def change
|
3
|
+
create_table :comee_core_user_application_roles do |t|
|
4
|
+
t.references :user,
|
5
|
+
index: {name: "user_on_ccuar_indx"},
|
6
|
+
null: false,
|
7
|
+
foreign_key: {to_table: :comee_core_users}
|
8
|
+
t.references :application_module,
|
9
|
+
index: {name: "am_on_ccuar_indx"},
|
10
|
+
null: false,
|
11
|
+
foreign_key: {to_table: :comee_core_application_modules}
|
12
|
+
t.references :role,
|
13
|
+
null: false,
|
14
|
+
index: {name: "role_on_ccuar_indx"},
|
15
|
+
foreign_key: {to_table: :comee_core_roles}
|
16
|
+
|
17
|
+
t.timestamps
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/comee/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: comee_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.53
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Henock L.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-04-
|
11
|
+
date: 2024-04-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: active_model_serializers
|
@@ -300,6 +300,7 @@ files:
|
|
300
300
|
- app/mailers/comee/core/supplier_mailer.rb
|
301
301
|
- app/models/comee/core/additional_item.rb
|
302
302
|
- app/models/comee/core/agent.rb
|
303
|
+
- app/models/comee/core/application_module.rb
|
303
304
|
- app/models/comee/core/application_record.rb
|
304
305
|
- app/models/comee/core/back_order.rb
|
305
306
|
- app/models/comee/core/back_order_item.rb
|
@@ -340,6 +341,7 @@ files:
|
|
340
341
|
- app/models/comee/core/purchase_requisition_item.rb
|
341
342
|
- app/models/comee/core/quotation_request.rb
|
342
343
|
- app/models/comee/core/quotation_request_item.rb
|
344
|
+
- app/models/comee/core/role.rb
|
343
345
|
- app/models/comee/core/sales_order.rb
|
344
346
|
- app/models/comee/core/sales_order_item.rb
|
345
347
|
- app/models/comee/core/shipment_instruction.rb
|
@@ -353,6 +355,7 @@ files:
|
|
353
355
|
- app/models/comee/core/unit.rb
|
354
356
|
- app/models/comee/core/unit_conversion.rb
|
355
357
|
- app/models/comee/core/user.rb
|
358
|
+
- app/models/comee/core/user_application_role.rb
|
356
359
|
- app/notifications/comee/core/back_order_notification.rb
|
357
360
|
- app/serializers/comee/core/agent_serializer.rb
|
358
361
|
- app/serializers/comee/core/client_price_serializer.rb
|
@@ -371,8 +374,10 @@ files:
|
|
371
374
|
- app/serializers/comee/core/product_lookup_serializer.rb
|
372
375
|
- app/serializers/comee/core/product_serializer.rb
|
373
376
|
- app/serializers/comee/core/product_type_serializer.rb
|
377
|
+
- app/serializers/comee/core/purchase_order_item_serializer.rb
|
374
378
|
- app/serializers/comee/core/quotation_request_item_serializer.rb
|
375
379
|
- app/serializers/comee/core/quotation_request_serializer.rb
|
380
|
+
- app/serializers/comee/core/sales_order_item_detail_serializer.rb
|
376
381
|
- app/serializers/comee/core/sales_order_item_serializer.rb
|
377
382
|
- app/serializers/comee/core/sales_order_serializer.rb
|
378
383
|
- app/serializers/comee/core/shipment_item_serializer.rb
|
@@ -394,11 +399,14 @@ files:
|
|
394
399
|
- config/locales/en.yml
|
395
400
|
- config/routes.rb
|
396
401
|
- config/spring.rb
|
402
|
+
- db/migrate/20230411123525_create_comee_core_application_modules.rb
|
403
|
+
- db/migrate/20230411132211_create_comee_core_roles.rb
|
404
|
+
- db/migrate/20230428014330_create_comee_core_users.rb
|
405
|
+
- db/migrate/20230428140341_create_comee_core_user_application_roles.rb
|
397
406
|
- db/migrate/20230727091518_create_comee_core_fulfillment_centers.rb
|
398
407
|
- db/migrate/20230727153013_create_comee_core_units.rb
|
399
408
|
- db/migrate/20230728011037_create_comee_core_currencies.rb
|
400
409
|
- db/migrate/20230728014322_create_comee_core_products.rb
|
401
|
-
- db/migrate/20230728014330_create_comee_core_users.rb
|
402
410
|
- db/migrate/20230728122618_create_comee_core_suppliers.rb
|
403
411
|
- db/migrate/20230728123039_create_comee_core_clients.rb
|
404
412
|
- db/migrate/20230728123458_create_comee_core_agents.rb
|
@@ -455,6 +463,7 @@ files:
|
|
455
463
|
- lib/tasks/comee_core_tasks.rake
|
456
464
|
- spec/factories/comee/core/additional_items.rb
|
457
465
|
- spec/factories/comee/core/agents.rb
|
466
|
+
- spec/factories/comee/core/application_modules.rb
|
458
467
|
- spec/factories/comee/core/back_order_items.rb
|
459
468
|
- spec/factories/comee/core/back_orders.rb
|
460
469
|
- spec/factories/comee/core/client_orders.rb
|
@@ -493,6 +502,7 @@ files:
|
|
493
502
|
- spec/factories/comee/core/purchase_requisitions.rb
|
494
503
|
- spec/factories/comee/core/quotation_request_items.rb
|
495
504
|
- spec/factories/comee/core/quotation_requests.rb
|
505
|
+
- spec/factories/comee/core/roles.rb
|
496
506
|
- spec/factories/comee/core/sales_order_items.rb
|
497
507
|
- spec/factories/comee/core/sales_orders.rb
|
498
508
|
- spec/factories/comee/core/shipment_instruction_items.rb
|
@@ -505,6 +515,7 @@ files:
|
|
505
515
|
- spec/factories/comee/core/transport_availabilities.rb
|
506
516
|
- spec/factories/comee/core/unit_conversions.rb
|
507
517
|
- spec/factories/comee/core/units.rb
|
518
|
+
- spec/factories/comee/core/user_application_roles.rb
|
508
519
|
- spec/factories/comee/core/users.rb
|
509
520
|
homepage: https://www.mks.com
|
510
521
|
licenses:
|