Class: Bumbleworks::Rails::TasksController
Instance Method Summary
collapse
#render_404, #render_unauthorized
#entity_task_path, #entity_task_url, #entity_tasks_path, #entity_tasks_url, #render_task_partial, #task_name
Instance Method Details
#claim ⇒ Object
34
35
36
37
38
39
40
41
42
|
# File 'app/controllers/bumbleworks/rails/tasks_controller.rb', line 34
def claim
current_user.claim(@task)
flash[:notice] = I18n.t('bumbleworks.tasks.claimed', :task => task_name(@task))
rescue Bumbleworks::User::UnauthorizedClaimAttempt,
Bumbleworks::Task::AlreadyClaimed => e
flash[:error] = e.message
ensure
redirect_to entity_task_path @task
end
|
#complete ⇒ Object
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'app/controllers/bumbleworks/rails/tasks_controller.rb', line 18
def complete
if @task.claimant == current_user.claim_token
@task.complete(params[:task] || {})
flash[:notice] = I18n.t('bumbleworks.tasks.completed', :task => task_name(@task))
redirect_to entity_tasks_path @entity
else
flash[:error] = I18n.t('bumbleworks.tasks.unclaimed_complete_attempt', :task => task_name(@task))
redirect_to entity_task_path @task
end
rescue Bumbleworks::Task::NotCompletable => e
flash[:error] = e.message
redirect_to entity_task_path @task
rescue Bumbleworks::Task::CompletionFailed
render :show, :prefixes => template_prefixes
end
|
#index ⇒ Object
9
10
11
12
13
14
15
16
|
# File 'app/controllers/bumbleworks/rails/tasks_controller.rb', line 9
def index
[:available_tasks, :claimed_tasks].each do |category|
tasks = current_user.send(category)
tasks = tasks.for_entity(@entity) if @entity
instance_variable_set("@#{category}", tasks)
end
render :prefixes => template_prefixes
end
|
#release ⇒ Object
44
45
46
47
48
49
50
51
|
# File 'app/controllers/bumbleworks/rails/tasks_controller.rb', line 44
def release
current_user.release(@task)
flash[:notice] = I18n.t('bumbleworks.tasks.released', :task => task_name(@task))
rescue Bumbleworks::User::UnauthorizedReleaseAttempt
flash[:error] = I18n.t('bumbleworks.tasks.unauthorized_release_attempt', :task => task_name(@task))
ensure
redirect_to entity_tasks_path @entity
end
|
#show ⇒ Object
5
6
7
|
# File 'app/controllers/bumbleworks/rails/tasks_controller.rb', line 5
def show
render :prefixes => template_prefixes
end
|