effective_products 0.3.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- 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/stamp.rb +20 -4
- data/app/views/admin/stamps/_form.html.haml +6 -19
- data/app/views/admin/stamps/_form_stamp.html.haml +23 -0
- data/lib/effective_products/engine.rb +1 -1
- data/lib/effective_products/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 80bac2e7b1ed3a48a5c5f2caca7174e2e3ec02df57d03cf33981dc9b590ac4d4
|
4
|
+
data.tar.gz: 28647f5ddc1d5481c6cb2e97d9e1d77410e74f5e1940290989f84071e71e79e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5fbe389767f3391a11b774e33a14bf9a65af863797ee665149ac7a89312c62c2f2a01943ffd0bf0c5ec2ea7e61dce2e5b7429214a7505fb917caa3848a6d1b4
|
7
|
+
data.tar.gz: 4b5b4bf6a5bb5953ec889e82fd88cb206d7a364646cf063fff75d0e7e1d0abaa0fce1fe0d8e766c6eb7b06e6f5a2ce676e8c5df5e032d9fa17c3a1599a5250b3
|
@@ -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
|
@@ -7,6 +7,8 @@ module Effective
|
|
7
7
|
acts_as_purchasable
|
8
8
|
acts_as_addressable :shipping
|
9
9
|
|
10
|
+
attr_accessor :admin_action
|
11
|
+
|
10
12
|
acts_as_statused(
|
11
13
|
:draft, # Built in an application
|
12
14
|
:submitted, # Submitted by an applicant or stamp wizard
|
@@ -45,16 +47,25 @@ module Effective
|
|
45
47
|
timestamps
|
46
48
|
end
|
47
49
|
|
48
|
-
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) }
|
49
52
|
|
50
53
|
scope :with_approved_applicants, -> { where(applicant_id: EffectiveMemberships.Applicant.approved) }
|
51
|
-
scope :
|
52
|
-
|
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) }
|
53
60
|
|
61
|
+
# Datatable Scopes
|
54
62
|
scope :ready_to_issue, -> {
|
55
|
-
with_approved_applicants.or(
|
63
|
+
with_approved_applicants.or(with_purchased_stamp_wizards).or(created_by_admin).submitted
|
56
64
|
}
|
57
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
|
+
|
58
69
|
validates :name, presence: true
|
59
70
|
validates :name_confirmation, presence: true
|
60
71
|
validates :category, presence: true
|
@@ -68,6 +79,10 @@ module Effective
|
|
68
79
|
self.errors.add(:category, "is not included") unless EffectiveProducts.stamp_categories.include?(category)
|
69
80
|
end
|
70
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
|
+
|
71
86
|
def to_s
|
72
87
|
[model_name.human, *name.presence].join(' ')
|
73
88
|
end
|
@@ -93,6 +108,7 @@ module Effective
|
|
93
108
|
|
94
109
|
# This is the Admin Save and Mark Paid action
|
95
110
|
def mark_paid!
|
111
|
+
update!(admin_action: true) # Make sure we have an owner with a membership
|
96
112
|
raise('expected an user with a membership category') unless owner && owner.try(:membership).present?
|
97
113
|
|
98
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'
|
@@ -9,7 +9,7 @@ module EffectiveProducts
|
|
9
9
|
|
10
10
|
# Include acts_as_addressable concern and allow any ActiveRecord object to call it
|
11
11
|
initializer 'effective_products.active_record' do |app|
|
12
|
-
|
12
|
+
app.config.to_prepare do
|
13
13
|
ActiveRecord::Base.extend(EffectiveProductsRingWizard::Base)
|
14
14
|
ActiveRecord::Base.extend(EffectiveProductsStampWizard::Base)
|
15
15
|
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.3.
|
4
|
+
version: 0.3.2
|
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-12-04 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
|