1 class RedactionsController < ApplicationController
4 before_filter :authorize_web
5 before_filter :set_locale
6 before_filter :require_user, :only => [:new, :create, :edit, :update, :destroy]
7 before_filter :require_moderator, :only => [:new, :create, :edit, :update, :destroy]
8 before_filter :lookup_redaction, :only => [:show, :edit, :update, :destroy]
9 before_filter :check_database_readable
10 before_filter :check_database_writable, :only => [:create, :update, :destroy]
13 @redactions_pages, @redactions = paginate(:redactions, :order => :id, :per_page => 10)
17 @redaction = Redaction.new
21 @redaction = Redaction.new
22 @redaction.user_id = @user.id
23 @redaction.title = params[:redaction][:title]
24 @redaction.description = params[:redaction][:description]
25 # didn't see this come in from the form - maybe i'm doing something
26 # wrong, or markdown is the only thing supported at the moment?
27 @redaction.description_format = 'markdown'
30 flash[:notice] = t('redaction.create.flash')
31 redirect_to @redaction
33 render :action => 'new'
44 # note - don't update the user ID
46 if params[:redaction][:title] and params[:redaction][:title] != @redaction.title
47 @redaction.title = params[:redaction][:title]
50 if params[:redaction][:description] and params[:redaction][:description] != @redaction.description
51 @redaction.description = params[:redaction][:description]
55 flash[:notice] = t('redaction.update.flash')
56 redirect_to @redaction
58 render :action => 'edit'
63 unless @redaction.old_nodes.empty? and
64 @redaction.old_ways.empty? and
65 @redaction.old_relations.empty?
66 flash[:error] = t('redaction.destroy.not_empty')
67 redirect_to @redaction
70 flash[:notice] = t('redaction.destroy.flash')
73 flash[:error] = t('redaction.destroy.error')
74 redirect_to @redaction
82 @redaction = Redaction.find(params[:id])