Class: WorkStateTransitionNotification
- Inherits:
-
Object
- Object
- WorkStateTransitionNotification
- Defined in:
- app/models/work_state_transition_notification.rb
Overview
Connect with the curators of a work when an activity occurs
Instance Attribute Summary collapse
-
#current_user_id ⇒ Object
readonly
Returns the value of attribute current_user_id.
-
#depositor ⇒ Object
readonly
Returns the value of attribute depositor.
-
#from_state ⇒ Object
readonly
Returns the value of attribute from_state.
-
#group ⇒ Object
readonly
Returns the value of attribute group.
-
#group_administrators ⇒ Object
readonly
Returns the value of attribute group_administrators.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#notification ⇒ Object
readonly
Returns the value of attribute notification.
-
#to_state ⇒ Object
readonly
Returns the value of attribute to_state.
-
#users ⇒ Object
readonly
Returns the value of attribute users.
-
#work_title ⇒ Object
readonly
Returns the value of attribute work_title.
-
#work_url ⇒ Object
readonly
Returns the value of attribute work_url.
Instance Method Summary collapse
-
#initialize(work, current_user_id) ⇒ WorkStateTransitionNotification
constructor
A new instance of WorkStateTransitionNotification.
- #send ⇒ Object
Constructor Details
#initialize(work, current_user_id) ⇒ WorkStateTransitionNotification
Returns a new instance of WorkStateTransitionNotification.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'app/models/work_state_transition_notification.rb', line 9 def initialize(work, current_user_id) @to_state = work.aasm.to_state @from_state = work.aasm.from_state @depositor = work.created_by_user @group = work.group @group_administrators = group.administrators.to_a @work_url = Rails.application.routes.url_helpers.work_url(work) # Troubleshooting https://github.com/pulibrary/pdc_describe/issues/1783 if @work_url.include?("/describe/describe/") Rails.logger.error("URL #{@work_url} included /describe/describe/ and was fixed. See https://github.com/pulibrary/pdc_describe/issues/1783") @work_url = @work_url.gsub("/describe/describe/", "/describe/") end @work_title = work.title @notification = notification_for_transition @id = work.id raise(NotImplementedError, "Invalid user ID provided.") if current_user_id.nil? @current_user_id = current_user_id end |
Instance Attribute Details
#current_user_id ⇒ Object (readonly)
Returns the value of attribute current_user_id.
6 7 8 |
# File 'app/models/work_state_transition_notification.rb', line 6 def current_user_id @current_user_id end |
#depositor ⇒ Object (readonly)
Returns the value of attribute depositor.
6 7 8 |
# File 'app/models/work_state_transition_notification.rb', line 6 def depositor @depositor end |
#from_state ⇒ Object (readonly)
Returns the value of attribute from_state.
6 7 8 |
# File 'app/models/work_state_transition_notification.rb', line 6 def from_state @from_state end |
#group ⇒ Object (readonly)
Returns the value of attribute group.
6 7 8 |
# File 'app/models/work_state_transition_notification.rb', line 6 def group @group end |
#group_administrators ⇒ Object (readonly)
Returns the value of attribute group_administrators.
6 7 8 |
# File 'app/models/work_state_transition_notification.rb', line 6 def group_administrators @group_administrators end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
6 7 8 |
# File 'app/models/work_state_transition_notification.rb', line 6 def id @id end |
#notification ⇒ Object (readonly)
Returns the value of attribute notification.
6 7 8 |
# File 'app/models/work_state_transition_notification.rb', line 6 def notification @notification end |
#to_state ⇒ Object (readonly)
Returns the value of attribute to_state.
6 7 8 |
# File 'app/models/work_state_transition_notification.rb', line 6 def to_state @to_state end |
#users ⇒ Object (readonly)
Returns the value of attribute users.
6 7 8 |
# File 'app/models/work_state_transition_notification.rb', line 6 def users @users end |
#work_title ⇒ Object (readonly)
Returns the value of attribute work_title.
6 7 8 |
# File 'app/models/work_state_transition_notification.rb', line 6 def work_title @work_title end |
#work_url ⇒ Object (readonly)
Returns the value of attribute work_url.
6 7 8 |
# File 'app/models/work_state_transition_notification.rb', line 6 def work_url @work_url end |
Instance Method Details
#send ⇒ Object
31 32 33 34 35 |
# File 'app/models/work_state_transition_notification.rb', line 31 def send return if notification.nil? WorkActivity.add_work_activity(id, notification, current_user_id, activity_type: WorkActivity::NOTIFICATION) end |