Sha256: 20f6ab1e826e0c006dade659dfd5ef66bbc8a5db4554617c44aa0ad18db76015

Contents?: true

Size: 1.26 KB

Versions: 29

Compression:

Stored size: 1.26 KB

Contents

class Cms::TasksController < Cms::BaseController
  
  before_filter :set_toolbar_tab
  before_filter :load_page, :only => [:new, :create]
  
  def new
    @task = @page.tasks.build(:assigned_by => current_user)
  end
  
  def create
    @task = @page.tasks.build(params[:task])
    @task.assigned_by = current_user
    if @task.save
      flash[:notice] = "Page was assigned to '#{@task.assigned_to.login}'"
      redirect_to @page.path
    else
      render :action => 'new'
    end
  end
  
  def complete
    if params[:task_ids]
      Task.all(:conditions => ["id in (?)", params[:task_ids]]).each do |t|
        if t.assigned_to == current_user
          t.mark_as_complete!
        end
      end
      flash[:notice] = "Tasks marked as complete"
      redirect_to cms_dashboard_path
    else
      @task = Task.find(params[:id])
      if @task.assigned_to == current_user
        if @task.mark_as_complete!
          flash[:notice] = "Task was marked as complete"
        end
      else
        flash[:error] = "You cannot complete tasks that are not assigned to you"
      end
      redirect_to @task.page.path
    end
  end
  
  private
    def load_page
      @page = Page.find(params[:page_id])
    end
  
    def set_toolbar_tab
      @toolbar_tab = :sitemap
    end  
  
end

Version data entries

29 entries across 29 versions & 8 rubygems

Version Path
SFEley-browsercms-3.0.2 app/controllers/cms/tasks_controller.rb
buzzware-browsercms-3.0.2 app/controllers/cms/tasks_controller.rb
coredumplings-browsercms-3.0.0 app/controllers/cms/tasks_controller.rb
nate-browsercms-3.0.210 app/controllers/cms/tasks_controller.rb
nate-browsercms-3.0.211 app/controllers/cms/tasks_controller.rb
we5-browsercms-3.0.1.1 app/controllers/cms/tasks_controller.rb
webficient-browsercms-3.0.1 app/controllers/cms/tasks_controller.rb
webficient-browsercms-3.0.2 app/controllers/cms/tasks_controller.rb
webficient-browsercms-3.0.3 app/controllers/cms/tasks_controller.rb
webficient-browsercms-3.0.4 app/controllers/cms/tasks_controller.rb
browsercms-3.1.5 app/controllers/cms/tasks_controller.rb
browsercms-3.1.4 app/controllers/cms/tasks_controller.rb
browsercms-3.1.3 app/controllers/cms/tasks_controller.rb
browsercms-3.1.2 app/controllers/cms/tasks_controller.rb
browsercms-3.1.0 app/controllers/cms/tasks_controller.rb
we5-browsercms-3.1.0 app/controllers/cms/tasks_controller.rb
browsercms-3.0.6 app/controllers/cms/tasks_controller.rb
browsercms-3.0.5 app/controllers/cms/tasks_controller.rb
we5-browsercms-3.0.5.1 app/controllers/cms/tasks_controller.rb
we5-browsercms-3.0.5 app/controllers/cms/tasks_controller.rb