Class: Actions::Katello::Organization::SimpleContentAccess::Toggle

Inherits:
AbstractAsyncTask
  • Object
show all
Includes:
Helpers::Notifications
Defined in:
app/lib/actions/katello/organization/simple_content_access/toggle.rb

Direct Known Subclasses

Disable, Enable

Constant Summary collapse

SIMPLE_CONTENT_ACCESS_DISABLED_VALUE =
"entitlement".freeze
SIMPLE_CONTENT_ACCESS_ENABLED_VALUE =
"org_environment".freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Helpers::Notifications

#get_foreman_task, included, #plan_failed?, #send_notification, #subject_organization

Methods inherited from AbstractAsyncTask

#humanized_output, #rescue_strategy

Instance Attribute Details

#organizationObject (readonly)

Returns the value of attribute organization.



12
13
14
# File 'app/lib/actions/katello/organization/simple_content_access/toggle.rb', line 12

def organization
  @organization
end

Instance Method Details

#failure_notification(plan) ⇒ Object



26
27
28
29
30
31
# File 'app/lib/actions/katello/organization/simple_content_access/toggle.rb', line 26

def failure_notification(plan)
  task_error_notification.deliver!(
    :subject => subject_organization,
    :task => get_foreman_task(plan)
  )
end

#humanized_inputObject



39
40
41
# File 'app/lib/actions/katello/organization/simple_content_access/toggle.rb', line 39

def humanized_input
  _("for organization %s") % input[:organization_name]
end

#plan(organization_id) ⇒ Object



14
15
16
17
18
19
20
# File 'app/lib/actions/katello/organization/simple_content_access/toggle.rb', line 14

def plan(organization_id)
  organization = ::Organization.find(organization_id.to_i)
  input[:organization_name] = organization.name
  input[:organization_label] = organization.label
  action_subject organization
  plan_self(organization_id: organization_id)
end

#runObject



22
23
24
# File 'app/lib/actions/katello/organization/simple_content_access/toggle.rb', line 22

def run
  ::Katello::Resources::Candlepin::Owner.update(input[:organization_label], contentAccessMode: content_access_mode_value)
end

#success_notification(_plan) ⇒ Object



33
34
35
36
37
# File 'app/lib/actions/katello/organization/simple_content_access/toggle.rb', line 33

def success_notification(_plan)
  task_success_notification.deliver!(
    subject_organization
  )
end