diff --git a/app/controllers/my_profile/tasks_controller.rb b/app/controllers/my_profile/tasks_controller.rb index ac70439..9e3c268 100644 --- a/app/controllers/my_profile/tasks_controller.rb +++ b/app/controllers/my_profile/tasks_controller.rb @@ -4,6 +4,7 @@ class TasksController < MyProfileController def index @filter = params[:filter_type].blank? ? nil : params[:filter_type] + @task_types = Task.pending_types_for(profile) @tasks = Task.to(profile).without_spam.pending.of(@filter).order_by('created_at', 'asc').paginate(:per_page => Task.per_page, :page => params[:page]) @failed = params ? params[:failed] : {} end diff --git a/app/models/task.rb b/app/models/task.rb index 6163261..f74bc73 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -250,6 +250,10 @@ class Task < ActiveRecord::Base { :conditions => [environment_condition, profile_condition].compact.join(' OR ') } } + def self.pending_types_for(profile) + Task.to(profile).pending.select('distinct type').map { |t| [t.class.name, t.title] } + end + def opened? status == Task::Status::ACTIVE || status == Task::Status::HIDDEN end diff --git a/app/views/tasks/index.html.erb b/app/views/tasks/index.html.erb index 17d01b8..7249341 100644 --- a/app/views/tasks/index.html.erb +++ b/app/views/tasks/index.html.erb @@ -4,11 +4,9 @@

<% - type_collection = [[nil, _('All')]] - type_collection += @tasks.map { |t| [t.name, t.title] }.uniq + type_collection = [[nil, _('All')]] + @task_types %> - <% if !@failed.blank? %>

<% @failed.each do |error, tasks_descriptions|%> @@ -40,7 +38,7 @@