1 # frozen_string_literal: true
 
   3 class RedactionsController < ApplicationController
 
   6   before_action :authorize_web
 
   7   before_action :set_locale
 
  11   before_action :lookup_redaction, :only => [:show, :edit, :update, :destroy]
 
  12   before_action :check_database_readable
 
  13   before_action :check_database_writable, :only => [:create, :update, :destroy]
 
  16     @redactions = Redaction.order(:id)
 
  22     @redaction = Redaction.new
 
  28     @redaction = Redaction.new
 
  29     @redaction.user = current_user
 
  30     @redaction.title = params[:redaction][:title]
 
  31     @redaction.description = params[:redaction][:description]
 
  32     # NOTE: the description format will default to 'markdown'
 
  35       flash[:notice] = t(".flash")
 
  36       redirect_to @redaction
 
  38       render :action => "new"
 
  43     # NOTE: don't update the user ID
 
  44     @redaction.title = params[:redaction][:title]
 
  45     @redaction.description = params[:redaction][:description]
 
  48       flash[:notice] = t(".flash")
 
  49       redirect_to @redaction
 
  51       render :action => "edit"
 
  56     if @redaction.old_nodes.empty? &&
 
  57        @redaction.old_ways.empty? &&
 
  58        @redaction.old_relations.empty?
 
  60         flash[:notice] = t(".flash")
 
  61         redirect_to :redactions
 
  63         flash[:error] = t(".error")
 
  64         redirect_to @redaction
 
  67       flash[:error] = t(".not_empty")
 
  68       redirect_to @redaction
 
  75     @redaction = Redaction.find(params[:id])