<commit_before>module Edition::ScheduledPublishing
  extend ActiveSupport::Concern

  module InstanceMethods
    def schedulable_by?(user, options = {})
      reason_to_prevent_scheduling_by(user, options).nil?
    end

    def reason_to_prevent_scheduling_by(user, options = {})
      reason_to_prevent_approval_by(user, options) or if scheduled_publication.present?
        "This edition is does not have a scheduled publication date set"
      end
    end

    def schedule_as(user, options = {})
      if schedulable_by?(user, options)
        self.force_published = options[:force]
        schedule!
        true
      else
        errors.add(:base, reason_to_prevent_scheduling_by(user, options))
        false
      end
    end

    def reason_to_prevent_publication_by(user, options = {})
      super or if scheduled_publication.present?
        if !scheduled? or Time.zone.now < scheduled_publication
          "This edition is scheduled for publication on #{scheduled_publication.to_s}, and may not be published before"
        end
      end
    end
  end
end<commit_msg>The logic in this method seems to have been inverted.<commit_after>module Edition::ScheduledPublishing
  extend ActiveSupport::Concern

  module InstanceMethods
    def schedulable_by?(user, options = {})
      reason_to_prevent_scheduling_by(user, options).nil?
    end

    def reason_to_prevent_scheduling_by(user, options = {})
      reason_to_prevent_approval_by(user, options) or if scheduled_publication.blank?
        "This edition does not have a scheduled publication date set"
      end
    end

    def schedule_as(user, options = {})
      if schedulable_by?(user, options)
        self.force_published = options[:force]
        schedule!
        true
      else
        errors.add(:base, reason_to_prevent_scheduling_by(user, options))
        false
      end
    end

    def reason_to_prevent_publication_by(user, options = {})
      super or if scheduled_publication.present?
        if !scheduled? or Time.zone.now < scheduled_publication
          "This edition is scheduled for publication on #{scheduled_publication.to_s}, and may not be published before"
        end
      end
    end
  end
end
{'fraction_non_alphanumeric': 0.06964041875284478, 'fraction_numerical': 0.0, 'mean_word_length': 3.1161048689138577, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6803958', 'n_tokens_mistral': 624, 'n_tokens_neox': 622, 'n_words': 169}