effective_learndash 0.1.3 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +16 -10
- data/app/assets/config/effective_learndash_manifest.js +0 -1
- data/app/controllers/admin/course_registrations_controller.rb +8 -0
- data/app/controllers/admin/learndash_courses_controller.rb +1 -1
- data/app/controllers/effective/course_registrations_controller.rb +13 -0
- data/app/controllers/effective/learndash_courses_controller.rb +32 -0
- data/app/datatables/admin/effective_course_registrations_datatable.rb +28 -0
- data/app/datatables/admin/effective_learndash_courses_datatable.rb +5 -1
- data/app/datatables/admin/effective_learndash_enrollments_datatable.rb +1 -2
- data/app/datatables/admin/effective_learndash_users_datatable.rb +1 -1
- data/app/datatables/effective_course_registrants_datatable.rb +24 -0
- data/app/datatables/effective_course_registrations_datatable.rb +35 -0
- data/app/datatables/effective_learndash_courses_datatable.rb +30 -0
- data/app/datatables/effective_learndash_enrollments_datatable.rb +7 -4
- data/app/models/concerns/effective_learndash_course_registration.rb +172 -0
- data/app/models/concerns/effective_learndash_owner.rb +1 -1
- data/app/models/effective/course_registrant.rb +53 -0
- data/app/models/effective/course_registration.rb +5 -0
- data/app/models/effective/learndash_api.rb +14 -5
- data/app/models/effective/learndash_course.rb +78 -3
- data/app/models/effective/learndash_enrollment.rb +7 -3
- data/app/models/effective/learndash_user.rb +5 -6
- data/app/views/admin/learndash_courses/_form.html.haml +25 -0
- data/app/views/admin/learndash_courses/_form_course_registration_content.html.haml +19 -0
- data/app/views/admin/learndash_courses/_form_learndash_course.html.haml +32 -0
- data/app/views/admin/learndash_courses/_learndash_course.html.haml +3 -3
- data/app/views/admin/learndash_owners/_form.html.haml +1 -1
- data/app/views/admin/learndash_users/_form.html.haml +1 -1
- data/app/views/admin/learndash_users/_learndash_user.html.haml +4 -4
- data/app/views/effective/course_registrations/_content.html.haml +10 -0
- data/app/views/effective/course_registrations/_course.html.haml +9 -0
- data/app/views/effective/course_registrations/_course_registration.html.haml +3 -0
- data/app/views/effective/course_registrations/_dashboard.html.haml +30 -0
- data/app/views/effective/course_registrations/_layout.html.haml +3 -0
- data/app/views/effective/course_registrations/_orders.html.haml +4 -0
- data/app/views/effective/course_registrations/_summary.html.haml +39 -0
- data/app/views/effective/course_registrations/billing.html.haml +15 -0
- data/app/views/effective/course_registrations/checkout.html.haml +6 -0
- data/app/views/effective/course_registrations/course.html.haml +20 -0
- data/app/views/effective/course_registrations/start.html.haml +25 -0
- data/app/views/effective/course_registrations/submitted.html.haml +15 -0
- data/app/views/effective/course_registrations/summary.html.haml +8 -0
- data/app/views/effective/learndash/_dashboard.html.haml +14 -16
- data/app/views/effective/learndash_courses/_learndash_course.html.haml +13 -0
- data/app/views/effective/learndash_courses/index.html.haml +5 -0
- data/app/views/effective/learndash_courses/show.html.haml +6 -0
- data/config/effective_learndash.rb +9 -0
- data/config/routes.rb +13 -3
- data/db/migrate/01_create_effective_learndash.rb.erb +98 -33
- data/lib/effective_learndash/engine.rb +1 -0
- data/lib/effective_learndash/version.rb +1 -1
- data/lib/effective_learndash.rb +6 -1
- data/lib/generators/effective_learndash/install_generator.rb +0 -1
- metadata +33 -4
| @@ -3,22 +3,88 @@ module Effective | |
| 3 3 | 
             
                has_many :learndash_enrollments
         | 
| 4 4 | 
             
                has_many :learndash_users, through: :learndash_enrollments
         | 
| 5 5 |  | 
| 6 | 
            +
                log_changes if respond_to?(:log_changes)
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                # rich_text_body - Used by the select step
         | 
| 9 | 
            +
                has_many_rich_texts
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                # rich_text_body
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                # rich_text_all_steps_content
         | 
| 14 | 
            +
                # rich_text_start_content
         | 
| 15 | 
            +
                # rich_text_select_content
         | 
| 16 | 
            +
                # rich_text_select_content
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                acts_as_slugged
         | 
| 19 | 
            +
                log_changes if respond_to?(:log_changes)
         | 
| 20 | 
            +
                acts_as_role_restricted if respond_to?(:acts_as_role_restricted)
         | 
| 21 | 
            +
             | 
| 6 22 | 
             
                effective_resource do
         | 
| 7 23 | 
             
                  # This user the wordpress credentials
         | 
| 8 | 
            -
                  course_id | 
| 9 | 
            -
                   | 
| 10 | 
            -
                   | 
| 24 | 
            +
                  course_id             :integer
         | 
| 25 | 
            +
                  title                 :string
         | 
| 26 | 
            +
                  status                :string
         | 
| 27 | 
            +
             | 
| 28 | 
            +
                  # Our attributes
         | 
| 29 | 
            +
                  slug                   :string
         | 
| 30 | 
            +
             | 
| 31 | 
            +
                  # For course purchases
         | 
| 32 | 
            +
                  can_register           :boolean
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  # Pricing
         | 
| 35 | 
            +
                  regular_price         :integer
         | 
| 36 | 
            +
                  member_price          :integer
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                  qb_item_name          :string
         | 
| 39 | 
            +
                  tax_exempt            :boolean
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  # Access
         | 
| 42 | 
            +
                  roles_mask             :integer
         | 
| 43 | 
            +
                  authenticate_user      :boolean
         | 
| 11 44 |  | 
| 12 45 | 
             
                  timestamps
         | 
| 13 46 | 
             
                end
         | 
| 14 47 |  | 
| 15 48 | 
             
                scope :deep, -> { all }
         | 
| 16 49 | 
             
                scope :sorted, -> { order(:title) }
         | 
| 50 | 
            +
                scope :registerable, -> { where(can_register: true) }
         | 
| 51 | 
            +
                scope :published, -> { all }
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                scope :paginate, -> (page: nil, per_page: nil) {
         | 
| 54 | 
            +
                  page = (page || 1).to_i
         | 
| 55 | 
            +
                  offset = [(page - 1), 0].max * (per_page || EffectiveLearndash.per_page)
         | 
| 56 | 
            +
             | 
| 57 | 
            +
                  limit(per_page).offset(offset)
         | 
| 58 | 
            +
                }
         | 
| 59 | 
            +
             | 
| 60 | 
            +
                scope :learndash_courses, -> (user: nil, unpublished: false) {
         | 
| 61 | 
            +
                  scope = all.deep.sorted
         | 
| 62 | 
            +
             | 
| 63 | 
            +
                  if defined?(EffectiveRoles) && EffectiveLearndash.use_effective_roles
         | 
| 64 | 
            +
                    scope = scope.for_role(user&.roles)
         | 
| 65 | 
            +
                  end
         | 
| 66 | 
            +
             | 
| 67 | 
            +
                  if user.blank?
         | 
| 68 | 
            +
                    scope = scope.where(authenticate_user: false)
         | 
| 69 | 
            +
                  end
         | 
| 70 | 
            +
             | 
| 71 | 
            +
                  # TODO
         | 
| 72 | 
            +
                  # unless unpublished
         | 
| 73 | 
            +
                  #   scope = scope.published
         | 
| 74 | 
            +
                  # end
         | 
| 75 | 
            +
             | 
| 76 | 
            +
                  scope
         | 
| 77 | 
            +
                }
         | 
| 17 78 |  | 
| 18 79 | 
             
                validates :course_id, presence: true
         | 
| 19 80 | 
             
                validates :status, presence: true
         | 
| 20 81 | 
             
                validates :title, presence: true
         | 
| 21 82 |  | 
| 83 | 
            +
                with_options(if: -> { can_register? }) do
         | 
| 84 | 
            +
                  validates :regular_price, presence: true
         | 
| 85 | 
            +
                  validates :member_price, presence: true
         | 
| 86 | 
            +
                end
         | 
| 87 | 
            +
             | 
| 22 88 | 
             
                # Syncs all courses
         | 
| 23 89 | 
             
                def self.refresh!
         | 
| 24 90 | 
             
                  courses = all()
         | 
| @@ -35,5 +101,14 @@ module Effective | |
| 35 101 | 
             
                  title.presence || 'learndash course'
         | 
| 36 102 | 
             
                end
         | 
| 37 103 |  | 
| 104 | 
            +
                def body
         | 
| 105 | 
            +
                  rich_text_body
         | 
| 106 | 
            +
                end
         | 
| 107 | 
            +
             | 
| 108 | 
            +
                # Todo
         | 
| 109 | 
            +
                def draft?
         | 
| 110 | 
            +
                  false
         | 
| 111 | 
            +
                end
         | 
| 112 | 
            +
             | 
| 38 113 | 
             
              end
         | 
| 39 114 | 
             
            end
         | 
| @@ -1,11 +1,11 @@ | |
| 1 1 | 
             
            module Effective
         | 
| 2 2 | 
             
              class LearndashEnrollment < ActiveRecord::Base
         | 
| 3 3 | 
             
                belongs_to :owner, polymorphic: true
         | 
| 4 | 
            -
                log_changes(to: :owner) if respond_to?(:log_changes)
         | 
| 5 | 
            -
             | 
| 6 4 | 
             
                belongs_to :learndash_course
         | 
| 7 5 | 
             
                belongs_to :learndash_user
         | 
| 8 6 |  | 
| 7 | 
            +
                log_changes(to: :learndash_course, except: [:last_synced_at]) if respond_to?(:log_changes)
         | 
| 8 | 
            +
             | 
| 9 9 | 
             
                PROGRESS_STATUSES = ['not-started', 'in-progress', 'completed']
         | 
| 10 10 |  | 
| 11 11 | 
             
                effective_resource do
         | 
| @@ -58,7 +58,11 @@ module Effective | |
| 58 58 | 
             
                  progress_status == 'completed'
         | 
| 59 59 | 
             
                end
         | 
| 60 60 |  | 
| 61 | 
            -
                def refresh!
         | 
| 61 | 
            +
                def refresh!(force: false)
         | 
| 62 | 
            +
                  unless force
         | 
| 63 | 
            +
                    return if last_synced_at.present? && (Time.zone.now - last_synced_at) < 5
         | 
| 64 | 
            +
                  end
         | 
| 65 | 
            +
             | 
| 62 66 | 
             
                  assign_api_attributes
         | 
| 63 67 | 
             
                  save!
         | 
| 64 68 | 
             
                end
         | 
| @@ -44,13 +44,12 @@ module Effective | |
| 44 44 | 
             
                  owner&.to_s || username.presence || 'learndash user'
         | 
| 45 45 | 
             
                end
         | 
| 46 46 |  | 
| 47 | 
            -
                def  | 
| 48 | 
            -
                   | 
| 49 | 
            -
             | 
| 50 | 
            -
             | 
| 51 | 
            -
             | 
| 47 | 
            +
                def refresh!(force: false)
         | 
| 48 | 
            +
                  unless force
         | 
| 49 | 
            +
                    return if last_synced_at.present? && (Time.zone.now - last_synced_at) < 5
         | 
| 50 | 
            +
                    return if learndash_enrollments.none? { |enrollment| !enrollment.completed? }
         | 
| 51 | 
            +
                  end
         | 
| 52 52 |  | 
| 53 | 
            -
                def refresh!
         | 
| 54 53 | 
             
                  assign_api_course_enrollments
         | 
| 55 54 | 
             
                  save!
         | 
| 56 55 | 
             
                end
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            = tabs do
         | 
| 2 | 
            +
              = tab "Learndash Course" do
         | 
| 3 | 
            +
                = render 'admin/learndash_courses/form_learndash_course', learndash_course: learndash_course
         | 
| 4 | 
            +
             | 
| 5 | 
            +
              - if learndash_course.persisted?
         | 
| 6 | 
            +
                = tab 'Enrollments' do
         | 
| 7 | 
            +
                  %h2 Enrollments
         | 
| 8 | 
            +
                  %p Click the New button from the below table to enroll a user into this course.
         | 
| 9 | 
            +
                  %p Enrolling a user here will enroll them on the LearnDash site.
         | 
| 10 | 
            +
                  %p Alternately, if this course is available for registration, the enrollment will be created upon registration purchase.
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  - datatable = Admin::EffectiveLearndashEnrollmentsDatatable.new(learndash_course: learndash_course)
         | 
| 13 | 
            +
                  = render_datatable(datatable, inline: true)
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                = tab 'Registrations' do
         | 
| 16 | 
            +
                  %h2 Purchases
         | 
| 17 | 
            +
                  - datatable = Admin::EffectiveCourseRegistrationsDatatable.new(learndash_course: learndash_course)
         | 
| 18 | 
            +
                  = render_inline_datatable(datatable)
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                = tab 'Wizard' do
         | 
| 21 | 
            +
                  = render '/admin/learndash_courses/form_course_registration_content', learndash_course: learndash_course
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                - if learndash_course.respond_to?(:log_changes_datatable)
         | 
| 24 | 
            +
                  = tab "Logs" do
         | 
| 25 | 
            +
                    = render_inline_datatable(learndash_course.log_changes_datatable)
         | 
| @@ -0,0 +1,19 @@ | |
| 1 | 
            +
            %p Each of the following content areas will be displayed on the course purchase wizard.
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            = effective_form_with(model: [:admin, learndash_course], engine: true) do |f|
         | 
| 4 | 
            +
              = card("All Steps") do
         | 
| 5 | 
            +
                = f.rich_text_area "rich_text_all_steps_content", label: false,
         | 
| 6 | 
            +
                  hint: "displayed on all steps"
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              %hr
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              - enabled = EffectiveLearndash.CourseRegistration.all_wizard_steps
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              - EffectiveLearndash.CourseRegistration::WIZARD_STEPS.each do |step, title|
         | 
| 13 | 
            +
                - next unless enabled.include?(step)
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                = card("#{title}") do
         | 
| 16 | 
            +
                  = f.rich_text_area "rich_text_#{step}_content", label: false,
         | 
| 17 | 
            +
                    hint: "displayed on the course purchase wizard #{step} wizard step only"
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              = f.submit
         | 
| @@ -0,0 +1,32 @@ | |
| 1 | 
            +
            = effective_form_with(model: [:admin, learndash_course], engine: true) do |f|
         | 
| 2 | 
            +
              = f.static_field :title
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              = f.static_field :learndash_course_url do
         | 
| 5 | 
            +
                = link_to(learndash_course.link, learndash_course.link, target: '_blank')
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              = f.static_field :learndash_course_admin do
         | 
| 8 | 
            +
                = link_to "Learndash LMS Course Admin", EffectiveLearndash.learndash_url.chomp('/') + "/wp-admin/post.php?post=#{learndash_course.course_id}&action=edit", target: '_blank'
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              - if f.object.persisted? || f.object.errors.include?(:slug)
         | 
| 11 | 
            +
                - current_url = (effective_learndash.learndash_course_url(f.object) rescue nil)
         | 
| 12 | 
            +
                = f.text_field :slug, hint: "The slug controls this course's internet address. Be careful, changing the slug will break links that other websites may have to the old address.<br>#{('This course is currently reachable via ' + link_to(current_url.gsub(f.object.slug, '<strong>' + f.object.slug + '</strong>').html_safe, current_url)) if current_url }".html_safe
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              = f.check_box :can_register, label: 'Yes, this course is displayed and available for registration'
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              = f.show_if :can_register, true do
         | 
| 17 | 
            +
                = card('Pricing Information') do
         | 
| 18 | 
            +
                  %p.text-muted
         | 
| 19 | 
            +
                    Charge the following amounts during course registration. Enter $0 for free.
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                  .row
         | 
| 22 | 
            +
                    .col-lg-3= f.price_field :regular_price, label: 'Price to applicants or new users'
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  .row
         | 
| 25 | 
            +
                    .col-lg-3= f.price_field :member_price, label: 'Price to existing members'
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                  = f.check_box :tax_exempt
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  .row
         | 
| 30 | 
            +
                    .col-lg-3= f.text_field :qb_item_name, label: "Quickbooks Item Name"
         | 
| 31 | 
            +
             | 
| 32 | 
            +
              = f.submit
         | 
| @@ -1,10 +1,10 @@ | |
| 1 | 
            -
            = card(' | 
| 1 | 
            +
            = card('LearnDash Course') do
         | 
| 2 2 | 
             
              %p= learndash_course.title
         | 
| 3 3 | 
             
              %p= link_to(learndash_course.link, learndash_course.link, target: '_blank')
         | 
| 4 4 |  | 
| 5 | 
            -
              %p= link_to " | 
| 5 | 
            +
              %p= link_to "LearnDash LMS Course Admin", EffectiveLearndash.learndash_url.chomp('/') + "/wp-admin/post.php?post=#{learndash_course.course_id}}&action=edit", target: '_blank'
         | 
| 6 6 |  | 
| 7 | 
            -
            %h3  | 
| 7 | 
            +
            %h3 LearnDash User Enrollments
         | 
| 8 8 |  | 
| 9 9 | 
             
            %p Click the New button from the below table to enroll a user into this course.
         | 
| 10 10 |  | 
| @@ -1,5 +1,5 @@ | |
| 1 1 | 
             
            - if owner.learndash_user.blank?
         | 
| 2 | 
            -
              %p #{owner} does not yet have an account on  | 
| 2 | 
            +
              %p #{owner} does not yet have an account on LearnDash.
         | 
| 3 3 |  | 
| 4 4 | 
             
            - if owner.learndash_user.present?
         | 
| 5 5 | 
             
              = render('admin/learndash_users/learndash_user', learndash_user: owner.learndash_user)
         | 
| @@ -1,6 +1,6 @@ | |
| 1 1 | 
             
            = effective_form_with(model: [:admin, learndash_user], engine: true) do |f|
         | 
| 2 2 |  | 
| 3 3 | 
             
              = f.select :owner, {'Owners' => current_user.class.sorted }, polymorphic: true,
         | 
| 4 | 
            -
                hint: 'Create a  | 
| 4 | 
            +
                hint: 'Create a LearnDash account for this user'
         | 
| 5 5 |  | 
| 6 6 | 
             
              = f.submit
         | 
| @@ -1,19 +1,19 @@ | |
| 1 | 
            -
            = card(' | 
| 1 | 
            +
            = card('LearnDash') do
         | 
| 2 2 | 
             
              %p
         | 
| 3 3 | 
             
                = link_to(learndash_user.owner, "/admin/users/#{learndash_user.owner.to_param}/edit")
         | 
| 4 | 
            -
                has an existing account on  | 
| 4 | 
            +
                has an existing account on LearnDash.
         | 
| 5 5 |  | 
| 6 6 | 
             
              %ul
         | 
| 7 7 | 
             
                %li Email: #{learndash_user.email}
         | 
| 8 8 | 
             
                %li Username: #{learndash_user.username}
         | 
| 9 9 | 
             
                %li Password: #{learndash_user.password}
         | 
| 10 10 |  | 
| 11 | 
            -
              %p= link_to " | 
| 11 | 
            +
              %p= link_to "LearnDash LMS User Admin", EffectiveLearndash.learndash_url.chomp('/') + "/wp-admin/user-edit.php?user_id=#{learndash_user.user_id}", target: '_blank'
         | 
| 12 12 |  | 
| 13 13 | 
             
              %p
         | 
| 14 14 | 
             
                %small Last refreshed #{time_ago_in_words(learndash_user.last_synced_at)} ago.
         | 
| 15 15 |  | 
| 16 | 
            -
            %h3  | 
| 16 | 
            +
            %h3 LearnDash Course Enrollments
         | 
| 17 17 |  | 
| 18 18 | 
             
            %p Click the New button from the below table to manually enroll this user into a new course.
         | 
| 19 19 |  | 
| @@ -0,0 +1,10 @@ | |
| 1 | 
            +
            - all_steps_content = resource.learndash_course&.rich_text_all_steps_content
         | 
| 2 | 
            +
            - step_content = resource.learndash_course&.send("rich_text_#{step}_content")
         | 
| 3 | 
            +
             | 
| 4 | 
            +
            - if all_steps_content.present?
         | 
| 5 | 
            +
              .card.mb-4
         | 
| 6 | 
            +
                .card-body= all_steps_content
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            - if step_content.present?
         | 
| 9 | 
            +
              .card.mb-4
         | 
| 10 | 
            +
                .card-body= step_content
         | 
| @@ -0,0 +1,9 @@ | |
| 1 | 
            +
            = card do
         | 
| 2 | 
            +
              .row
         | 
| 3 | 
            +
                .col-sm
         | 
| 4 | 
            +
                  %h5.card-title= course_registration.wizard_step_title(:course)
         | 
| 5 | 
            +
                .col-sm-auto.text-right
         | 
| 6 | 
            +
                  = link_to('Edit', wizard_path(:course)) if edit_effective_wizard?
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              - datatable = EffectiveCourseRegistrantsDatatable.new(course_registration: course_registration)
         | 
| 9 | 
            +
              .mb-4= render_simple_datatable(datatable)
         | 
| @@ -0,0 +1,30 @@ | |
| 1 | 
            +
            -# In progress course purchase
         | 
| 2 | 
            +
            - wizard = EffectiveLearndash.CourseRegistration.in_progress.for(current_user).first
         | 
| 3 | 
            +
            - datatable = EffectiveResources.best('EffectiveCourseRegistrationsDatatable').new(self, namespace: :effective)
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            - if wizard.present?
         | 
| 6 | 
            +
              %h2 In Progress Course Registrations
         | 
| 7 | 
            +
             | 
| 8 | 
            +
              %p
         | 
| 9 | 
            +
                Your course registration for
         | 
| 10 | 
            +
                = link_to(wizard.learndash_course, effective_learndash.learndash_course_path(wizard.learndash_course))
         | 
| 11 | 
            +
                is incomplete
         | 
| 12 | 
            +
             | 
| 13 | 
            +
              %p
         | 
| 14 | 
            +
                Please
         | 
| 15 | 
            +
                = link_to("Continue registration for #{wizard.learndash_course}", effective_learndash.learndash_course_course_registration_build_path(wizard.learndash_course, wizard, wizard.next_step), 'data-turbolinks' => false, class: 'btn btn-primary')
         | 
| 16 | 
            +
                or you can
         | 
| 17 | 
            +
                = link_to('Abandon course registration', effective_learndash.learndash_course_course_registration_path(wizard.learndash_course, wizard), 'data-confirm': "Really delete #{wizard}?", 'data-method': :delete, class: 'btn btn-danger')
         | 
| 18 | 
            +
                to register for another course.
         | 
| 19 | 
            +
             | 
| 20 | 
            +
              %hr
         | 
| 21 | 
            +
             | 
| 22 | 
            +
            %h2 Course Registrations
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            - if datatable.present?
         | 
| 25 | 
            +
              = render_simple_datatable(datatable)
         | 
| 26 | 
            +
            - else
         | 
| 27 | 
            +
              %p You have no past course registrations. When you do, we'll show them here.
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            - if false
         | 
| 30 | 
            +
              %p= link_to 'View all Course', effective_learndash.learndash_courses_path, class: 'btn btn-primary'
         | 
| @@ -0,0 +1,39 @@ | |
| 1 | 
            +
            = card('Course Registration') do
         | 
| 2 | 
            +
              %table.table.table-sm
         | 
| 3 | 
            +
                %tbody
         | 
| 4 | 
            +
                  %tr
         | 
| 5 | 
            +
                    %th.border-0 Course
         | 
| 6 | 
            +
                    %td.border-0
         | 
| 7 | 
            +
                      %p
         | 
| 8 | 
            +
                        %strong=course_registration.course
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                      - learndash_user = course_registration.learndash_owner.learndash_user
         | 
| 11 | 
            +
                      %p Your course account credentials are:
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                      %ul
         | 
| 14 | 
            +
                        %li
         | 
| 15 | 
            +
                          %strong Username:
         | 
| 16 | 
            +
                          #{learndash_user.username}
         | 
| 17 | 
            +
                        %li
         | 
| 18 | 
            +
                          %strong Password:
         | 
| 19 | 
            +
                          #{learndash_user.password}
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                      %p= link_to('Sign in to your course account', EffectiveLearndash.learndash_url, target: '_blank', class: 'btn btn-primary mb-2')
         | 
| 22 | 
            +
             | 
| 23 | 
            +
                  - if request.path.start_with?('/admin')
         | 
| 24 | 
            +
                    %tr
         | 
| 25 | 
            +
                      %th Registered by
         | 
| 26 | 
            +
                      %td
         | 
| 27 | 
            +
                        - url = (polymorphic_admin_path(course_registration.owner) rescue "/admin/users/#{course_registration.owner.to_param}/edit")
         | 
| 28 | 
            +
                        = link_to(course_registration.owner, url)
         | 
| 29 | 
            +
                  - else
         | 
| 30 | 
            +
                    %tr
         | 
| 31 | 
            +
                      %th Registered by
         | 
| 32 | 
            +
                      %td= course_registration.owner
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  - if course_registration.orders.present?
         | 
| 35 | 
            +
                    %tr
         | 
| 36 | 
            +
                      %th Order
         | 
| 37 | 
            +
                      %td
         | 
| 38 | 
            +
                        - course_registration.orders.each do |order|
         | 
| 39 | 
            +
                          = link_to(order, effective_orders.order_path(order))
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            = render 'layout' do
         | 
| 2 | 
            +
              = render 'effective/course_registrations/content', resource: resource
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              - raise('expected owner to respond to billing_address') unless resource.owner.respond_to?(:billing_address)
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              = card('Billing Address') do
         | 
| 7 | 
            +
                %p Please enter your billing address
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                = effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
         | 
| 10 | 
            +
                  = f.hidden_field :id
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  = f.fields_for(:owner, f.object.owner) do |fu|
         | 
| 13 | 
            +
                    = effective_address_fields(fu, :billing)
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                  = f.save 'Save and Continue'
         | 
| @@ -0,0 +1,6 @@ | |
| 1 | 
            +
            = render 'layout' do
         | 
| 2 | 
            +
              = render 'effective/course_registrations/content', resource: resource
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              .card
         | 
| 5 | 
            +
                .card-body
         | 
| 6 | 
            +
                  = render_checkout_step2(resource.submit_order, purchased_url: wizard_path(:submitted), deferred_url: wizard_path(:checkout), declined_url: wizard_path(:checkout))
         | 
| @@ -0,0 +1,20 @@ | |
| 1 | 
            +
            = render 'layout' do
         | 
| 2 | 
            +
              = render 'effective/course_registrations/content', resource: resource
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              = card('Course') do
         | 
| 5 | 
            +
                %p= resource.learndash_course
         | 
| 6 | 
            +
                %p= price_to_currency(resource.registration_price)
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                = effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
         | 
| 9 | 
            +
                  = f.hidden_field :id
         | 
| 10 | 
            +
             | 
| 11 | 
            +
                  = f.fields_for :course_registrants, (f.object.course_registrant || f.object.build_course_registrant) do |fr|
         | 
| 12 | 
            +
                    = fr.hidden_field :course_registration_id
         | 
| 13 | 
            +
                    = fr.hidden_field :course_registration_type
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                    = fr.hidden_field :owner_id
         | 
| 16 | 
            +
                    = fr.hidden_field :owner_type
         | 
| 17 | 
            +
             | 
| 18 | 
            +
                    = fr.hidden_field :learndash_course_id
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  = f.save 'Save and Continue'
         | 
| @@ -0,0 +1,25 @@ | |
| 1 | 
            +
            = render 'layout' do
         | 
| 2 | 
            +
              = render 'effective/course_registrations/content', resource: resource
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              .card
         | 
| 5 | 
            +
                .card-body
         | 
| 6 | 
            +
                  %p Welcome #{current_user}!
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  %p You are registering for #{resource.course}.
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  - existing = resource.owner.learndash_user&.enrollment(course: resource.course)
         | 
| 11 | 
            +
             | 
| 12 | 
            +
                  - if existing.present?
         | 
| 13 | 
            +
                    .alert.alert-warning
         | 
| 14 | 
            +
                      You are already enrolled in #{link_to(resource.course, EffectiveLearndash.learndash_url, target: '_blank')}.
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                  - if existing.blank?
         | 
| 17 | 
            +
                    = effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
         | 
| 18 | 
            +
                      = f.hidden_field :id
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                      = f.hidden_field :learndash_course_id
         | 
| 21 | 
            +
             | 
| 22 | 
            +
                      = f.hidden_field :owner_type
         | 
| 23 | 
            +
                      = f.hidden_field :owner_id
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                      = f.save 'Save and Continue'
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            = render 'layout' do
         | 
| 2 | 
            +
              = render 'effective/course_registrations/content', resource: resource
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              - raise('expected a submitted course_registration') unless resource.was_submitted?
         | 
| 5 | 
            +
              - raise('expected a purchased course_registration submit_order') unless resource.submit_order&.purchased?
         | 
| 6 | 
            +
             | 
| 7 | 
            +
              .alert.alert-warning.mb-4
         | 
| 8 | 
            +
                Successfully paid on #{resource.submit_order.purchased_at.strftime('%F')}.
         | 
| 9 | 
            +
             | 
| 10 | 
            +
              = link_to "Return to Dashboard", root_path, class: 'btn btn-lg btn-primary mb-4'
         | 
| 11 | 
            +
             | 
| 12 | 
            +
              = render 'effective/course_registrations/summary', course_registration: resource
         | 
| 13 | 
            +
              = render 'effective/course_registrations/orders', course_registration: resource
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              = link_to "Return to Dashboard", root_path, class: 'btn btn-lg btn-primary'
         | 
| @@ -0,0 +1,8 @@ | |
| 1 | 
            +
            = render 'layout' do
         | 
| 2 | 
            +
              = render 'effective/course_registrations/content', resource: resource
         | 
| 3 | 
            +
             | 
| 4 | 
            +
              = render('effective/course_registrations/course_registration', course_registration: resource)
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              = effective_form_with(model: resource, url: wizard_path(step), method: :put) do |f|
         | 
| 7 | 
            +
                = f.hidden_field :id
         | 
| 8 | 
            +
                = f.submit 'Save and Continue', class: 'btn btn-primary'
         | 
| @@ -1,31 +1,29 @@ | |
| 1 1 | 
             
            - learndash_user = current_user.try(:learndash_user)
         | 
| 2 2 | 
             
            - authorized = learndash_user && EffectiveResources.authorized?(self, :show, learndash_user)
         | 
| 3 3 |  | 
| 4 | 
            -
            %h2  | 
| 4 | 
            +
            %h2 Courses
         | 
| 5 5 |  | 
| 6 6 | 
             
            - if learndash_user.blank?
         | 
| 7 | 
            -
              %p You do not have a  | 
| 8 | 
            -
             | 
| 9 | 
            -
            - if learndash_user.present?
         | 
| 10 | 
            -
              %p
         | 
| 11 | 
            -
                = succeed('.') do
         | 
| 12 | 
            -
                  You have an existing account on
         | 
| 13 | 
            -
                  = link_to('Learndash', EffectiveLearndash.learndash_url, target: '_blank')
         | 
| 7 | 
            +
              %p You do not have an account to access courses. When you are enrolled in a course, your account credentials will be displayed here.
         | 
| 14 8 |  | 
| 15 9 | 
             
            - if learndash_user.present? && authorized
         | 
| 16 | 
            -
              - learndash_user. | 
| 10 | 
            +
              - learndash_user.refresh!
         | 
| 17 11 |  | 
| 18 | 
            -
              %p  | 
| 12 | 
            +
              %p Your course account credentials are:
         | 
| 19 13 |  | 
| 20 14 | 
             
              %ul
         | 
| 21 | 
            -
                %li | 
| 22 | 
            -
             | 
| 23 | 
            -
             | 
| 15 | 
            +
                %li
         | 
| 16 | 
            +
                  %strong Username:
         | 
| 17 | 
            +
                  #{learndash_user.username}
         | 
| 18 | 
            +
                %li
         | 
| 19 | 
            +
                  %strong Password:
         | 
| 20 | 
            +
                  #{learndash_user.password}
         | 
| 24 21 |  | 
| 25 | 
            -
               | 
| 26 | 
            -
                %p You are enrolled in #{pluralize(learndash_user.learndash_enrollments.length, 'course')}.
         | 
| 22 | 
            +
              %p= link_to('Sign in to your course account', EffectiveLearndash.learndash_url, target: '_blank', class: 'btn btn-primary')
         | 
| 27 23 |  | 
| 24 | 
            +
              - if learndash_user.learndash_enrollments.present?
         | 
| 28 25 | 
             
                - datatable = EffectiveResources.best('EffectiveLearndashEnrollmentsDatatable').new(self)
         | 
| 29 26 | 
             
                = render_datatable(datatable, simple: true)
         | 
| 27 | 
            +
             | 
| 30 28 | 
             
              - else
         | 
| 31 | 
            -
                You are not enrolled in any  | 
| 29 | 
            +
                %p You are not enrolled in any courses.
         | 
| @@ -0,0 +1,13 @@ | |
| 1 | 
            +
            %table.table.effective-learndash-courses-table
         | 
| 2 | 
            +
              %tbody
         | 
| 3 | 
            +
                %tr
         | 
| 4 | 
            +
                  %th Regular Price
         | 
| 5 | 
            +
                  %td= price_to_currency(learndash_course.regular_price)
         | 
| 6 | 
            +
                %tr
         | 
| 7 | 
            +
                  %th Discounted Price
         | 
| 8 | 
            +
                  %td= price_to_currency(learndash_course.member_price)
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                - if learndash_course.body.present?
         | 
| 11 | 
            +
                  %tr
         | 
| 12 | 
            +
                    %th Description
         | 
| 13 | 
            +
                    %td= learndash_course.body
         | 
| @@ -0,0 +1,6 @@ | |
| 1 | 
            +
            .effective-learndash-course
         | 
| 2 | 
            +
              - if @learndash_course.registerable?
         | 
| 3 | 
            +
                .resource-buttons
         | 
| 4 | 
            +
                  = link_to 'Register', effective_learndash.new_learndash_course_course_registration_path(@learndash_course), class: 'btn btn-primary'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
              = render 'effective/learndash_courses/learndash_course', learndash_course: @learndash_course
         | 
| @@ -15,4 +15,13 @@ EffectiveLearndash.setup do |config| | |
| 15 15 | 
             
              # Usernames can only contain lowercase letters (a-z) and numbers.
         | 
| 16 16 | 
             
              # config.wp_username = Proc.new { |user| "user#{user.id}" }
         | 
| 17 17 | 
             
              # config.wp_password = Proc.new { |user| SecureRandom.base64(12) }
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              # Course Purchase Wizard Settings
         | 
| 20 | 
            +
              # config.course_registration_class_name = 'Effective::CourseRegistration'
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              # Pagination length on the Events#index page
         | 
| 23 | 
            +
              config.per_page = 10
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              # Events can be restricted by role
         | 
| 26 | 
            +
              config.use_effective_roles = true
         | 
| 18 27 | 
             
            end
         | 
    
        data/config/routes.rb
    CHANGED
    
    | @@ -5,10 +5,19 @@ Rails.application.routes.draw do | |
| 5 5 | 
             
            end
         | 
| 6 6 |  | 
| 7 7 | 
             
            EffectiveLearndash::Engine.routes.draw do
         | 
| 8 | 
            +
              # Public routes
         | 
| 9 | 
            +
              scope module: 'effective' do
         | 
| 10 | 
            +
                resources :learndash_courses, only: [:index] do
         | 
| 11 | 
            +
                  resources :course_registrations, only: [:new, :show, :destroy] do
         | 
| 12 | 
            +
                    resources :build, controller: :course_registrations, only: [:show, :update]
         | 
| 13 | 
            +
                  end
         | 
| 14 | 
            +
                end
         | 
| 15 | 
            +
              end
         | 
| 16 | 
            +
             | 
| 8 17 | 
             
              namespace :admin do
         | 
| 9 18 | 
             
                get '/learndash', to: 'learndash#index', as: :learndash
         | 
| 10 19 |  | 
| 11 | 
            -
                resources :learndash_users,  | 
| 20 | 
            +
                resources :learndash_users, except: [:edit, :destroy] do
         | 
| 12 21 | 
             
                  post :refresh, on: :member
         | 
| 13 22 | 
             
                end
         | 
| 14 23 |  | 
| @@ -16,10 +25,11 @@ EffectiveLearndash::Engine.routes.draw do | |
| 16 25 | 
             
                  post :refresh, on: :member
         | 
| 17 26 | 
             
                end
         | 
| 18 27 |  | 
| 19 | 
            -
                resources :learndash_courses, only: [:index, : | 
| 28 | 
            +
                resources :learndash_courses, only: [:index, :edit, :update] do
         | 
| 20 29 | 
             
                  get :refresh, on: :collection
         | 
| 21 30 | 
             
                end
         | 
| 22 31 |  | 
| 32 | 
            +
                resources :course_registrants, only: [:index]
         | 
| 33 | 
            +
                resources :course_registrations, only: [:index, :show]
         | 
| 23 34 | 
             
              end
         | 
| 24 | 
            -
             | 
| 25 35 | 
             
            end
         |