dscf-core 0.1.0 → 0.1.1
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/models/dscf/core/business.rb +18 -0
- data/app/models/dscf/core/business_type.rb +9 -0
- data/app/models/dscf/core/role.rb +11 -0
- data/app/models/dscf/core/user.rb +14 -0
- data/app/models/dscf/core/user_role.rb +10 -0
- data/db/migrate/20250821175358_create_dscf_core_users.rb +15 -0
- data/db/migrate/20250821185708_create_dscf_core_roles.rb +11 -0
- data/db/migrate/20250822054547_create_dscf_core_user_roles.rb +12 -0
- data/db/migrate/20250822065156_create_dscf_core_business_types.rb +10 -0
- data/db/migrate/20250822072222_create_dscf_core_businesses.rb +15 -0
- data/lib/dscf/core/engine.rb +1 -4
- data/lib/dscf/core/version.rb +1 -1
- data/spec/factories/dscf/core/business_types.rb +5 -0
- data/spec/factories/dscf/core/businesses.rb +11 -0
- data/spec/factories/dscf/core/roles.rb +6 -0
- data/spec/factories/dscf/core/user_roles.rb +6 -0
- data/spec/factories/dscf/core/users.rb +10 -0
- metadata +20 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 619edb7b97e90954dc87fcef846540842f55e0f6dc6cfd0712bb811704fa2f12
|
4
|
+
data.tar.gz: c53ede3b3dd65d47cf040cad38b52327dcb2cacacddbe7020a3bef6891a8add1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b0236fc1c523a946f57da3a1f173e9dea653ab7487504afda1017400517d890bb27579e149a4e5e7eec0328933e2760307929d897281ef519904344f1bdc4a66
|
7
|
+
data.tar.gz: de58d1c8a1c991c83d61ea76869ff0b73d724db1616ccfc6ba8df6f16fcc6d79fd3ee987e811f8be1eead8557a4b0a3ad7d3b31d4daf5709c55372f1d89b558f
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Core
|
3
|
+
class Business < ApplicationRecord
|
4
|
+
belongs_to :user, class_name: "Dscf::Core::User"
|
5
|
+
belongs_to :business_type, class_name: "Dscf::Core::BusinessType"
|
6
|
+
|
7
|
+
has_one_attached :logo
|
8
|
+
|
9
|
+
validates :name, presence: true
|
10
|
+
|
11
|
+
def logo_url
|
12
|
+
return nil unless logo.attached?
|
13
|
+
|
14
|
+
Rails.application.routes.url_helpers.rails_blob_url(logo, only_path: true)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Core
|
3
|
+
class Role < ApplicationRecord
|
4
|
+
validates :code, presence: true, uniqueness: true
|
5
|
+
validates :name, presence: true
|
6
|
+
|
7
|
+
has_many :user_roles, class_name: "Dscf::Core::UserRole"
|
8
|
+
has_many :users, through: :user_roles, class_name: "Dscf::Core::User"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Dscf
|
2
|
+
module Core
|
3
|
+
class User < ApplicationRecord
|
4
|
+
has_secure_password
|
5
|
+
|
6
|
+
validates :email, presence: true, uniqueness: true
|
7
|
+
validates :phone, presence: true, uniqueness: true
|
8
|
+
|
9
|
+
has_many :user_roles, class_name: "Dscf::Core::UserRole"
|
10
|
+
has_many :roles, through: :user_roles, class_name: "Dscf::Core::Role"
|
11
|
+
has_many :businesses, dependent: :destroy, class_name: "Dscf::Core::Business"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateDscfCoreUsers < ActiveRecord::Migration[8.0]
|
2
|
+
def change
|
3
|
+
create_table :dscf_core_users do |t|
|
4
|
+
t.string :email, null: false, limit: 150
|
5
|
+
t.string :phone, null: false, limit: 30
|
6
|
+
t.datetime :verified_at
|
7
|
+
t.boolean :temp_password, null: false
|
8
|
+
t.string :password_digest
|
9
|
+
|
10
|
+
t.timestamps
|
11
|
+
end
|
12
|
+
add_index :dscf_core_users, :email, unique: true
|
13
|
+
add_index :dscf_core_users, :phone, unique: true
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
class CreateDscfCoreRoles < ActiveRecord::Migration[8.0]
|
2
|
+
def change
|
3
|
+
create_table :dscf_core_roles do |t|
|
4
|
+
t.string :code, null: false, limit: 50
|
5
|
+
t.string :name, null: false, limit: 100
|
6
|
+
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
add_index :dscf_core_roles, :code, unique: true
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
class CreateDscfCoreUserRoles < ActiveRecord::Migration[8.0]
|
2
|
+
def change
|
3
|
+
create_table :dscf_core_user_roles do |t|
|
4
|
+
t.references :user, null: false, index: {name: "user_on_dc_ur_indx"}, foreign_key: {to_table: :dscf_core_users}
|
5
|
+
t.references :role, null: false, index: {name: "role_on_dc_ur_indx"}, foreign_key: {to_table: :dscf_core_roles}
|
6
|
+
|
7
|
+
t.timestamps
|
8
|
+
end
|
9
|
+
|
10
|
+
add_index :dscf_core_user_roles, %i[user_id role_id], unique: true, name: "user_role_unique_indx"
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateDscfCoreBusinesses < ActiveRecord::Migration[7.1]
|
2
|
+
def change
|
3
|
+
create_table :dscf_core_businesses do |t|
|
4
|
+
t.string :name, null: false
|
5
|
+
t.string :description
|
6
|
+
t.string :contact_email
|
7
|
+
t.string :contact_phone
|
8
|
+
t.string :tin_number
|
9
|
+
t.references :business_type, null: false, foreign_key: {to_table: :dscf_core_business_types}
|
10
|
+
t.references :user, null: false, foreign_key: {to_table: :dscf_core_users}
|
11
|
+
|
12
|
+
t.timestamps
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/dscf/core/engine.rb
CHANGED
@@ -15,13 +15,10 @@ module Dscf
|
|
15
15
|
end
|
16
16
|
|
17
17
|
initializer :append_migrations do |app|
|
18
|
-
unless app.root.to_s.match(root.to_s + File::SEPARATOR)
|
19
|
-
app.config.paths["db/migrate"].concat(config.paths["db/migrate"].expanded)
|
20
|
-
end
|
18
|
+
app.config.paths["db/migrate"].concat(config.paths["db/migrate"].expanded) unless app.root.to_s.match(root.to_s + File::SEPARATOR)
|
21
19
|
end
|
22
20
|
|
23
21
|
require "active_storage/engine"
|
24
|
-
|
25
22
|
end
|
26
23
|
end
|
27
24
|
end
|
data/lib/dscf/core/version.rb
CHANGED
@@ -0,0 +1,11 @@
|
|
1
|
+
FactoryBot.define do
|
2
|
+
factory :business, class: "Dscf::Core::Business" do
|
3
|
+
name { Faker::Company.name }
|
4
|
+
description { Faker::Company.catch_phrase }
|
5
|
+
contact_email { Faker::Internet.email }
|
6
|
+
contact_phone { Faker::PhoneNumber.phone_number }
|
7
|
+
tin_number { Faker::Number.number(digits: 10).to_s }
|
8
|
+
user
|
9
|
+
business_type
|
10
|
+
end
|
11
|
+
end
|
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.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Asrat
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-08-
|
10
|
+
date: 2025-08-22 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: active_model_serializers
|
@@ -108,7 +108,7 @@ dependencies:
|
|
108
108
|
- !ruby/object:Gem::Version
|
109
109
|
version: '0'
|
110
110
|
- !ruby/object:Gem::Dependency
|
111
|
-
name:
|
111
|
+
name: pundit
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
113
113
|
requirements:
|
114
114
|
- - ">="
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
- !ruby/object:Gem::Version
|
123
123
|
version: '0'
|
124
124
|
- !ruby/object:Gem::Dependency
|
125
|
-
name:
|
125
|
+
name: rails
|
126
126
|
requirement: !ruby/object:Gem::Requirement
|
127
127
|
requirements:
|
128
128
|
- - ">="
|
@@ -136,7 +136,7 @@ dependencies:
|
|
136
136
|
- !ruby/object:Gem::Version
|
137
137
|
version: '0'
|
138
138
|
- !ruby/object:Gem::Dependency
|
139
|
-
name:
|
139
|
+
name: ransack
|
140
140
|
requirement: !ruby/object:Gem::Requirement
|
141
141
|
requirements:
|
142
142
|
- - ">="
|
@@ -289,11 +289,26 @@ files:
|
|
289
289
|
- app/jobs/dscf/core/application_job.rb
|
290
290
|
- app/mailers/dscf/core/application_mailer.rb
|
291
291
|
- app/models/dscf/core/application_record.rb
|
292
|
+
- app/models/dscf/core/business.rb
|
293
|
+
- app/models/dscf/core/business_type.rb
|
294
|
+
- app/models/dscf/core/role.rb
|
295
|
+
- app/models/dscf/core/user.rb
|
296
|
+
- app/models/dscf/core/user_role.rb
|
292
297
|
- config/routes.rb
|
298
|
+
- db/migrate/20250821175358_create_dscf_core_users.rb
|
299
|
+
- db/migrate/20250821185708_create_dscf_core_roles.rb
|
300
|
+
- db/migrate/20250822054547_create_dscf_core_user_roles.rb
|
301
|
+
- db/migrate/20250822065156_create_dscf_core_business_types.rb
|
302
|
+
- db/migrate/20250822072222_create_dscf_core_businesses.rb
|
293
303
|
- lib/dscf/core.rb
|
294
304
|
- lib/dscf/core/engine.rb
|
295
305
|
- lib/dscf/core/version.rb
|
296
306
|
- lib/tasks/dscf/core_tasks.rake
|
307
|
+
- spec/factories/dscf/core/business_types.rb
|
308
|
+
- spec/factories/dscf/core/businesses.rb
|
309
|
+
- spec/factories/dscf/core/roles.rb
|
310
|
+
- spec/factories/dscf/core/user_roles.rb
|
311
|
+
- spec/factories/dscf/core/users.rb
|
297
312
|
homepage: https://mksaddis.com/
|
298
313
|
licenses:
|
299
314
|
- MIT
|