Class: Cms::TasksController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- ApplicationController
- ApplicationController
- BaseController
- Cms::TasksController
- Defined in:
- app/controllers/cms/tasks_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
#complete ⇒ Object
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/tasks_controller.rb', line 21 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 |
#create ⇒ Object
10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/cms/tasks_controller.rb', line 10 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 |
#new ⇒ Object
6 7 8 |
# File 'app/controllers/cms/tasks_controller.rb', line 6 def new @task = @page.tasks.build(:assigned_by => current_user) end |