- @report = @issue.reports.where(reporter_user_id: @user.id).first
- details = params[:report][:details].to_s + "||" + params[:spam].to_s + "||" + params[:offensive].to_s + "||" + params[:threat].to_s + "||" + params[:vandal].to_s + "||" + params[:other].to_s
- @report.details = details
- if @report.save!
- redirect_to root_path, notice: 'Your report was successfully updated.'
+ # Check if details provided are sufficient
+ if check_report_params
+ @report = @issue.reports.where(reporter_user_id: @user.id).first
+
+ if @report == nil
+ @report = @issue.reports.build(report_params)
+ @report.reporter_user_id = @user.id
+ notice = t('issues.update.new_report')
+ end
+
+ details = get_report_details
+ @report.details = details
+
+ # Checking if instance has been updated since last report
+ @last_report = @issue.reports.order(updated_at: :desc).last
+ if check_if_updated
+ @issue.reopen
+ @issue.save!
+ end
+
+ if notice == nil
+ notice = t('issues.update.successful_update')
+ end
+
+ if @report.save!
+ redirect_to root_path, notice: notice
+ end