Feature #23954 » last_activity-3.r3.4.patch
| app/controllers/admin_controller.rb | ||
|---|---|---|
| 38 | 38 |
@project_pages = Paginator.new @project_count, per_page_option, params['page'] |
| 39 | 39 |
@projects = scope.limit(@project_pages.per_page).offset(@project_pages.offset).to_a |
| 40 | 40 | |
| 41 |
@last_activity = Redmine::Activity::Fetcher.new(User.current).events(nil, nil, :last_by_project => true).to_h |
|
| 42 | ||
| 41 | 43 |
render :action => "projects", :layout => false if request.xhr? |
| 42 | 44 |
end |
| 43 | 45 | |
| app/views/admin/projects.html.erb | ||
|---|---|---|
| 23 | 23 |
<th><%=l(:label_project)%></th> |
| 24 | 24 |
<th><%=l(:field_is_public)%></th> |
| 25 | 25 |
<th><%=l(:field_created_on)%></th> |
| 26 |
<th><%=l(:field_last_activity)%></th> |
|
| 26 | 27 |
<th></th> |
| 27 | 28 |
</tr></thead> |
| 28 | 29 |
<tbody> |
| ... | ... | |
| 31 | 32 |
<td class="name"><span><%= link_to_project_settings(project, {}, :title => project.short_description) %></span></td>
|
| 32 | 33 |
<td><%= checked_image project.is_public? %></td> |
| 33 | 34 |
<td><%= format_date(project.created_on) %></td> |
| 35 |
<td><%= format_date(@last_activity[project.id]) %></td> |
|
| 34 | 36 |
<td class="buttons"> |
| 35 | 37 |
<%= link_to(l(:button_archive), archive_project_path(project, :status => params[:status]), :data => {:confirm => l(:text_are_you_sure)}, :method => :post, :class => 'icon icon-lock') unless project.archived? %>
|
| 36 | 38 |
<%= link_to(l(:button_unarchive), unarchive_project_path(project, :status => params[:status]), :method => :post, :class => 'icon icon-unlock') if project.archived? && (project.parent.nil? || !project.parent.archived?) %> |
| config/locales/en.yml | ||
|---|---|---|
| 258 | 258 |
field_downloads: Downloads |
| 259 | 259 |
field_author: Author |
| 260 | 260 |
field_created_on: Created |
| 261 |
field_last_activity: Last activity |
|
| 261 | 262 |
field_updated_on: Updated |
| 262 | 263 |
field_closed_on: Closed |
| 263 | 264 |
field_field_format: Format |
| config/locales/pt-BR.yml | ||
|---|---|---|
| 224 | 224 |
field_downloads: Downloads |
| 225 | 225 |
field_author: Autor |
| 226 | 226 |
field_created_on: Criado em |
| 227 |
field_last_activity: Última atividade |
|
| 227 | 228 |
field_updated_on: Alterado em |
| 228 | 229 |
field_field_format: Formato |
| 229 | 230 |
field_is_for_all: Para todos os projetos |
| lib/plugins/acts_as_activity_provider/lib/acts_as_activity_provider.rb | ||
|---|---|---|
| 55 | 55 | |
| 56 | 56 |
scope = (provider_options[:scope] || self) |
| 57 | 57 | |
| 58 |
if from && to |
|
| 59 |
scope = scope.where("#{provider_options[:timestamp]} BETWEEN ? AND ?", from, to)
|
|
| 60 |
end |
|
| 58 |
scope = scope.where("#{provider_options[:timestamp]} >= ?", from) if from
|
|
| 59 |
scope = scope.where("#{provider_options[:timestamp]} <= ?", to) if to
|
|
| 61 | 60 | |
| 62 | 61 |
if options[:author] |
| 63 | 62 |
return [] if provider_options[:author_key].nil? |
| ... | ... | |
| 78 | 77 |
scope = scope.where(Project.allowed_to_condition(user, "view_#{self.name.underscore.pluralize}".to_sym, options))
|
| 79 | 78 |
end |
| 80 | 79 | |
| 80 |
if options[:next_by_project] |
|
| 81 |
scope = scope.group("projects.id").minimum(provider_options[:timestamp])
|
|
| 82 |
end |
|
| 83 | ||
| 84 |
if options[:last_by_project] |
|
| 85 |
scope = scope.group("projects.id").maximum(provider_options[:timestamp])
|
|
| 86 |
end |
|
| 87 | ||
| 81 | 88 |
scope.to_a |
| 82 | 89 |
end |
| 83 | 90 |
end |
| lib/redmine/activity/fetcher.rb | ||
|---|---|---|
| 85 | 85 |
def events(from = nil, to = nil, options={})
|
| 86 | 86 |
e = [] |
| 87 | 87 |
@options[:limit] = options[:limit] |
| 88 |
@options[:last_by_project] = options[:last_by_project] if options[:last_by_project] |
|
| 89 |
@options[:next_by_project] = options[:next_by_project] if options[:next_by_project] |
|
| 88 | 90 | |
| 89 | 91 |
@scope.each do |event_type| |
| 90 | 92 |
constantized_providers(event_type).each do |provider| |
| ... | ... | |
| 92 | 94 |
end |
| 93 | 95 |
end |
| 94 | 96 | |
| 95 |
e.sort! {|a,b| b.event_datetime <=> a.event_datetime}
|
|
| 97 |
if options[:last_by_project] |
|
| 98 |
e.sort! |
|
| 99 |
elsif options[:next_by_project] |
|
| 100 |
e.sort! {|a,b| b <=> a}
|
|
| 101 |
else |
|
| 102 |
e.sort! {|a,b| b.event_datetime <=> a.event_datetime}
|
|
| 96 | 103 | |
| 97 |
if options[:limit] |
|
| 98 |
e = e.slice(0, options[:limit]) |
|
| 104 |
if options[:limit] |
|
| 105 |
e = e.slice(0, options[:limit]) |
|
| 106 |
end |
|
| 99 | 107 |
end |
| 100 | 108 |
e |
| 101 | 109 |
end |