Sha256: 78849488e2ad8d621fd507d806d2d223e759fe0faaf46d7347d5a5abd35b2845

Contents?: true

Size: 1.06 KB

Versions: 1

Compression:

Stored size: 1.06 KB

Contents

module Catarse
class Adm::ProjectsController < Catarse::Adm::BaseController
  inherit_resources
  menu I18n.t("adm.projects.index.menu") => Catarse::Core::Engine.routes.url_helpers.adm_projects_path

  has_scope :by_id, :pg_search, :user_name_contains, :order_table

  before_filter do
    @total_projects = Project.count
  end

  def update
    @project = Project.find params[:id]

    respond_to do |format|
      if @project.update_attributes(params[:project])
        format.html { redirect_to(adm_projects_path) }
        format.json { respond_with_bip(@project) }
      else
        format.html { render :action => "edit" }
        format.json { respond_with_bip(@user) }
      end
    end
  end

  [:approve, :reject, :push_to_draft].each do |name|
    define_method name do
      @project = Project.find params[:id]
      @project.send("#{name.to_s}!")
      redirect_to :back
    end
  end

  def collection
    @projects = apply_scopes(Project).page(params[:page])
    @projects = @projects.order('created_at DESC') unless current_scopes.include?(:order_table)
  end
end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
catarse_core-1.0.0.beta app/controllers/catarse/adm/projects_controller.rb