effective_learndash 0.1.5 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz: '
|
3
|
+
metadata.gz: bb60befd537b5ed6b7111baf26c546997223c4350c60d0b66cf6803281616c64
|
4
|
+
data.tar.gz: '0087f4c16776214a5bb6b098078ade3f3a215742f75820b1c9046180faa0cf0b'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a9def7fbe45dec58d8768454a9adccffb989b44a1f387ee1b04de0c56f9db48ba5f104012ee4060fbf4adb9e35ec3ebc0281ff4274f10c486efc3ba7416e526
|
7
|
+
data.tar.gz: 5b8bd37c4ea919fc77aa4f61d6f8aa8b4c638dbb8b9deb72bcf632fa4c56cd01da62024f0e8ff98656060e9e2d25315a5882bebb4760a6b21d7c860cc49165f6
|
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
class EffectiveCourseRegistrantsDatatable < Effective::Datatable
|
4
4
|
datatable do
|
5
|
-
col :learndash_course
|
6
|
-
col :owner, label: '
|
5
|
+
col :learndash_course, label: 'Title'
|
6
|
+
col :owner, label: 'Registrant', action: false
|
7
7
|
col :price, as: :price
|
8
8
|
end
|
9
9
|
|
@@ -87,9 +87,9 @@ module EffectiveLearndashCourseRegistration
|
|
87
87
|
course_registrants
|
88
88
|
end
|
89
89
|
|
90
|
+
# Enroll them in all courses.
|
90
91
|
def after_submit_purchased!
|
91
|
-
|
92
|
-
learndash_owner.create_learndash_enrollment(course: learndash_course)
|
92
|
+
course_registrants.each { |registrant| registrant.owner.create_learndash_enrollment(course: registrant.learndash_course) }
|
93
93
|
end
|
94
94
|
|
95
95
|
end
|
@@ -116,7 +116,7 @@ module EffectiveLearndashCourseRegistration
|
|
116
116
|
end
|
117
117
|
|
118
118
|
def build_course_registrant
|
119
|
-
course_registrants.build(owner: owner)
|
119
|
+
course_registrants.build(owner: owner, learndash_course: learndash_course)
|
120
120
|
end
|
121
121
|
|
122
122
|
def learndash_owner
|
@@ -151,7 +151,7 @@ module EffectiveLearndashCourseRegistration
|
|
151
151
|
|
152
152
|
# Assign prices
|
153
153
|
assign_pricing()
|
154
|
-
raise('expected
|
154
|
+
raise('expected course_registrants to have a price') if course_registrants.any? { |registrant| registrant.price.blank? }
|
155
155
|
|
156
156
|
# Save record
|
157
157
|
save!
|
@@ -30,7 +30,7 @@ module Effective
|
|
30
30
|
def find_user(value)
|
31
31
|
# Find by email
|
32
32
|
if value.kind_of?(String) && value.include?('@')
|
33
|
-
return find_by("/wp/v2/users", :email, value)
|
33
|
+
return find_by("/wp/v2/users", :email, email_for(value))
|
34
34
|
end
|
35
35
|
|
36
36
|
# Fetch by saved param value
|
@@ -39,7 +39,7 @@ module Effective
|
|
39
39
|
return user if user.present?
|
40
40
|
|
41
41
|
# Find by email
|
42
|
-
email = value
|
42
|
+
email = email_for(value)
|
43
43
|
user = find_by("/wp/v2/users", :email, email) if email
|
44
44
|
return user if user.present?
|
45
45
|
|
@@ -122,7 +122,6 @@ module Effective
|
|
122
122
|
|
123
123
|
# private under this point
|
124
124
|
|
125
|
-
|
126
125
|
def user_id(resource)
|
127
126
|
if resource.class.respond_to?(:effective_learndash_owner?) # This is a user
|
128
127
|
resource.learndash_user&.user_id
|
@@ -147,18 +146,9 @@ module Effective
|
|
147
146
|
|
148
147
|
def username_for(resource)
|
149
148
|
raise('expected a LearnDash owner') unless resource.class.respond_to?(:effective_learndash_owner?) # This is a user
|
150
|
-
|
151
149
|
name = EffectiveLearndash.wp_username_for(resource)
|
152
|
-
name = "test#{name}" unless Rails.env.production?
|
153
|
-
name
|
154
|
-
end
|
155
|
-
|
156
|
-
def email_for(resource)
|
157
|
-
raise('expected a LearnDash owner') unless resource.class.respond_to?(:effective_learndash_owner?) # This is a user
|
158
150
|
|
159
|
-
|
160
|
-
email = "test#{email}" unless Rails.env.production?
|
161
|
-
email
|
151
|
+
Rails.env.production? ? name : "test#{name}"
|
162
152
|
end
|
163
153
|
|
164
154
|
def password_for(resource)
|
@@ -166,6 +156,13 @@ module Effective
|
|
166
156
|
EffectiveLearndash.wp_password_for(resource)
|
167
157
|
end
|
168
158
|
|
159
|
+
def email_for(value)
|
160
|
+
email = value.try(:email) || value.to_s
|
161
|
+
return nil unless email.present? && email.include?('@')
|
162
|
+
|
163
|
+
Rails.env.production? ? email : "test#{email}"
|
164
|
+
end
|
165
|
+
|
169
166
|
def find(endpoint, params = nil)
|
170
167
|
response = get(endpoint, params)
|
171
168
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_learndash
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
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: 2022-
|
11
|
+
date: 2022-05-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|