Commit fbbb2470c1bd6e9c52f456616ffd40fb92c76544

Authored by Antonio Terceiro
1 parent e1d1cd19

Tasks: need to filter only on actual list of tasks

Let's quite this string programming there. We do not need to keep a list
of all types of tasks, we just need to take the actual list of tasks,
and create the filter list accordingly.
app/models/task.rb
... ... @@ -73,10 +73,6 @@ class Task < ActiveRecord::Base
73 73 end
74 74 end
75 75  
76   - def self.all_types
77   - %w[Invitation EnterpriseActivation AddMember Ticket SuggestArticle AddFriend CreateCommunity AbuseComplaint ApproveComment ApproveArticle CreateEnterprise ChangePassword EmailActivation InviteFriend InviteMember]
78   - end
79   -
80 76 # this method finished the task. It calls #perform, which must be overriden
81 77 # by subclasses. At the end a message (as returned by #finish_message) is
82 78 # sent to the requestor with #notify_requestor.
... ...
app/views/tasks/index.html.erb
... ... @@ -3,9 +3,10 @@
3 3 <h1><%= _("%s's pending tasks") % profile.name %></h1>
4 4 <p>
5 5  
6   -<% type_collection = [[nil, _('All')]] %>
7   -<% type_collection += Task.all_types.sort_by {|klass| klass.constantize.new.title}.map{|s| [s, s.constantize.new.title] } %>
8   -
  6 +<%
  7 + type_collection = [[nil, _('All')]]
  8 + type_collection += @tasks.map { |t| [t.name, t.title] }.uniq
  9 +%>
9 10  
10 11  
11 12 <% if !@failed.blank? %>
... ...