Sha256: 08d677aedb957e252df7ffa6fa46f4c5b539649de5f0a54ebd5e52982a678954

Contents?: true

Size: 1.39 KB

Versions: 15

Compression:

Stored size: 1.39 KB

Contents

module Cms
class 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 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
  rescue ActiveRecord::RecordNotFound
    flash[:error] = "No tasks were marked for completion"
    redirect_to dashboard_path
  end
  
  private
    def load_page
      @page = Page.find(params[:page_id])
    end
  
    def set_toolbar_tab
      @toolbar_tab = :sitemap
    end  
  
end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
browsercms-3.5.7 app/controllers/cms/tasks_controller.rb
browsercms-3.5.6 app/controllers/cms/tasks_controller.rb
browsercms-3.5.5 app/controllers/cms/tasks_controller.rb
browsercms-3.5.4 app/controllers/cms/tasks_controller.rb
browsercms-3.5.3 app/controllers/cms/tasks_controller.rb
browsercms-3.5.2 app/controllers/cms/tasks_controller.rb
browsercms-3.5.1 app/controllers/cms/tasks_controller.rb
browsercms-3.5.0 app/controllers/cms/tasks_controller.rb
browsercms-3.5.0.rc3 app/controllers/cms/tasks_controller.rb
browsercms-3.5.0.rc2 app/controllers/cms/tasks_controller.rb
browsercms-3.5.0.rc1 app/controllers/cms/tasks_controller.rb
browsercms-3.4.2 app/controllers/cms/tasks_controller.rb
browsercms-3.4.2.rc1 app/controllers/cms/tasks_controller.rb
browsercms-3.4.1 app/controllers/cms/tasks_controller.rb
browsercms-3.4.0 app/controllers/cms/tasks_controller.rb