Class: Actions::Katello::ContentView::RemoveFromEnvironment

Inherits:
EntryAction
  • Object
show all
Defined in:
app/lib/actions/katello/content_view/remove_from_environment.rb

Instance Method Summary collapse

Instance Method Details

#finalizeObject



27
28
29
30
31
# File 'app/lib/actions/katello/content_view/remove_from_environment.rb', line 27

def finalize
  history = ::Katello::ContentViewHistory.find(input[:history_id])
  history.status = ::Katello::ContentViewHistory::SUCCESSFUL
  history.save!
end

#humanized_nameObject



33
34
35
# File 'app/lib/actions/katello/content_view/remove_from_environment.rb', line 33

def humanized_name
  _("Remove from Environment")
end

#plan(content_view, environment) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/lib/actions/katello/content_view/remove_from_environment.rb', line 5

def plan(content_view, environment)
  action_subject(content_view)
  content_view.check_remove_from_environment!(environment)

  cv_env = ::Katello::ContentViewEnvironment.where(:content_view_id => content_view.id,
                                                   :environment_id => environment.id).first

  if cv_env.nil?
    fail _("Cannot remove content view from environment. Content view '%{view}' is not in lifecycle environment '%{env}'.") %
      {view: content_view.name, env: environment.name}
  end

  history = ::Katello::ContentViewHistory.create!(:content_view_version => cv_env.content_view_version,
                                                  :environment => environment,
                                                  :user => ::User.current.,
                                                  :status => ::Katello::ContentViewHistory::IN_PROGRESS,
                                                  :task => self.task)

  plan_action(ContentViewEnvironment::Destroy, cv_env)
  plan_self(history_id: history.id)
end