dscf-core 0.2.4 → 0.2.5
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/dscf/core/businesses_controller.rb +83 -0
- data/app/models/dscf/core/document.rb +6 -5
- data/app/serializers/dscf/core/business_serializer.rb +1 -0
- data/app/serializers/dscf/core/document_serializer.rb +17 -0
- data/config/locales/en.yml +22 -0
- data/config/routes.rb +12 -0
- data/lib/dscf/core/version.rb +1 -1
- data/spec/factories/dscf/core/documents.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76a29d2a9907fa50b70a858a3e0a01824f2f6168b54733d5bb22428552add9d2
|
4
|
+
data.tar.gz: e6cc6b64f3eaa57d5b29bed770f9ddeec43d462dd2cd23fa3f4bc8cde97bb1ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23411e23576b4f5fb2a0a32a505b5d21025535b511e63430c1fac639e4a2e5f1417f99caf09a45d9a2c49917d4462faebacbbf17963db7b91daab7ec37cc8ad9
|
7
|
+
data.tar.gz: e368003213a383cb9afcacf105c33c0d1fadd2acb1dd08a3ccc3039d28140cadb328c67cc5637758de604b9b9753bb3f5e96bb0926a75eb6a2ba890b05011e98
|
@@ -0,0 +1,83 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Core
|
3
|
+
class BusinessesController < ApplicationController
|
4
|
+
include Dscf::Core::Common
|
5
|
+
include Dscf::Core::ReviewableController
|
6
|
+
|
7
|
+
def create
|
8
|
+
super do
|
9
|
+
business = @clazz.new(model_params)
|
10
|
+
business.user = current_user
|
11
|
+
business.reviews.build(
|
12
|
+
status: "pending",
|
13
|
+
context: "default"
|
14
|
+
)
|
15
|
+
|
16
|
+
if business.save && params[:business][:business_license].present?
|
17
|
+
document = business.documents.create!(
|
18
|
+
document_type: :business_license
|
19
|
+
)
|
20
|
+
document.files.attach(params[:business][:business_license])
|
21
|
+
document.save!
|
22
|
+
end
|
23
|
+
|
24
|
+
business
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def my_business
|
29
|
+
index do
|
30
|
+
current_user.businesses
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
# Enable authentication for this controller
|
37
|
+
def authentication_required?
|
38
|
+
true
|
39
|
+
end
|
40
|
+
|
41
|
+
def model_params
|
42
|
+
params.require(:business).permit(
|
43
|
+
:name,
|
44
|
+
:description,
|
45
|
+
:contact_email,
|
46
|
+
:contact_phone,
|
47
|
+
:tin_number,
|
48
|
+
:business_type_id,
|
49
|
+
business_license: :file
|
50
|
+
)
|
51
|
+
end
|
52
|
+
|
53
|
+
def eager_loaded_associations
|
54
|
+
[
|
55
|
+
:business_type, :user, :documents,
|
56
|
+
reviews: {reviewed_by: :user_profile}
|
57
|
+
]
|
58
|
+
end
|
59
|
+
|
60
|
+
def allowed_order_columns
|
61
|
+
%w[id name description contact_email contact_phone tin_number created_at updated_at]
|
62
|
+
end
|
63
|
+
|
64
|
+
def default_serializer_includes
|
65
|
+
{
|
66
|
+
index: [
|
67
|
+
:business_type, :user, :documents,
|
68
|
+
reviews: {reviewed_by: :user_profile}
|
69
|
+
],
|
70
|
+
show: [
|
71
|
+
:business_type, :user, :documents,
|
72
|
+
reviews: {reviewed_by: :user_profile}
|
73
|
+
],
|
74
|
+
create: %i[business_type user documents reviews],
|
75
|
+
update: [
|
76
|
+
:business_type, :user, :documents,
|
77
|
+
reviews: {reviewed_by: :user_profile}
|
78
|
+
]
|
79
|
+
}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
@@ -5,14 +5,15 @@ module Dscf
|
|
5
5
|
belongs_to :verified_by, polymorphic: true, optional: true
|
6
6
|
validates :document_type, presence: true
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
has_many_attached :files
|
10
9
|
enum :document_type, {business_license: 0, drivers_license: 1, claim: 2}
|
11
10
|
|
12
|
-
def
|
13
|
-
return
|
11
|
+
def file_urls
|
12
|
+
return [] unless files.attached?
|
14
13
|
|
15
|
-
|
14
|
+
files.map do |file|
|
15
|
+
Rails.application.routes.url_helpers.rails_blob_url(file, only_path: true)
|
16
|
+
end
|
16
17
|
end
|
17
18
|
end
|
18
19
|
end
|
@@ -6,6 +6,7 @@ module Dscf
|
|
6
6
|
belongs_to :user, serializer: Dscf::Core::UserSerializer
|
7
7
|
belongs_to :business_type, serializer: Dscf::Core::BusinessTypeSerializer
|
8
8
|
has_many :reviews, serializer: Dscf::Core::ReviewSerializer
|
9
|
+
has_many :documents, serializer: Dscf::Core::DocumentSerializer
|
9
10
|
end
|
10
11
|
end
|
11
12
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Core
|
3
|
+
class DocumentSerializer < ActiveModel::Serializer
|
4
|
+
attributes :id, :document_type, :file_urls, :is_verified, :verified_at, :created_at, :updated_at
|
5
|
+
include Rails.application.routes.url_helpers
|
6
|
+
|
7
|
+
belongs_to :documentable, polymorphic: true
|
8
|
+
belongs_to :verified_by, polymorphic: true, optional: true
|
9
|
+
|
10
|
+
def file_urls
|
11
|
+
return [] unless object.files.attached?
|
12
|
+
|
13
|
+
object.files.map { |file| url_for(file) }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/config/locales/en.yml
CHANGED
@@ -33,3 +33,25 @@ en:
|
|
33
33
|
show: "Failed to retrieve business type details"
|
34
34
|
create: "Failed to create business type"
|
35
35
|
update: "Failed to update business type"
|
36
|
+
|
37
|
+
business:
|
38
|
+
success:
|
39
|
+
index: "Businesses retrieved successfully"
|
40
|
+
show: "Business details retrieved successfully"
|
41
|
+
create: "Business created successfully"
|
42
|
+
update: "Business updated successfully"
|
43
|
+
approve: "Business approved successfully"
|
44
|
+
reject: "Business rejected successfully"
|
45
|
+
request_modification: "Business modification requested successfully"
|
46
|
+
resubmit: "Business resubmitted successfully"
|
47
|
+
my_business: "Businesses retrieved successfully"
|
48
|
+
errors:
|
49
|
+
index: "Failed to retrieve businesses"
|
50
|
+
show: "Business not found"
|
51
|
+
create: "Failed to create business"
|
52
|
+
update: "Failed to update business"
|
53
|
+
approve: "Failed to approve business"
|
54
|
+
reject: "Failed to reject business"
|
55
|
+
request_modification: "Failed to request modification for business"
|
56
|
+
resubmit: "Failed to resubmit business"
|
57
|
+
my_business: "Failed to retrieve businesses"
|
data/config/routes.rb
CHANGED
@@ -1,4 +1,16 @@
|
|
1
1
|
Dscf::Core::Engine.routes.draw do
|
2
|
+
resources :businesses do
|
3
|
+
collection do
|
4
|
+
get "my_business"
|
5
|
+
end
|
6
|
+
member do
|
7
|
+
patch "approve"
|
8
|
+
patch "reject"
|
9
|
+
patch "request_modification"
|
10
|
+
patch "resubmit"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
2
14
|
post "auth/login", to: "auth#login"
|
3
15
|
post "auth/logout", to: "auth#logout"
|
4
16
|
post "auth/signup", to: "auth#signup"
|
data/lib/dscf/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dscf-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Asrat
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-10-
|
10
|
+
date: 2025-10-13 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: rails
|
@@ -436,6 +436,7 @@ files:
|
|
436
436
|
- app/controllers/dscf/core/application_controller.rb
|
437
437
|
- app/controllers/dscf/core/auth_controller.rb
|
438
438
|
- app/controllers/dscf/core/business_types_controller.rb
|
439
|
+
- app/controllers/dscf/core/businesses_controller.rb
|
439
440
|
- app/errors/dscf/core/authentication_error.rb
|
440
441
|
- app/jobs/dscf/core/application_job.rb
|
441
442
|
- app/mailers/dscf/core/application_mailer.rb
|
@@ -455,6 +456,7 @@ files:
|
|
455
456
|
- app/serializers/dscf/core/address_serializer.rb
|
456
457
|
- app/serializers/dscf/core/business_serializer.rb
|
457
458
|
- app/serializers/dscf/core/business_type_serializer.rb
|
459
|
+
- app/serializers/dscf/core/document_serializer.rb
|
458
460
|
- app/serializers/dscf/core/review_serializer.rb
|
459
461
|
- app/serializers/dscf/core/role_serializer.rb
|
460
462
|
- app/serializers/dscf/core/user_auth_serializer.rb
|