Class: Cms::TaskItemsController

Inherits:
BaseController show all
Defined in:
app/controllers/cms/task_items_controller.rb

Instance Method Summary collapse

Methods included from PageHelper

#able_to?, #cms_toolbar, #container, #container_has_block?, #current_page, #page_title, #render_breadcrumbs, #render_portlet

Methods included from PathHelper

#cms_connectable_path, #cms_index_path_for, #cms_index_url_for, #cms_new_path_for, #cms_new_url_for, #edit_cms_connectable_path

Methods included from ErrorHandling

#handle_access_denied, #handle_server_error, included

Instance Method Details

#completeObject



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'app/controllers/cms/task_items_controller.rb', line 21

def complete
  if params[:task_item_ids]
    TaskItem.all(:conditions => ["id in (?)", params[:task_item_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_item = TaskItem.find(params[:id])
    if @task_item.assigned_to == current_user
      if @task_item.mark_as_complete!
        flash[:notice] = "Task was marked as complete"
      end
    else
      flash[:error] = "You cannot complete task_items that are not assigned to you"
    end
    redirect_to @task_item.page.path
  end
end

#createObject



10
11
12
13
14
15
16
17
18
19
# File 'app/controllers/cms/task_items_controller.rb', line 10

def create
  @task_item = @page.task_items.build(params[:task_item])
  @task_item.assigned_by = current_user
  if @task_item.save
    flash[:notice] = "Page was assigned to '#{@task_item.assigned_to.}'"
    redirect_to @page.path
  else
    render :action => 'new'
  end
end

#newObject



6
7
8
# File 'app/controllers/cms/task_items_controller.rb', line 6

def new
  @task_item = @page.task_items.build(:assigned_by => current_user)
end