think_feel_do_engine 3.19.7 → 3.19.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
  SHA1:
3
- metadata.gz: ae2ac67360cf4936becc3201ca3116aa5a2746a6
4
- data.tar.gz: 6014a2de830f98bd3a06736f46b528184bd8e185
3
+ metadata.gz: 44490ab377c55a5697d0f9cd55455ef8dbd7e365
4
+ data.tar.gz: 97c16cd8be6225e6527fa30bc7cf50663e5f7213
5
5
  SHA512:
6
- metadata.gz: ab49783f7ad4d0feaa1693cd618dcd4157eca182b13f51e2569a37f881f3e3f28fe8ea6917b61d1d5abab8928de922f2c35cbe9554625dd3aa1bec29adc45da1
7
- data.tar.gz: 64611db3bd1672d9607c30d6fd26ecbe41647af500c1837ea23fa8ccae031b43e2aff6bc7523200b89cd0ef6ca299c1c1f60fd86961e80fd85b3cd44cb7c6610
6
+ metadata.gz: 0109f1af1b2d18f7082394276e1bd5b078e41202b3c21dc02509d23dba4e56480dbe0b566a39caec9575e3ce6e716a9c8925d123002640aa96a9e508eb223e7f
7
+ data.tar.gz: 31afec2473200a51f94d1096f0f16ce83d8e2e7a8d7bcb4c6b5957d61120675c72e4e590bb29cd03459a2a1f7fc3f2282aacb7ac5ccfc07bafb7549f3756b55e
@@ -5,6 +5,7 @@ module ThinkFeelDoEngine
5
5
  # Enables users to create, update, and delete modules
6
6
  # These modules contain providers that display content to the participants
7
7
  class ContentModulesController < ApplicationController
8
+ ARM_NOT_FOUND_MESSAGE = "Unable to find that arm.".freeze
8
9
  before_action :authenticate_user!, :set_arm, :set_tools
9
10
  before_action :set_content_module, only: [:show, :edit, :update, :destroy]
10
11
  load_and_authorize_resource only: [:show, :edit, :update, :destroy]
@@ -116,8 +117,21 @@ module ThinkFeelDoEngine
116
117
  end
117
118
 
118
119
  def record_not_found
119
- redirect_to arm_bit_maker_content_modules_path(@arm),
120
- alert: "Unable to find content module."
120
+ if @arm.is_a?(Arm)
121
+ redirect_to arm_bit_maker_content_modules_path(@arm),
122
+ alert: "Unable to find content module."
123
+ else
124
+ arm_not_found_path
125
+ end
126
+ end
127
+
128
+ def arm_not_found_path
129
+ if defined?(think_feel_do_dashboard)
130
+ redirect_to think_feel_do_dashboard.arms_path,
131
+ alert: ARM_NOT_FOUND_MESSAGE
132
+ else
133
+ redirect_to privacy_policy_path, alert: ARM_NOT_FOUND_MESSAGE
134
+ end
121
135
  end
122
136
  end
123
137
  end
@@ -42,7 +42,7 @@ module ThinkFeelDoEngine
42
42
  redirect_to coach_group_messages_url(@group), notice: "Message saved"
43
43
  else
44
44
  errors = @message.errors.full_messages.join(", ")
45
- redirect_to :back, alert: "Unable to save message: #{ errors }"
45
+ redirect_to :back, alert: "Unable to save message: #{errors}"
46
46
  end
47
47
  end
48
48
 
@@ -79,7 +79,7 @@ module ThinkFeelDoEngine
79
79
 
80
80
  rescue
81
81
  redirect_to arm_lessons_url(@arm),
82
- alert: "Unable to delete lesson: #{ model_errors(@lesson) }"
82
+ alert: "Unable to delete lesson: #{model_errors(@lesson)}"
83
83
  end
84
84
 
85
85
  def sort
@@ -21,7 +21,7 @@ module ThinkFeelDoEngine
21
21
  notice: "Task assigned."
22
22
  else
23
23
  errors = @task.errors.full_messages.join(", ")
24
- flash[:alert] = "Unable to assign task: #{ errors }"
24
+ flash[:alert] = "Unable to assign task: #{errors}"
25
25
  redirect_to arm_manage_tasks_group_path(@group.arm, @group)
26
26
  end
27
27
  end
@@ -36,7 +36,7 @@ module ThinkFeelDoEngine
36
36
  flash[:success] = "Task unassigned from group."
37
37
  else
38
38
  errors = @task.errors.full_messages.join(", ")
39
- flash[:alert] = "Unable to delete task from group: #{ errors }"
39
+ flash[:alert] = "Unable to delete task from group: #{errors}"
40
40
  end
41
41
  redirect_to arm_manage_tasks_group_path(group.arm, group)
42
42
  end
@@ -12,7 +12,7 @@ module ThinkFeelDoEngine
12
12
  @assessment = build_assessment(release_date: @token.release_date)
13
13
 
14
14
  render "think_feel_do_engine/participants/assessments/" \
15
- "new_#{ assessment_name }"
15
+ "new_#{assessment_name}"
16
16
  end
17
17
 
18
18
  def create
@@ -26,15 +26,15 @@ module ThinkFeelDoEngine
26
26
  @assessment = build_assessment(release_date: @token.release_date)
27
27
 
28
28
  render "think_feel_do_engine/participants/assessments/" \
29
- "new_#{ assessment_name }"
29
+ "new_#{assessment_name}"
30
30
  else
31
31
  render :success
32
32
  end
33
33
  else
34
34
  errors = @assessment.errors.full_messages.join(", ")
35
- flash.now[:alert] = "Unable to save assessment: #{ errors }"
35
+ flash.now[:alert] = "Unable to save assessment: #{errors}"
36
36
  render "think_feel_do_engine/participants/assessments/" \
37
- "new_#{ assessment_name }"
37
+ "new_#{assessment_name}"
38
38
  end
39
39
  end
40
40
 
@@ -1,6 +1,7 @@
1
1
  module ThinkFeelDoEngine
2
2
  module Coach
3
3
  # Displays navigational information in the form of breadcrumbs
4
+ # rubocop:disable Metrics/ModuleLength
4
5
  module GroupDashboardHelper
5
6
  def social_likes_and_comments_column_headers
6
7
  if social_features?
@@ -152,5 +153,6 @@ module ThinkFeelDoEngine
152
153
  end
153
154
  end
154
155
  end
156
+ # rubocop:enable Metrics/ModuleLength
155
157
  end
156
158
  end
@@ -4,7 +4,7 @@ module ThinkFeelDoEngine
4
4
  module PhqAssessmentHelper
5
5
  def phq_warning(score)
6
6
  if score == 3
7
- "<div class='label label-danger'>PHQ-9 WARNING: #{ score }</div>"
7
+ "<div class='label label-danger'>PHQ-9 WARNING: #{score}</div>"
8
8
  .html_safe
9
9
  else
10
10
  score
@@ -76,7 +76,7 @@ module ThinkFeelDoEngine
76
76
  end
77
77
 
78
78
  def css_id
79
- "task-status-#{ available_module.task_status_id }"
79
+ "task-status-#{available_module.task_status_id}"
80
80
  end
81
81
 
82
82
  def data_attributes
@@ -343,8 +343,12 @@ class Activity < ActiveRecord::Base
343
343
  end
344
344
 
345
345
  def create_activity_type
346
- new_title = activity_type_new_title.present? ? activity_type_new_title :
347
- activity_type_title
346
+ new_title = if activity_type_new_title.present?
347
+ activity_type_new_title
348
+ else
349
+ activity_type_title
350
+ end
351
+
348
352
  if new_title
349
353
  activity_types = participant.activity_types
350
354
 
@@ -43,7 +43,8 @@ module ContentProviders
43
43
 
44
44
  def timestamps(participant)
45
45
  period = most_recent_awake_period(participant)
46
- start_time, end_time = period.start_time, period.end_time
46
+ start_time = period.start_time
47
+ end_time = period.end_time
47
48
  times = []
48
49
  (start_time.to_i..(end_time.to_i - 1.hour)).step(1.hour) do |timestamp|
49
50
  times << timestamp
@@ -34,30 +34,35 @@ module ContentProviders
34
34
  end
35
35
  end
36
36
 
37
+ def report_missing_module
38
+ return unless defined? Raven
39
+
40
+ event = Raven::Event.new(message: "one of the thought modules " \
41
+ "couldn't be found via title")
42
+ Raven.send(event)
43
+ end
44
+
37
45
  def provider_postscript
38
46
  if @thoughts.count > 0
39
47
  "We're going to ask you to challenge each thought:"
40
48
  else
41
- title_1, title_2 = "#1 Identifying", "Add a New Harmful Thought"
49
+ title_1 = "#1 Identifying"
50
+ title_2 = "Add a New Harmful Thought"
42
51
  module_1 = BitCore::ContentModule.find_by_title(title_1)
43
52
  module_2 = BitCore::ContentModule.find_by_title(title_2)
44
53
 
45
54
  if module_1 && module_2
46
55
  "You can log more thoughts in " \
47
- "#{ @view.link_to(
56
+ "#{@view.link_to(
48
57
  title_1,
49
58
  @view.navigator_location_path(module_id: module_1.id),
50
- style: 'font-size: larger;') } or use " \
51
- "#{ @view.link_to(
59
+ style: 'font-size: larger;')} or use " \
60
+ "#{@view.link_to(
52
61
  title_2,
53
62
  @view.navigator_location_path(module_id: module_2.id),
54
- style: 'font-size: larger;') } to do multiple steps at once."
63
+ style: 'font-size: larger;')} to do multiple steps at once."
55
64
  else
56
- if defined? Raven
57
- event = Raven::Event.new(message: "one of the thought modules " \
58
- "couldn't be found via title")
59
- Raven.send(event)
60
- end
65
+ report_missing_module
61
66
 
62
67
  nil
63
68
  end
@@ -35,7 +35,7 @@ class MessageSmsNotification
35
35
 
36
36
  def message
37
37
  params = {
38
- to: "+1#{ phone_number }",
38
+ to: "+1#{phone_number}",
39
39
  from: from_telephone_number,
40
40
  body: body
41
41
  }
@@ -48,8 +48,8 @@ class PhqAssessment < ActiveRecord::Base
48
48
 
49
49
  if answered_questions.min < MIN_QUESTION_SCORE ||
50
50
  answered_questions.max > MAX_QUESTION_SCORE
51
- errors.add(:base, "scores must be between #{ MIN_QUESTION_SCORE } " \
52
- "and #{ MAX_QUESTION_SCORE } inclusive")
51
+ errors.add(:base, "scores must be between #{MIN_QUESTION_SCORE} " \
52
+ "and #{MAX_QUESTION_SCORE} inclusive")
53
53
  end
54
54
  end
55
55
  end
@@ -4,7 +4,7 @@ module ThinkFeelDoEngine
4
4
  module LessonModule
5
5
  URL_ROOT_RE = /^[^\/]*\/\/[^\/]+/
6
6
  # Disabling method length due to nested methods.
7
- # rubocop:disable Metrics/MethodLength
7
+ # rubocop:disable Metrics/MethodLength,Lint/NestedMethodDefinition
8
8
  def self.included(klass)
9
9
  class << klass
10
10
  # Returns a hash mapping lesson entry (first slide) path to Lesson
@@ -17,7 +17,7 @@ module ThinkFeelDoEngine
17
17
  path = navigator_location_path(module_id: m.id,
18
18
  provider_id: first_provider_id,
19
19
  content_position: 1)
20
- ["#{ path }", m.id]
20
+ ["#{path}", m.id]
21
21
  end.compact
22
22
 
23
23
  Hash[lessons]
@@ -28,7 +28,7 @@ module ThinkFeelDoEngine
28
28
  lessons = ContentModules::LessonModule.all.map do |m|
29
29
  path = navigator_location_path(module_id: m.id)
30
30
 
31
- ["#{ path }", m.id]
31
+ ["#{path}", m.id]
32
32
  end
33
33
 
34
34
  Hash[lessons]
@@ -42,7 +42,7 @@ module ThinkFeelDoEngine
42
42
  end
43
43
  end
44
44
  end
45
- # rubocop:enable Metrics/LineLength
45
+ # rubocop:enable Metrics/LineLength,Lint/NestedMethodDefinition
46
46
  end
47
47
  end
48
48
  end
@@ -49,7 +49,7 @@ module ThinkFeelDoEngine
49
49
  .order(:emitted_at)
50
50
  .where("emitted_at > ? AND payload NOT LIKE ?",
51
51
  page_render_event.emitted_at,
52
- "%currentUrl: #{ page_render_event.current_url }\n%")
52
+ "%currentUrl: #{page_render_event.current_url}\n%")
53
53
  .select(:emitted_at).limit(1).first.try(:emitted_at)
54
54
  end
55
55
  end
@@ -118,8 +118,8 @@ module ThinkFeelDoEngine
118
118
  if last_provider.nil?
119
119
  false
120
120
  else
121
- provider_re = "modules\/#{ module_id }\/" \
122
- "providers\/#{ last_provider.id }(\/.*)?$"
121
+ provider_re = "modules\/#{module_id}\/" \
122
+ "providers\/#{last_provider.id}(\/.*)?$"
123
123
 
124
124
  !url.match(/#{ provider_re }/).nil?
125
125
  end
@@ -1,6 +1,7 @@
1
1
  module ThinkFeelDoEngine
2
2
  module Reports
3
3
  # Helper methods for reporting on modules.
4
+ # rubocop:disable Lint/NestedMethodDefinition
4
5
  module ToolModule
5
6
  URL_ROOT_RE = /^[^\/]*\/\/[^\/]+/
6
7
 
@@ -25,5 +26,6 @@ module ThinkFeelDoEngine
25
26
  end
26
27
  end
27
28
  end
29
+ # rubocop:enable Lint/NestedMethodDefinition
28
30
  end
29
31
  end
@@ -61,20 +61,20 @@ class Thought < ActiveRecord::Base
61
61
  end
62
62
 
63
63
  def shared_description
64
- "Thought: #{ content }"
64
+ "Thought: #{content}"
65
65
  end
66
66
 
67
67
  private
68
68
 
69
69
  def clean_attributes
70
- def clean_attribute(attr)
70
+ clean_attribute = lambda do |attr|
71
71
  if self[attr].respond_to?(:strip)
72
72
  cleaned = self[attr].strip
73
- send("#{ attr }=", cleaned == "" ? nil : cleaned)
73
+ send("#{attr}=", cleaned == "" ? nil : cleaned)
74
74
  end
75
75
  end
76
76
 
77
- clean_attribute(:challenging_thought)
78
- clean_attribute(:act_as_if)
77
+ clean_attribute.call(:challenging_thought)
78
+ clean_attribute.call(:act_as_if)
79
79
  end
80
80
  end
@@ -19,8 +19,8 @@ class WaiAssessment < ActiveRecord::Base
19
19
 
20
20
  if remove_nils.min < MIN_QUESTION_SCORE ||
21
21
  remove_nils.max > MAX_QUESTION_SCORE
22
- errors.add(:base, "scores must be between #{ MIN_QUESTION_SCORE } " \
23
- "and #{ MAX_QUESTION_SCORE } inclusive")
22
+ errors.add(:base, "scores must be between #{MIN_QUESTION_SCORE} " \
23
+ "and #{MAX_QUESTION_SCORE} inclusive")
24
24
  end
25
25
  end
26
26
 
@@ -1,4 +1,4 @@
1
1
  # nodoc
2
2
  module ThinkFeelDoEngine
3
- VERSION = "3.19.7"
3
+ VERSION = "3.19.8"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: think_feel_do_engine
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.19.7
4
+ version: 3.19.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Carty-Fickes
@@ -988,7 +988,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
988
988
  version: '0'
989
989
  requirements: []
990
990
  rubyforge_project:
991
- rubygems_version: 2.5.1
991
+ rubygems_version: 2.6.4
992
992
  signing_key:
993
993
  specification_version: 4
994
994
  summary: Summary of ThinkFeelDoEngine.