dscf-credit 0.4.57 → 0.4.58
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/policies/dscf/credit/facilitator_application_policy.rb +25 -1
- data/db/seeds.rb +12 -3
- data/lib/dscf/credit/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b1b21359760cd3729a9b735611064dbfb6f880521893f133d98dbca7687f1c48
|
|
4
|
+
data.tar.gz: b326a4e108b2b12ea342929cfb3debe9b2f90ec65856112923055dbd7722bdd2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d58b21750e49bd68bdb8d16cb852d50ba39a3973160c88fb1df2ef552112a3c8f8ee7c8552cb9bb985001eb32d088139babf9814110c71d2d1b7f3a0f6d4d7ff
|
|
7
|
+
data.tar.gz: a8151e9ea4a5e2fcd6dd8aa0da19b7ddf37710e2feefce24f7bf805b0ce798c82f3fef3ce833843a7e3e2351af716e1dc6ca81a4824978f4b86ca1000fb91f9b
|
|
@@ -1,7 +1,31 @@
|
|
|
1
1
|
module Dscf
|
|
2
2
|
module Credit
|
|
3
3
|
class FacilitatorApplicationPolicy < ApplicationPolicy
|
|
4
|
-
|
|
4
|
+
class Scope < ApplicationPolicy::Scope
|
|
5
|
+
def resolve
|
|
6
|
+
return scope.none unless user.has_permission?(index_permission_code)
|
|
7
|
+
return scope.all if user.super_admin?
|
|
8
|
+
return scope.all if admin_role?
|
|
9
|
+
|
|
10
|
+
if user.has_role?("USER") || user.has_role?("FACILITATOR")
|
|
11
|
+
scope.where(user_id: user.id)
|
|
12
|
+
else
|
|
13
|
+
scope.none
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def bulk_create?
|
|
19
|
+
user.has_permission?("facilitator_applications.bulk_create")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def owned_record?
|
|
23
|
+
if user.has_role?("USER") || user.has_role?("FACILITATOR")
|
|
24
|
+
record.user_id == user.id
|
|
25
|
+
else
|
|
26
|
+
true
|
|
27
|
+
end
|
|
28
|
+
end
|
|
5
29
|
end
|
|
6
30
|
end
|
|
7
31
|
end
|
data/db/seeds.rb
CHANGED
|
@@ -44,6 +44,7 @@ end
|
|
|
44
44
|
|
|
45
45
|
admin_user = nil
|
|
46
46
|
admin_role = nil
|
|
47
|
+
normal_user = nil
|
|
47
48
|
|
|
48
49
|
if defined?(Dscf::Core::User)
|
|
49
50
|
admin_user = Dscf::Core::User.find_or_create_by!(email: 'admin@bunna.com') do |user|
|
|
@@ -52,6 +53,14 @@ if defined?(Dscf::Core::User)
|
|
|
52
53
|
user.temp_password = false
|
|
53
54
|
user.password = 'SecurePassword123!'
|
|
54
55
|
end
|
|
56
|
+
|
|
57
|
+
normal_user = Dscf::Core::User.find_or_create_by!(email: 'user@bunna.com') do |user|
|
|
58
|
+
user.phone = '+251911123457'
|
|
59
|
+
user.verified_at = Time.current
|
|
60
|
+
user.temp_password = false
|
|
61
|
+
user.password = 'SecurePassword123!'
|
|
62
|
+
end
|
|
63
|
+
|
|
55
64
|
puts "✓ System admin user created/found"
|
|
56
65
|
else
|
|
57
66
|
puts "Warning: Dscf::Core::User not found. Skipping system admin user seed."
|
|
@@ -102,13 +111,13 @@ end
|
|
|
102
111
|
|
|
103
112
|
if defined?(Dscf::Core::Business) && defined?(Dscf::Core::BusinessType)
|
|
104
113
|
business1 = Dscf::Core::Business.find_or_create_by(
|
|
105
|
-
user_id:
|
|
114
|
+
user_id: normal_user.id,
|
|
106
115
|
business_type_id: wholesaler.id
|
|
107
116
|
) do |business|
|
|
108
117
|
business.name = 'Individual Trading Business'
|
|
109
118
|
business.description = 'Individual business for trading services'
|
|
110
|
-
business.contact_email =
|
|
111
|
-
business.contact_phone =
|
|
119
|
+
business.contact_email = normal_user.email
|
|
120
|
+
business.contact_phone = normal_user.phone
|
|
112
121
|
end
|
|
113
122
|
|
|
114
123
|
puts "✓ Businesses created/found"
|
data/lib/dscf/credit/version.rb
CHANGED