21: def complete
22: if params[:task_ids]
23: Task.all(:conditions => ["id in (?)", params[:task_ids]]).each do |t|
24: if t.assigned_to == current_user
25: t.mark_as_complete!
26: end
27: end
28: flash[:notice] = "Tasks marked as complete"
29: redirect_to cms_dashboard_path
30: else
31: @task = Task.find(params[:id])
32: if @task.assigned_to == current_user
33: if @task.mark_as_complete!
34: flash[:notice] = "Task was marked as complete"
35: end
36: else
37: flash[:error] = "You cannot complete tasks that are not assigned to you"
38: end
39: redirect_to @task.page.path
40: end
41: end