effective_products 0.2.1 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/app/datatables/admin/effective_stamps_datatable.rb +26 -15
- data/app/models/concerns/effective_products_stamp_wizard.rb +1 -1
- data/app/models/effective/ring.rb +2 -0
- data/app/models/effective/ring_wizard.rb +1 -1
- data/app/models/effective/stamp.rb +22 -4
- data/app/models/effective/stamp_wizard.rb +1 -1
- data/app/views/admin/stamps/_form.html.haml +6 -19
- data/app/views/admin/stamps/_form_stamp.html.haml +23 -0
- data/config/effective_products.rb +0 -5
- data/db/migrate/{01_create_effective_products.rb.erb → 101_create_effective_products.rb} +1 -1
- data/lib/effective_products/version.rb +1 -1
- data/lib/generators/effective_products/install_generator.rb +1 -3
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6b962a8361ef38e6fd53023d4f6cc26a048d14dad3c6764c65c4592aeeb4feb
|
4
|
+
data.tar.gz: bed89486cacc7cc0a6fe02e2e4bd0559134e67198ca688c594375b270ef4f8ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 270befc380dfe3fdc3f0b6c93aca1225cd0969322a81ae8f23b0e855335c328f7cff0fac00abdcf5706d7455066366d932fe7409e8a34388c629c147783fe261
|
7
|
+
data.tar.gz: b39a6283d0e81cf2e2204a8aeac6f14f8d52f75683a36cc65d1b1e7cf4ca7f91bc8aed3a64cc35c5130d63ce07a2aade14819e5dfe3f2bd73bc0cd0ab82616d5
|
data/MIT-LICENSE
CHANGED
@@ -2,25 +2,37 @@ module Admin
|
|
2
2
|
class EffectiveStampsDatatable < Effective::Datatable
|
3
3
|
filters do
|
4
4
|
scope :ready_to_issue
|
5
|
+
scope :pending_applicant_approval
|
6
|
+
scope :pending_stamp_request_purchase
|
5
7
|
scope :issued
|
6
8
|
scope :all
|
7
9
|
end
|
8
10
|
|
9
11
|
datatable do
|
10
|
-
order :
|
12
|
+
order :created_at
|
11
13
|
|
12
14
|
col :updated_at, visible: false
|
13
15
|
col :created_at, visible: false
|
14
16
|
col :id, visible: false
|
15
17
|
|
16
18
|
col :created_at, as: :date
|
19
|
+
col :status, visible: false
|
17
20
|
col :owner, search: :string
|
18
21
|
|
19
|
-
col
|
20
|
-
|
22
|
+
col(:applicant, search: :string) do |stamp|
|
23
|
+
if stamp.applicant.present?
|
24
|
+
link_to(stamp.applicant, effective_memberships.edit_admin_applicant_path(stamp.applicant)) + ' ' + badges(stamp.applicant.status)
|
25
|
+
end
|
26
|
+
end
|
21
27
|
|
22
|
-
col(:
|
23
|
-
|
28
|
+
col(:stamp_wizard, search: :string) do |stamp|
|
29
|
+
if stamp.stamp_wizard.present?
|
30
|
+
stamp.stamp_wizard.to_s + ' ' + badges(stamp.stamp_wizard.status)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
col(:email, visible: false) { |stamp| mail_to stamp.owner.email }
|
35
|
+
col(:phone, visible: false) { |stamp| stamp.owner.phone }
|
24
36
|
|
25
37
|
col :member_number, label: 'Member #' do |stamp|
|
26
38
|
stamp.owner.try(:membership).try(:number)
|
@@ -31,21 +43,20 @@ module Admin
|
|
31
43
|
|
32
44
|
col :category, search: EffectiveProducts.stamp_categories
|
33
45
|
|
34
|
-
col :shipping_address
|
35
|
-
col(:address1) { |stamp| stamp.shipping_address.try(:address1) }
|
36
|
-
col(:address2) { |stamp| stamp.shipping_address.try(:address2) }
|
37
|
-
col(:city) { |stamp| stamp.shipping_address.try(:city) }
|
38
|
-
col(:state_code, label: 'Prov') { |stamp| stamp.shipping_address.try(:state_code) }
|
39
|
-
col(:postal_code, label: 'Postal') { |stamp| stamp.shipping_address.try(:postal_code) }
|
40
|
-
col(:country_code, label: 'Country') { |stamp| stamp.shipping_address.try(:country_code) }
|
46
|
+
col :shipping_address
|
47
|
+
col(:address1, visible: false) { |stamp| stamp.shipping_address.try(:address1) }
|
48
|
+
col(:address2, visible: false) { |stamp| stamp.shipping_address.try(:address2) }
|
49
|
+
col(:city, visible: false) { |stamp| stamp.shipping_address.try(:city) }
|
50
|
+
col(:state_code, visible: false, label: 'Prov') { |stamp| stamp.shipping_address.try(:state_code) }
|
51
|
+
col(:postal_code, visible: false, label: 'Postal') { |stamp| stamp.shipping_address.try(:postal_code) }
|
52
|
+
col(:country_code, visible: false, label: 'Country') { |stamp| stamp.shipping_address.try(:country_code) }
|
41
53
|
|
42
|
-
col :purchased_order, visible: false
|
54
|
+
col :purchased_order, search: :string, visible: false
|
43
55
|
col :price, as: :price, visible: false
|
44
56
|
col :tax_exempt, visible: false
|
45
57
|
col :qb_item_name, visible: false
|
46
58
|
|
47
|
-
col :
|
48
|
-
col :issued_at
|
59
|
+
col :issued_at, as: :date
|
49
60
|
|
50
61
|
actions_col
|
51
62
|
end
|
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
module Effective
|
4
4
|
class Ring < ActiveRecord::Base
|
5
|
+
self.table_name = (EffectiveProducts.rings_table_name || :rings).to_s
|
6
|
+
|
5
7
|
SIZES = [3, 4, 5, 6, 7, 8]
|
6
8
|
TITANIUM_SIZES = [3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]
|
7
9
|
METALS = ['14k Yellow Gold', 'Sterling Silver', 'Titanium']
|
@@ -2,9 +2,13 @@
|
|
2
2
|
|
3
3
|
module Effective
|
4
4
|
class Stamp < ActiveRecord::Base
|
5
|
+
self.table_name = (EffectiveProducts.stamps_table_name || :stamps).to_s
|
6
|
+
|
5
7
|
acts_as_purchasable
|
6
8
|
acts_as_addressable :shipping
|
7
9
|
|
10
|
+
attr_accessor :admin_action
|
11
|
+
|
8
12
|
acts_as_statused(
|
9
13
|
:draft, # Built in an application
|
10
14
|
:submitted, # Submitted by an applicant or stamp wizard
|
@@ -43,16 +47,25 @@ module Effective
|
|
43
47
|
timestamps
|
44
48
|
end
|
45
49
|
|
46
|
-
scope :deep, -> { includes(:addresses, owner: [:membership]) }
|
50
|
+
scope :deep, -> { includes(:addresses, :purchased_order, owner: [:membership], applicant: [:category, :user], stamp_wizard: [:user]) }
|
51
|
+
scope :not_issued, -> { where.not(status: :issued) }
|
47
52
|
|
48
53
|
scope :with_approved_applicants, -> { where(applicant_id: EffectiveMemberships.Applicant.approved) }
|
49
|
-
scope :
|
50
|
-
|
54
|
+
scope :with_unapproved_applicants, -> { where.not(applicant_id: nil).where.not(applicant_id: EffectiveMemberships.Applicant.approved) }
|
55
|
+
|
56
|
+
scope :with_purchased_stamp_wizards, -> { purchased.where.not(stamp_wizard_id: nil) }
|
57
|
+
scope :with_not_purchased_stamp_wizards, -> { not_purchased.where.not(stamp_wizard_id: nil) }
|
58
|
+
|
59
|
+
scope :created_by_admin, -> { submitted.where(applicant_id: nil, stamp_wizard_id: nil) }
|
51
60
|
|
61
|
+
# Datatable Scopes
|
52
62
|
scope :ready_to_issue, -> {
|
53
|
-
with_approved_applicants.or(
|
63
|
+
with_approved_applicants.or(with_purchased_stamp_wizards).or(created_by_admin).submitted
|
54
64
|
}
|
55
65
|
|
66
|
+
scope :pending_applicant_approval, -> { not_issued.with_unapproved_applicants }
|
67
|
+
scope :pending_stamp_request_purchase, -> { not_issued.with_not_purchased_stamp_wizards }
|
68
|
+
|
56
69
|
validates :name, presence: true
|
57
70
|
validates :name_confirmation, presence: true
|
58
71
|
validates :category, presence: true
|
@@ -66,6 +79,10 @@ module Effective
|
|
66
79
|
self.errors.add(:category, "is not included") unless EffectiveProducts.stamp_categories.include?(category)
|
67
80
|
end
|
68
81
|
|
82
|
+
validate(if: -> { admin_action }) do
|
83
|
+
self.errors.add(:owner_id, "must have a membership") unless owner && owner.try(:membership).present?
|
84
|
+
end
|
85
|
+
|
69
86
|
def to_s
|
70
87
|
[model_name.human, *name.presence].join(' ')
|
71
88
|
end
|
@@ -91,6 +108,7 @@ module Effective
|
|
91
108
|
|
92
109
|
# This is the Admin Save and Mark Paid action
|
93
110
|
def mark_paid!
|
111
|
+
update!(admin_action: true) # Make sure we have an owner with a membership
|
94
112
|
raise('expected an user with a membership category') unless owner && owner.try(:membership).present?
|
95
113
|
|
96
114
|
category = owner.membership.categories.first
|
@@ -1,21 +1,8 @@
|
|
1
|
-
=
|
2
|
-
|
3
|
-
=
|
4
|
-
= f.hidden_field :owner_type
|
1
|
+
= tabs do
|
2
|
+
= tab(stamp) do
|
3
|
+
= render 'admin/stamps/form_stamp', stamp: stamp
|
5
4
|
|
6
|
-
-
|
7
|
-
|
8
|
-
|
5
|
+
- if stamp.persisted?
|
6
|
+
= tab 'Logs' do
|
7
|
+
= render_inline_datatable(stamp.logs_datatable)
|
9
8
|
|
10
|
-
= f.select :owner_id, current_user.class.all, label: 'User', ajax_url: ajax_url,
|
11
|
-
'data-load-ajax-url': effective_products.new_admin_stamp_path,
|
12
|
-
'data-load-ajax-div': '#effective-stamps-ajax'
|
13
|
-
|
14
|
-
#effective-stamps-ajax
|
15
|
-
= render 'effective/stamps/fields', f: f, stamp: f.object
|
16
|
-
|
17
|
-
= f.submit do
|
18
|
-
= f.save 'Save'
|
19
|
-
|
20
|
-
- if f.object.new_record?
|
21
|
-
= f.save 'Save and Mark Paid'
|
@@ -0,0 +1,23 @@
|
|
1
|
+
= effective_form_with(model: [:admin, stamp], engine: true) do |f|
|
2
|
+
- if inline_datatable?
|
3
|
+
= f.hidden_field :owner_id
|
4
|
+
= f.hidden_field :owner_type
|
5
|
+
|
6
|
+
- else
|
7
|
+
- ajax_url = (@select2_ajax_path || effective_resources.users_admin_select2_ajax_index_path) unless Rails.env.test?
|
8
|
+
- f.object.owner_type ||= current_user.class.name
|
9
|
+
|
10
|
+
= f.hidden_field :owner_type
|
11
|
+
|
12
|
+
= f.select :owner_id, current_user.class.all, label: 'User', ajax_url: ajax_url,
|
13
|
+
'data-load-ajax-url': effective_products.new_admin_stamp_path,
|
14
|
+
'data-load-ajax-div': '#effective-stamps-ajax'
|
15
|
+
|
16
|
+
#effective-stamps-ajax
|
17
|
+
= render 'effective/stamps/fields', f: f, stamp: f.object
|
18
|
+
|
19
|
+
= f.submit do
|
20
|
+
- if f.object.new_record?
|
21
|
+
= f.save 'Save and Mark Paid'
|
22
|
+
- else
|
23
|
+
= f.save 'Save'
|
@@ -1,9 +1,4 @@
|
|
1
1
|
EffectiveProducts.setup do |config|
|
2
|
-
config.rings_table_name = :rings
|
3
|
-
config.ring_wizards_table_name = :ring_wizards
|
4
|
-
config.stamps_table_name = :stamps
|
5
|
-
config.stamp_wizards_table_name = :stamp_wizards
|
6
|
-
|
7
2
|
# Layout Settings
|
8
3
|
# Configure the Layout per controller, or all at once
|
9
4
|
# config.layout = { application: 'application', admin: 'admin' }
|
@@ -20,9 +20,7 @@ module EffectiveMemberships
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def create_migration_file
|
23
|
-
|
24
|
-
|
25
|
-
migration_template ('../' * 3) + 'db/migrate/01_create_effective_products.rb.erb', 'db/migrate/create_effective_products.rb'
|
23
|
+
migration_template ('../' * 3) + 'db/migrate/101_create_effective_products.rb', 'db/migrate/create_effective_products.rb'
|
26
24
|
end
|
27
25
|
|
28
26
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_products
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -238,6 +238,7 @@ files:
|
|
238
238
|
- app/models/effective/stamp_wizard.rb
|
239
239
|
- app/views/admin/rings/_ring.html.haml
|
240
240
|
- app/views/admin/stamps/_form.html.haml
|
241
|
+
- app/views/admin/stamps/_form_stamp.html.haml
|
241
242
|
- app/views/admin/stamps/_stamp.html.haml
|
242
243
|
- app/views/effective/ring_wizards/_content.html.haml
|
243
244
|
- app/views/effective/ring_wizards/_dashboard.html.haml
|
@@ -271,7 +272,7 @@ files:
|
|
271
272
|
- config/effective_products.rb
|
272
273
|
- config/locales/effective_products.en.yml
|
273
274
|
- config/routes.rb
|
274
|
-
- db/migrate/
|
275
|
+
- db/migrate/101_create_effective_products.rb
|
275
276
|
- db/seeds.rb
|
276
277
|
- lib/effective_products.rb
|
277
278
|
- lib/effective_products/engine.rb
|