Class | Admin::ProposalsController
In: | app/controllers/admin/proposals_controller.rb
Parent: | Admin::BaseController

### Methods

auto_complete_for_proposal_tag_list_es comments create destroy edit edit index new publish show update update_status

### Public Instance methods

auto_complete_for_proposal_tag_list_es()

def update_comments_status

      @title = "Actualizar propuesta"

      if @proposal.update_attribute(:comments_closed, params[:comments_closed])
        render :update do |page|
          page.replace :comments_status, :partial => 'comments_status'
        end
      end

end

[Source]

         # File app/controllers/admin/proposals_controller.rb, line 138
    138:   def auto_complete_for_proposal_tag_list_es
    139:     auto_complete_for_tag_list(params[:proposal][:tag_list_es])
    140:     if @tags.length > 0
    141:       render :inline => "<%= content_tag(:ul, @tags.map {|t| content_tag(:li, t.nombre)}) %>"
    142:     else
    143:       render :nothing => true
    144:     end
    145:   end

comments()

[Source]

         # File app/controllers/admin/proposals_controller.rb, line 108
    108:   def comments
    109:     @comments = @proposal.comments.paginate :per_page => 20, :page => params[:page], :order => "created_at DESC"
    110:     @title = "Comentarios de la propuesta \"#{@proposal.title_es}\""
    111:   end

create()

[Source]

        # File app/controllers/admin/proposals_controller.rb, line 58
    58:   def create
    59:     @title = "Crear propuesta gubernamental"
    60:     @proposal = Proposal.new(params[:proposal])
    61:     @proposal.governmental = true
    62:     @proposal.user_id = current_user.id
    63:     @proposal.name = current_user.name
    64:     @proposal.email = current_user.email
    65:     @proposal.status = 'aprobado'
    66:
    67:     if @proposal.save
    68:       flash[:notice] = 'La propuesta se ha guardado correctamente'
    69:       redirect_to admin_proposal_path(@proposal)
    70:     else
    71:       render :action => 'new'
    72:     end
    73:   end

destroy()

[Source]

         # File app/controllers/admin/proposals_controller.rb, line 96
     96:   def destroy
     97:     @title = 'Eliminar propuesta'
     98:
     99:     if @proposal.destroy
    100:       flash[:notice] = 'La propuesta se ha eliminado correctamente'
    101:       redirect_to admin_proposals_path
    102:     else
    103:       flash[:error] = 'La propuesta no se ha podido eliminar'
    104:       redirect_to admin_proposal_path(@proposal)
    105:     end
    106:   end

edit()

[Source]

        # File app/controllers/admin/proposals_controller.rb, line 75
    75:   def edit
    76:     @title = "Modificar propuesta"
    77:   end

edit()

[Source]

        # File app/controllers/admin/proposals_controller.rb, line 79
    79:   def edit
    80:     @title = "Modificar propuesta"
    81:   end

index()

[Source]

        # File app/controllers/admin/proposals_controller.rb, line 15
    15:   def index
    16:     @sort_order = params[:sort] ||  "update"
    17:
    18:     case @sort_order
    19:     when "update"
    20:       order = "updated_at DESC, title_es, published_at DESC"
    21:     when "publish"
    22:       order = "created_at DESC, title_es, updated_at DESC"
    23:     when "title"
    24:       order = "lower(tildes(title_es)), published_at DESC, updated_at DESC"
    25:     end
    26:
    27:     conditions = []
    28:     cond_values = {}
    29:
    30:     @gov = params[:gov] || "t"
    31:     conditions << "governmental=:gov"
    32:     cond_values[:gov] = @gov
    33:
    34:     if params[:q].present?
    35:       conditions << "lower(tildes(coalesce(title_es, '') || ' ' || coalesce(title_eu, ''))) like :q"
    36:       cond_values[:q] = "%" + params[:q].tildes.downcase + "%"
    37:     end
    38:
    39:     @proposals = Proposal.paginate :page => params[:page], :per_page => 20,
    40:       :order => order,
    41:       :conditions => [conditions.join(' AND '), cond_values]
    42:
    43:     @title = "Propuestas"
    44:
    45:     @your_proposals_text = Proposal.yours_intro_page
    46:     @our_proposals_text = Proposal.ours_intro_page
    47:   end

new()

[Source]

        # File app/controllers/admin/proposals_controller.rb, line 53
    53:   def new
    54:     @title = "Crear propuesta gubernamental"
    55:     @proposal = Proposal.new
    56:   end

publish()

[Source]

         # File app/controllers/admin/proposals_controller.rb, line 113
    113:   def publish
    114:     @proposal.update_attribute(:draft, false)
    115:     redirect_to @proposal
    116:   end

show()

[Source]

        # File app/controllers/admin/proposals_controller.rb, line 49
    49:   def show
    50:     @title = "#{@proposal.title}"
    51:   end

update()

[Source]

        # File app/controllers/admin/proposals_controller.rb, line 83
    83:   def update
    84:     @proposal.attributes = params[:proposal]
    85:
    86:     @title = "Actualizar propuesta"
    87:
    88:     if @proposal.save
    89:       flash[:notice] = 'El propuesta se ha guardado correctamente'
    90:       redirect_to admin_proposal_path(@proposal)
    91:     else
    92:       render :action => params[:return_to] || 'edit'
    93:     end
    94:   end

update_status()

[Source]

         # File app/controllers/admin/proposals_controller.rb, line 118
    118:   def update_status
    119:     @proposal.update_attributes(params[:proposal])
    120:
    121:     render :update do |page|
    122:       page.replace "proposal_#{@proposal.id}", :partial => "proposal", :locals => {:proposal => @proposal}
    123:       page["proposal_#{@proposal.id}"].className = @proposal.status
    124:     end
    125:
    126:   end

[Validate]