Skip to content
This repository has been archived by the owner on Sep 18, 2018. It is now read-only.

show a warning after host creation/update if not all repositoires are av... #29

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/content/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ class Engine < ::Rails::Engine
::Hostgroup.send :include, ContentHostgroup
# Extend the host model
::Host::Managed.send :include, ContentHost

::HostsController.send :include, ContentHostsController
end
end

Expand Down
17 changes: 17 additions & 0 deletions lib/content_hosts_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
module ContentHostsController
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you refactor to use AR:Concern and also move in to app/controllers/concerns?

def self.included(base)
base.send(:include, InstanceMethods)
base.class_eval do
after_filter :verify_repository_status, :only => [:create, :setBuild, :cancelBuild]
end
end

module InstanceMethods
def verify_repository_status
return if new_record? || !built?
@host.attached_repositories.each do |r|
flash[:warning] = "Repository '#{r.name}' is not ready to be used." unless r.sync_status.synced?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rescue if pulp is not reachable?

this could be very confusing error message if all you do is set build

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw: another reason to keep that status in our db.

end
end
end
end