app/controllers/hyrax/workflow_actions_controller.rb
# Update required_report and required_report_due_date values given a work and workflow action
Update required_report and required_report_due_date values given a work and workflow action
Update required_report and required_report_due_date values given a work and workflow action
def update_required_report(work, workflow_action_name)
      required_report_name = work.required_report_name
      return if required_report_name == 'Not Required'
      date_published = Date.parse(work.date_published)
      required_report = RequiredReport.where(agency_name: work.agency, name: required_report_name).first
      case workflow_action_name
      when 'comment_only'
        return
      when 'approve'
        if required_report.last_published_date.nil? || (date_published > required_report.last_published_date)
          required_report.update_attributes(last_published_date: date_published)
        end
      when 'request_changes'
        required_report_due_date = RequiredReportDueDate.where(submission_id: work.id).first
        required_report_due_date.update_attributes(date_submitted: nil)
      when 'request_review'
        required_report_due_date = RequiredReportDueDate.where(submission_id: work.id).first
        required_report_due_date.update_attributes(date_submitted: Time.current)
      end
    end
def update_required_report ( work , workflow_action_name ) required_report_name = work . required_report_name return if required_report_name == 'Not Required' date_published = Date . parse ( work . date_published ) required_report = RequiredReport . where ( agency_name : work . agency , name : required_report_name ) . first case workflow_action_name when 'comment_only' return when 'approve' if required_report . last_published_date . nil? || ( date_published > required_report . last_published_date ) required_report . update_attributes ( last_published_date : date_published ) end when 'request_changes' required_report_due_date = RequiredReportDueDate . where ( submission_id : work . id ) . first required_report_due_date . update_attributes ( date_submitted : nil ) when 'request_review' required_report_due_date = RequiredReportDueDate . where ( submission_id : work . id ) . first required_report_due_date . update_attributes ( date_submitted : Time . current ) end end
Update required_report and required_report_due_date values given a work and workflow action
Update required_report and required_report_due_date values given a work and workflow action
# Set last_published_date if work is approved and date_published is after current value of last_published_date # Set date_submitted to nil on request_changes # Set date_submitted to current date and time on request_review
work
<not_specific>
workflow_action_name
<not_specific>