dscf-core 0.3.1 → 0.3.3

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: '049d90d63eb4196e4b7d15ae1208485d7d09fe4a29a29ed920010b8ebcc6a312'
4
- data.tar.gz: 768e5835fd1172552db3548fd675b2a2a3a8b332c6e3bda211ec253f1e0c27e1
3
+ metadata.gz: 442564f7e8acce4f8eae9f074f58b03f8f026189660334c5c58cb2f67cce461c
4
+ data.tar.gz: 1c283579ec50ad95225bf1f6f9fd76d71decedf6387289ce99c314fefdae5d8f
5
5
  SHA512:
6
- metadata.gz: 3ed7b66f6f68b8d51dec4bf2d74561b7c8f2f793e7724bd9aa578c91b6f4f870fb6818afed28d2f1b3b4c84a23b2309f00a254c96896555c57763018624a9daf
7
- data.tar.gz: 26f208c4e989045dc55ad983034742a4768b4659602ef7b646f2e6c192ab26ce09ddb78a734884d7becb75eeb16d30ebe6e282a9396ae27e06c47fd2869c1c24
6
+ metadata.gz: 8d13fd5bb155bc6b292bcbe46c28e35d5e3be4b070cb95183b30cc7da0abaef0f955b000af3a2282138b5272f98a181569e45ae322c047e695cf229daba194ec
7
+ data.tar.gz: 56540f927754630b63a813a573e81f7c84cc2d94f462851536dc04b59cf6ecb1c85ee32e3156d43263e0de6256cd986dedc160d7d13da0f123cf8818a3b6df7e
@@ -8,7 +8,12 @@ module Dscf
8
8
 
9
9
  def login
10
10
  skip_authorization
11
- user = AuthService.authenticate_user(params[:email_or_phone], params[:password])
11
+ email_or_phone = params[:email_or_phone].presence || params.dig(:auth, :email_or_phone).presence
12
+ password = params[:password].presence || params.dig(:auth, :password).presence
13
+
14
+ return render_error("auth.errors.missing_credentials", status: :bad_request) unless email_or_phone && password
15
+
16
+ user = AuthService.authenticate_user(email_or_phone, password)
12
17
 
13
18
  if user&.valid_for_authentication?
14
19
  tokens = sign_in(user, request)
@@ -1,11 +1,24 @@
1
1
  module Dscf
2
2
  module Core
3
3
  class Address < ApplicationRecord
4
- belongs_to :user, class_name: "Dscf::Core::User"
4
+ belongs_to :user, class_name: "Dscf::Core::User", optional: true
5
+ belongs_to :supplier, class_name: "Dscf::Marketplace::Supplier", optional: true
5
6
 
6
- enum :address_type, {shipping: 0, residence: 1, current: 2, branch: 3}
7
+ enum :address_type, {
8
+ shipping: 0,
9
+ residence: 1,
10
+ current: 2,
11
+ branch: 3,
12
+ warehouse: 4,
13
+ business_hq: 5,
14
+ pickup_point: 6
15
+ }
7
16
 
8
17
  validates :country, presence: true
18
+
19
+ def self.ransackable_attributes(_auth_object = nil)
20
+ %w[id user_id supplier_id address_type country city sub_city woreda kebele house_numbers po_box created_at updated_at]
21
+ end
9
22
  end
10
23
  end
11
24
  end
@@ -20,7 +20,7 @@ module Dscf
20
20
 
21
21
  def self.ransackable_attributes(_auth_object = nil)
22
22
  %w[business_type_id contact_email contact_phone created_at description id id_value name tin_number
23
- updated_at user_id]
23
+ updated_at user_id is_system]
24
24
  end
25
25
 
26
26
  def self.ransackable_associations(_auth_object = nil)
@@ -1,7 +1,7 @@
1
1
  module Dscf
2
2
  module Core
3
3
  class BusinessSerializer < ActiveModel::Serializer
4
- attributes :id, :name, :description, :contact_email, :contact_phone, :tin_number, :created_at, :updated_at
4
+ attributes :id, :name, :description, :contact_email, :contact_phone, :tin_number, :created_at, :updated_at, :is_system
5
5
 
6
6
  belongs_to :user, serializer: Dscf::Core::UserSerializer
7
7
  belongs_to :business_type, serializer: Dscf::Core::BusinessTypeSerializer
@@ -2,15 +2,12 @@ module Dscf
2
2
  module Core
3
3
  class DocumentSerializer < ActiveModel::Serializer
4
4
  attributes :id, :document_type, :file_urls, :is_verified, :verified_at, :created_at, :updated_at
5
- include Rails.application.routes.url_helpers
6
5
 
7
6
  belongs_to :documentable, polymorphic: true
8
7
  belongs_to :verified_by, polymorphic: true, optional: true
9
8
 
10
9
  def file_urls
11
- return [] unless object.files.attached?
12
-
13
- object.files.map { |file| url_for(file) }
10
+ object.file_urls
14
11
  end
15
12
  end
16
13
  end
@@ -52,6 +52,8 @@ module Dscf
52
52
  private
53
53
 
54
54
  def find_user_by_email_or_phone(email_or_phone)
55
+ return nil if email_or_phone.blank?
56
+
55
57
  if email_or_phone.include?("@")
56
58
  User.find_by(email: email_or_phone)
57
59
  else
@@ -0,0 +1,5 @@
1
+ class AddIsSystemToDscfCoreBusinesses < ActiveRecord::Migration[8.0]
2
+ def change
3
+ add_column :dscf_core_businesses, :is_system, :boolean, null: false, default: false
4
+ end
5
+ end
@@ -1,5 +1,5 @@
1
1
  module Dscf
2
2
  module Core
3
- VERSION = "0.3.1".freeze
3
+ VERSION = "0.3.3".freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dscf-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.1
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Asrat
@@ -515,6 +515,7 @@ files:
515
515
  - db/migrate/20260128000000_create_dscf_core_file_attachments.rb
516
516
  - db/migrate/20260304000001_create_dscf_core_permissions.rb
517
517
  - db/migrate/20260304000002_create_dscf_core_role_permissions.rb
518
+ - db/migrate/20260501000001_add_is_system_to_dscf_core_businesses.rb
518
519
  - lib/dscf/core.rb
519
520
  - lib/dscf/core/engine.rb
520
521
  - lib/dscf/core/permission_registry.rb