Class: ContentDepositorChangeEventJob
- Inherits:
-
ContentEventJob
- Object
- EventJob
- ContentEventJob
- ContentDepositorChangeEventJob
- Defined in:
- app/jobs/content_depositor_change_event_job.rb
Overview
A specific job to log a file deposit change to a user’s activity stream
This is a bit wierd becuase the job performs the depositor transfer along with logging the job
Instance Attribute Summary collapse
-
#id ⇒ String
identifier of the file to be transfered.
-
#login ⇒ String
the user key of the user the file is being transfered to.
-
#reset ⇒ Boolean
(false) should the access controls be reset.
Attributes inherited from ContentEventJob
Attributes inherited from EventJob
Instance Method Summary collapse
- #action ⇒ Object
-
#generic_file ⇒ Object
overriding default to load from fedora and change the depositor.
-
#initialize(id, login, reset = false) ⇒ ContentDepositorChangeEventJob
constructor
A new instance of ContentDepositorChangeEventJob.
-
#log_user_event ⇒ Object
overriding default to log the event to the depositor instead of their profile.
- #queue_name ⇒ Object
- #run ⇒ Object
Methods inherited from ContentEventJob
#log_generic_file_event, #log_to_followers
Methods inherited from EventJob
#depositor, #event, #log_to_followers
Methods included from Sufia::SufiaHelperBehavior
#current_search_parameters, #display_user_name, #error_messages_for, #has_collection_search_parameters?, #iconify_auto_link, #iconify_link, #is_url?, #link_back_to_dashboard, #link_to_dashboard_query, #link_to_facet, #link_to_facet_list, #link_to_field, #link_to_profile, #link_to_telephone, #linkify_chat_id, #number_of_deposits, #orcid_label, #render_visibility_label, #render_visibility_link, #search_form_action, #show_transfer_request_title, #sufia_thumbnail_tag, #user_display_name_and_key, #zotero_label, #zotero_profile_url
Methods included from Sufia::BlacklightOverride
#render_bookmarks_control?, #render_constraints_query, #url_for_document
Constructor Details
#initialize(id, login, reset = false) ⇒ ContentDepositorChangeEventJob
Returns a new instance of ContentDepositorChangeEventJob.
18 19 20 21 22 23 |
# File 'app/jobs/content_depositor_change_event_job.rb', line 18 def initialize(id, login, reset = false) super(id, login) self.id = id self.login = login self.reset = reset end |
Instance Attribute Details
#id ⇒ String
identifier of the file to be transfered
8 9 10 |
# File 'app/jobs/content_depositor_change_event_job.rb', line 8 def id @id end |
#login ⇒ String
the user key of the user the file is being transfered to.
8 9 10 |
# File 'app/jobs/content_depositor_change_event_job.rb', line 8 def login @login end |
#reset ⇒ Boolean
(false) should the access controls be reset. This means revoking edit access from the depositor
8 9 10 |
# File 'app/jobs/content_depositor_change_event_job.rb', line 8 def reset @reset end |
Instance Method Details
#action ⇒ Object
33 34 35 |
# File 'app/jobs/content_depositor_change_event_job.rb', line 33 def action "User #{link_to_profile generic_file.proxy_depositor} has transferred #{link_to generic_file.title.first, Sufia::Engine.routes.url_helpers.generic_file_path(generic_file)} to user #{link_to_profile login}" end |
#generic_file ⇒ Object
overriding default to load from fedora and change the depositor
38 39 40 41 42 43 44 45 46 47 48 |
# File 'app/jobs/content_depositor_change_event_job.rb', line 38 def generic_file # TODO: This should be in its own job, not this event job @generic_file ||= begin file = ::GenericFile.find(id) file.proxy_depositor = file.depositor file. if reset file.(login) file.save! file end end |
#log_user_event ⇒ Object
overriding default to log the event to the depositor instead of their profile
51 52 53 |
# File 'app/jobs/content_depositor_change_event_job.rb', line 51 def log_user_event depositor.log_event(event) end |
#queue_name ⇒ Object
9 10 11 |
# File 'app/jobs/content_depositor_change_event_job.rb', line 9 def queue_name :proxy_deposit end |
#run ⇒ Object
25 26 27 28 29 30 31 |
# File 'app/jobs/content_depositor_change_event_job.rb', line 25 def run super # log the event to the proxy depositor's profile proxy_depositor = ::User.find_by_user_key(generic_file.proxy_depositor) proxy_depositor.log_profile_event(event) end |