effective_products 0.3.0 → 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/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/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: 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
|
@@ -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'
|
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.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
|