effective_learndash 0.1.6 → 0.1.9

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: bf3a76614af4d9fba4a5d9e483ecfc78ec821c042643b0d59508b42f80aead20
4
- data.tar.gz: 3e383233f17438db0bc4c134e8fb767183b3697b0036100ddf89e80961b42332
3
+ metadata.gz: 8a995bb252c9977d587fad29eb85ed7a700e14623000545f40f86c5ef11578e3
4
+ data.tar.gz: a8e0082d8e0db22298325ba7bfc074e01ef0f244063e7e4725058dcac0bf704d
5
5
  SHA512:
6
- metadata.gz: 73041dc5fa8d6e130f865cd0ed5acf4c966ff1d7148168d6482f582f68c29d86fd8521c6d23aeb35227ca1f70810bd54b88408527767c3654b0998f8f6513d37
7
- data.tar.gz: 58d39dc3138ff44d2be3152aba69734f7f83146714b1b79a44b084cdc05dcd865974e457b4f61c2c3dd2436e5a81b709db7ea3cde5b68b807a325bf28df7c58e
6
+ metadata.gz: c4b47b748dcb01abb40f39f7a2db372e15c9ddc872a98f78afb7e6dddd10b4b404c3dbc280d82895ac2b7cb593622292a201e791dbb7f720ad4b4137eb8968da
7
+ data.tar.gz: 5278f678c4e13c4e08ed936fc53e7d9e3225e8db1ff3b663abf6acc67589001cd39b120a4d802abace3ad9e3710b88f10e676074f10fea7c6c1dd8ee5dbd27af
@@ -2,8 +2,8 @@
2
2
 
3
3
  class EffectiveCourseRegistrantsDatatable < Effective::Datatable
4
4
  datatable do
5
- col :learndash_course
6
- col :owner, label: 'User', action: false
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,8 +87,9 @@ module EffectiveLearndashCourseRegistration
87
87
  course_registrants
88
88
  end
89
89
 
90
- # Enroll them in all courses.
90
+ # Create learndash user and enroll in all courses
91
91
  def after_submit_purchased!
92
+ learndash_owner.create_learndash_user
92
93
  course_registrants.each { |registrant| registrant.owner.create_learndash_enrollment(course: registrant.learndash_course) }
93
94
  end
94
95
 
@@ -155,12 +156,6 @@ module EffectiveLearndashCourseRegistration
155
156
 
156
157
  # Save record
157
158
  save!
158
-
159
- # Create a learndash user now before payment to catch any errors in server stuff before payment.
160
- learndash_owner.create_learndash_user
161
- raise('expected a persisted learndash user') unless learndash_owner.learndash_user&.persisted?
162
-
163
- true
164
159
  end
165
160
 
166
161
  private
@@ -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.try(:email)
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
- email = resource.email
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
 
@@ -1,3 +1,3 @@
1
1
  module EffectiveLearndash
2
- VERSION = '0.1.6'.freeze
2
+ VERSION = '0.1.9'.freeze
3
3
  end
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.6
4
+ version: 0.1.9
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-05-02 00:00:00.000000000 Z
11
+ date: 2022-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails