dscf-credit 0.4.57 → 0.4.59

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: 9dd97d9f175fb7a5ca199d3936aac923a3dade3a884f3104ede5b3e360ca9eec
4
- data.tar.gz: ceef5ac266b5c3098cc04dd7fc2fd5aa1b42a96a454fe2b58e29cb5eb483fe3e
3
+ metadata.gz: 70bb55068257cda9e5f5d8d3de13f350631e2843791f468cb7bea66444bc2dc7
4
+ data.tar.gz: 51b94b70b4572111df8304fb1cf4e35b48961bdc9c7a186ffcc993068ef3ad38
5
5
  SHA512:
6
- metadata.gz: 195cb6e222088619ac2fd418886f59045960f3b315aab843108284894ddad9d20e69bae9d1405ffde8bf974e9b1f5d498bf64c4feac8f43cdab8d04e796a4c46
7
- data.tar.gz: 6c06c6031927a07554603dbe1030614a4e5cc195493dc2874ed796ad393b3e7baf41148a0c8547ab9c76576fb9ed89711521f6c7cf0fb692efc6f3dfc17672bc
6
+ metadata.gz: b0c7c18b2054ad521b2e6e33139ac584248d35f4e34db7a7572ddd6e0a76e1f69fa30f20e4c194a058a1d14793a4fb43f87a8350540bc8387d746b45f0b8d88e
7
+ data.tar.gz: d4ad44b2556648d4cb9cbb5bc780f397e220f9425825019737b12b53bf7fef32b2fce683f1f85468673fbf65f763aa95075e7cb1c05d9ec44ff8a8cf9ff92b49
@@ -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."
@@ -63,6 +72,10 @@ if defined?(Dscf::Core::Role)
63
72
  role.description = 'Full system access — bypasses all permission checks'
64
73
  role.active = true
65
74
  end
75
+ user_role = Dscf::Core::Role.find_or_create_by!(code: "USER") do |role|
76
+ role.name = "User"
77
+ role.active = true
78
+ end
66
79
  puts "✓ System admin role created/found"
67
80
  end
68
81
 
@@ -71,6 +84,7 @@ if defined?(Dscf::Core::Permission) && defined?(Dscf::Core::RolePermission)
71
84
  # SUPER_ADMIN gets all permissions
72
85
  Dscf::Core::Permission.where(code: all_credit_permissions).each do |perm|
73
86
  Dscf::Core::RolePermission.find_or_create_by!(role: super_admin_role, permission: perm)
87
+ Dscf::Core::RolePermission.find_or_create_by!(role: user_role, permission: perm)
74
88
  end
75
89
  end
76
90
 
@@ -79,6 +93,11 @@ if admin_user && super_admin_role && defined?(Dscf::Core::UserRole)
79
93
  puts "✓ Super admin role assigned to admin user"
80
94
  end
81
95
 
96
+ if normal_user && user_role && defined?(Dscf::Core::UserRole)
97
+ Dscf::Core::UserRole.find_or_create_by!(user: normal_user, role: user_role)
98
+ puts "✓ User role assigned to normal user"
99
+ end
100
+
82
101
  bunna_bank = Dscf::Credit::Bank.find_or_create_by!(registration_number: 'BUN001') do |bank|
83
102
  bank.name = 'Bunna Bank'
84
103
  bank.swift_code = 'BUNNETAA'
@@ -102,13 +121,13 @@ end
102
121
 
103
122
  if defined?(Dscf::Core::Business) && defined?(Dscf::Core::BusinessType)
104
123
  business1 = Dscf::Core::Business.find_or_create_by(
105
- user_id: admin_user.id,
124
+ user_id: normal_user.id,
106
125
  business_type_id: wholesaler.id
107
126
  ) do |business|
108
127
  business.name = 'Individual Trading Business'
109
128
  business.description = 'Individual business for trading services'
110
- business.contact_email = admin_user.email
111
- business.contact_phone = admin_user.phone
129
+ business.contact_email = normal_user.email
130
+ business.contact_phone = normal_user.phone
112
131
  end
113
132
 
114
133
  puts "✓ Businesses created/found"
@@ -1,5 +1,5 @@
1
1
  module Dscf
2
2
  module Credit
3
- VERSION = "0.4.57"
3
+ VERSION = "0.4.59"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dscf-credit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.57
4
+ version: 0.4.59
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adoniyas
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2026-04-21 00:00:00.000000000 Z
10
+ date: 2026-04-28 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: dscf-core