effective_learndash 0.1.1 → 0.1.2

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: f10afce8560043990198e9b364944ce9ed5d50f4c97f0a070074fa58a2e56014
4
- data.tar.gz: b4f516fcd3ceac21941a5db7e7bb8a43766608bba652998dd5f6677c74b3eccc
3
+ metadata.gz: be4c40ac53a2b543a2ec07ef72b03c9a99c299c1a791c07e41b8d7293bf14aac
4
+ data.tar.gz: 317aae5636eab574dba9dcf5b05c8d5739b971d7f8b7c4b55e5b22acad2a1f99
5
5
  SHA512:
6
- metadata.gz: 7b2d11bce9c397f42f95b823003530eedfe21feb80fa08a28d04c92272085906812b9dcf2685b798a171262ae1054661535394246e7374a7f5f3dcd941d4e939
7
- data.tar.gz: 1eef5bd56979080599f509b17df4835370fc392d0eded403d39091b0d3974846e9462ed215df69835158d4c0e0d3dad7bc2bea9b9f8160ae34875179522268f9
6
+ metadata.gz: 3a3c2d3e21f8c26f4fa36e46540d18d725b0f7f82a32b4ff066ef1eaa722fbed716ae8191e890bd343c8622493c099169bcda4d655916cd1a8edab938a26b940
7
+ data.tar.gz: 923e01c208aae2cdd5d77f7729f08f69cc319bf29996bfbcf1d4a47b50da57654d600864cce1f474781e5c6328b32076d47c8dc28fcaf380aacb01751ca1c5d9
data/README.md CHANGED
@@ -71,6 +71,9 @@ All authorization checks are handled via the effective_resources gem found in th
71
71
  The permissions you actually want to define are as follows (using CanCan):
72
72
 
73
73
  ```ruby
74
+ can(:show, Effective::LearndashUser) { |lduser| lduser.owner_id == user.id }
75
+ can(:index, Effective::LearndashEnrollment)
76
+
74
77
  if user.admin?
75
78
  can :admin, :effective_learndash
76
79
 
@@ -10,6 +10,17 @@ class EffectiveLearndashEnrollmentsDatatable < Effective::Datatable
10
10
 
11
11
  col :date_started, as: :date
12
12
  col :date_completed, as: :date
13
+
14
+ actions_col(show: false) do |enrollment|
15
+ if enrollment.not_started?
16
+ dropdown_link_to('Start', EffectiveLearndash.learndash_url, target: '_blank')
17
+ elsif enrollment.in_progress?
18
+ dropdown_link_to('Continue', EffectiveLearndash.learndash_url, target: '_blank')
19
+ else
20
+ dropdown_link_to('Show', EffectiveLearndash.learndash_url, target: '_blank')
21
+ end
22
+ end
23
+
13
24
  end
14
25
 
15
26
  collection do
@@ -46,6 +46,14 @@ module Effective
46
46
  persisted? ? "#{learndash_user} #{learndash_course}" : 'learndash enrollment'
47
47
  end
48
48
 
49
+ def not_started?
50
+ progress_status == 'not-started'
51
+ end
52
+
53
+ def in_progress?
54
+ progress_status == 'in-progress'
55
+ end
56
+
49
57
  def completed?
50
58
  progress_status == 'completed'
51
59
  end
@@ -1,4 +1,5 @@
1
1
  - learndash_user = current_user.try(:learndash_user)
2
+ - authorized = learndash_user && EffectiveResources.authorized?(self, :show, learndash_user)
2
3
 
3
4
  %h2 Learndash Courses
4
5
 
@@ -6,20 +7,22 @@
6
7
  %p You do not have a Learndash account.
7
8
 
8
9
  - if learndash_user.present?
9
- - # This queries the API
10
- - learndash_user.check_and_refresh!
11
-
12
10
  %p
13
11
  = succeed('.') do
14
12
  You have an existing account on
15
- = link_to('Learndash', EffectiveLearndash.learndash_url.chomp('/'), target: '_blank')
13
+ = link_to('Learndash', EffectiveLearndash.learndash_url, target: '_blank')
14
+
15
+ - if learndash_user.present? && authorized
16
+ - learndash_user.check_and_refresh!
17
+
18
+ %p Please sign into Learndash with the following credentials:
16
19
 
17
20
  %ul
18
21
  %li Email: #{learndash_user.email}
19
22
  %li Username: #{learndash_user.username}
20
23
  %li Password: #{learndash_user.password}
21
24
 
22
- - if learndash_user&.learndash_enrollments.present?
25
+ - if learndash_user.learndash_enrollments.present?
23
26
  %p You are enrolled in #{pluralize(learndash_user.learndash_enrollments.length, 'course')}.
24
27
 
25
28
  - datatable = EffectiveResources.best('EffectiveLearndashEnrollmentsDatatable').new(self)
@@ -1,3 +1,3 @@
1
1
  module EffectiveLearndash
2
- VERSION = '0.1.1'.freeze
2
+ VERSION = '0.1.2'.freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_learndash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect