Permalink
Browse files

Don't try to publish unsuitable editions

  • Loading branch information...
1 parent 21db5f3 commit 98dc81960547c993a0d2fa5719b7b7ee4657ebd1 @jamiecobbett jamiecobbett committed Mar 27, 2013
Showing with 4 additions and 4 deletions.
  1. +4 −4 lib/batch_publish.rb
@@ -5,7 +5,8 @@ def initialize(edition_identifiers, email)
end
def call
- editions = @edition_identifiers.map do |identifier|
+ editions = []
+ @edition_identifiers.each do |identifier|
edition = Edition.where(
slug: identifier.fetch(:slug),
version_number: identifier.fetch(:edition)
@@ -14,12 +15,11 @@ def call
Rails.logger.error "Edition couldn't be found for #{identifier}"
elsif ["ready", "published"].exclude?(edition.state)
Rails.logger.error "Edition #{identifier} isn't 'published' or 'ready'. It's #{edition.state}"
+ else
+ editions << edition
end
- edition
end
- editions = editions.compact
-
editions.each do |edition|
published = user.progress(edition, { request_type: "publish", comment: "" })
if published

0 comments on commit 98dc819

Please sign in to comment.