From 6e777b745305b627c934d5585ca2083b482011d0 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sun, 30 Nov 2008 12:12:06 +0000 Subject: [PATCH] Makes activity view accept a user_id param to show user's activity (#1002). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2067 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/controllers/projects_controller.rb | 17 ++++++++++++++--- app/views/projects/activity.rhtml | 5 +++-- lang/bg.yml | 1 + lang/ca.yml | 1 + lang/cs.yml | 1 + lang/da.yml | 1 + lang/de.yml | 1 + lang/en.yml | 1 + lang/es.yml | 1 + lang/fi.yml | 1 + lang/fr.yml | 3 ++- lang/he.yml | 1 + lang/hu.yml | 1 + lang/it.yml | 1 + lang/ja.yml | 1 + lang/ko.yml | 1 + lang/lt.yml | 1 + lang/nl.yml | 1 + lang/no.yml | 1 + lang/pl.yml | 1 + lang/pt-br.yml | 1 + lang/pt.yml | 1 + lang/ro.yml | 1 + lang/ru.yml | 1 + lang/sk.yml | 1 + lang/sr.yml | 1 + lang/sv.yml | 1 + lang/th.yml | 1 + lang/tr.yml | 1 + lang/uk.yml | 1 + lang/vn.yml | 1 + lang/zh-tw.yml | 1 + lang/zh.yml | 1 + lib/redmine/activity/fetcher.rb | 10 +++++++++- test/functional/projects_controller_test.rb | 18 ++++++++++++++++++ 35 files changed, 76 insertions(+), 7 deletions(-) diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index a7efa4695..43e1ae035 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -227,10 +227,13 @@ class ProjectsController < ApplicationController @date_to ||= Date.today + 1 @date_from = @date_to - @days @with_subprojects = params[:with_subprojects].nil? ? Setting.display_subprojects_issues? : (params[:with_subprojects] == '1') + @author = (params[:user_id] ? User.find_active(params[:user_id]) : nil) - @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project, :with_subprojects => @with_subprojects) + @activity = Redmine::Activity::Fetcher.new(User.current, :project => @project, + :with_subprojects => @with_subprojects, + :author => @author) @activity.scope_select {|t| !params["show_#{t}"].nil?} - @activity.default_scope! if @activity.scope.empty? + @activity.scope = (@author.nil? ? :default : :all) if @activity.scope.empty? events = @activity.events(@date_from, @date_to) @@ -240,10 +243,18 @@ class ProjectsController < ApplicationController render :layout => false if request.xhr? } format.atom { - title = (@activity.scope.size == 1) ? l("label_#{@activity.scope.first.singularize}_plural") : l(:label_activity) + title = l(:label_activity) + if @author + title = @author.name + elsif @activity.scope.size == 1 + title = l("label_#{@activity.scope.first.singularize}_plural") + end render_feed(events, :title => "#{@project || Setting.app_title}: #{title}") } end + + rescue ActiveRecord::RecordNotFound + render_404 end private diff --git a/app/views/projects/activity.rhtml b/app/views/projects/activity.rhtml index 5157dda7a..d067a6753 100644 --- a/app/views/projects/activity.rhtml +++ b/app/views/projects/activity.rhtml @@ -1,4 +1,4 @@ -

<%= l(:label_activity) %>

+

<%= @author.nil? ? l(:label_activity) : l(:label_user_activity, @author.to_s) %>

<%= "#{l(:label_date_from)} #{format_date(@date_to - @days)} #{l(:label_date_to).downcase} #{format_date(@date_to-1)}" %>

@@ -52,8 +52,9 @@

<%= hidden_field_tag 'with_subprojects', 0 %> <% end %> +<%= hidden_field_tag 'user_id', params[:user_id] %>

<%= submit_tag l(:button_apply), :class => 'button-small', :name => nil %>

<% end %> <% end %> -<% html_title(l(:label_activity)) -%> +<% html_title(l(:label_activity), @author) -%> diff --git a/lang/bg.yml b/lang/bg.yml index 17afe9eb4..40a7b6c8c 100644 --- a/lang/bg.yml +++ b/lang/bg.yml @@ -692,3 +692,4 @@ label_example: Example text_repository_usernames_mapping: "Select ou update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lang/ca.yml b/lang/ca.yml index 4179aa441..66805c45d 100644 --- a/lang/ca.yml +++ b/lang/ca.yml @@ -693,3 +693,4 @@ label_example: Example text_repository_usernames_mapping: "Select ou update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lang/cs.yml b/lang/cs.yml index 189f47244..e458b31b8 100644 --- a/lang/cs.yml +++ b/lang/cs.yml @@ -697,3 +697,4 @@ label_example: Example text_repository_usernames_mapping: "Select ou update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lang/da.yml b/lang/da.yml index d1b569713..d4bce1d50 100644 --- a/lang/da.yml +++ b/lang/da.yml @@ -693,3 +693,4 @@ label_example: Example text_repository_usernames_mapping: "Select ou update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lang/de.yml b/lang/de.yml index b23edd9c3..ee38db54e 100644 --- a/lang/de.yml +++ b/lang/de.yml @@ -694,3 +694,4 @@ default_activity_development: Entwicklung enumeration_issue_priorities: Ticket-Prioritäten enumeration_doc_categories: Dokumentenkategorien enumeration_activities: Aktivitäten (Zeiterfassung) +label_user_activity: "%s's activity" diff --git a/lang/en.yml b/lang/en.yml index 80751f0ab..1d5a66443 100644 --- a/lang/en.yml +++ b/lang/en.yml @@ -344,6 +344,7 @@ label_last_updates_plural: %d last updated label_registered_on: Registered on label_activity: Activity label_overall_activity: Overall activity +label_user_activity: "%s's activity" label_new: New label_logged_as: Logged in as label_environment: Environment diff --git a/lang/es.yml b/lang/es.yml index 74c3d496e..65d08b2ce 100644 --- a/lang/es.yml +++ b/lang/es.yml @@ -677,3 +677,4 @@ text_user_mail_option: "En los proyectos no seleccionados, sólo recibirá notif text_user_wrote: '%s escribió:' text_wiki_destroy_confirmation: ¿Seguro que quiere borrar el wiki y todo su contenido? text_workflow_edit: Seleccionar un flujo de trabajo para actualizar +label_user_activity: "%s's activity" diff --git a/lang/fi.yml b/lang/fi.yml index b028fd1f5..fb245412b 100644 --- a/lang/fi.yml +++ b/lang/fi.yml @@ -692,3 +692,4 @@ label_example: Example text_repository_usernames_mapping: "Select ou update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lang/fr.yml b/lang/fr.yml index 1c2bce3ca..730a43d26 100644 --- a/lang/fr.yml +++ b/lang/fr.yml @@ -170,7 +170,6 @@ field_start_page: Page de démarrage field_subproject: Sous-projet field_hours: Heures field_activity: Activité -label_overall_activity: Activité globale field_spent_on: Date field_identifier: Identifiant field_is_filter: Utilisé comme filtre @@ -344,6 +343,8 @@ label_last_updates: Dernière mise à jour label_last_updates_plural: %d dernières mises à jour label_registered_on: Inscrit le label_activity: Activité +label_overall_activity: Activité globale +label_user_activity: "Activité de %s" label_new: Nouveau label_logged_as: Connecté en tant que label_environment: Environnement diff --git a/lang/he.yml b/lang/he.yml index e32259ba5..87d3b0851 100644 --- a/lang/he.yml +++ b/lang/he.yml @@ -692,3 +692,4 @@ label_example: Example text_repository_usernames_mapping: "Select ou update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lang/hu.yml b/lang/hu.yml index 61831cedb..af91e1b4b 100644 --- a/lang/hu.yml +++ b/lang/hu.yml @@ -693,3 +693,4 @@ label_example: Példa text_repository_usernames_mapping: "Állítsd be a felhasználó összerendeléseket a Redmine, és a tároló logban található felhasználók között.\nAz azonos felhasználó nevek összerendelése automatikusan megtörténik." permission_edit_own_messages: Saját üzenetek szerkesztése permission_delete_own_messages: Saját üzenetek törlése +label_user_activity: "%s's activity" diff --git a/lang/it.yml b/lang/it.yml index d40b487f7..1ee5b72bb 100644 --- a/lang/it.yml +++ b/lang/it.yml @@ -692,3 +692,4 @@ label_example: Esempio text_repository_usernames_mapping: "Seleziona per aggiornare la corrispondenza tra gli utenti Redmine e quelli presenti nel log del repository.\nGli utenti Redmine e repository con lo stesso username o email sono mappati automaticamente." permission_edit_own_messages: Modifica propri messaggi permission_delete_own_messages: Elimina propri messaggi +label_user_activity: "%s's activity" diff --git a/lang/ja.yml b/lang/ja.yml index 8d106bf64..3e9240330 100644 --- a/lang/ja.yml +++ b/lang/ja.yml @@ -693,3 +693,4 @@ label_example: Example text_repository_usernames_mapping: "Select ou update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lang/ko.yml b/lang/ko.yml index 65a5f4434..b3cc59793 100644 --- a/lang/ko.yml +++ b/lang/ko.yml @@ -692,3 +692,4 @@ label_example: Example text_repository_usernames_mapping: "Select ou update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lang/lt.yml b/lang/lt.yml index 535f0416b..2e2018f47 100644 --- a/lang/lt.yml +++ b/lang/lt.yml @@ -694,3 +694,4 @@ label_example: Example text_repository_usernames_mapping: "Select ou update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lang/nl.yml b/lang/nl.yml index f138fc89b..216f238f6 100644 --- a/lang/nl.yml +++ b/lang/nl.yml @@ -694,3 +694,4 @@ label_example: Example text_repository_usernames_mapping: "Select ou update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lang/no.yml b/lang/no.yml index db4a320d2..6cde8edc6 100644 --- a/lang/no.yml +++ b/lang/no.yml @@ -693,3 +693,4 @@ label_example: Example text_repository_usernames_mapping: "Select ou update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lang/pl.yml b/lang/pl.yml index 64457b5fb..01025a686 100644 --- a/lang/pl.yml +++ b/lang/pl.yml @@ -711,3 +711,4 @@ text_user_wrote: '%s napisał:' text_wiki_destroy_confirmation: Jesteś pewien, że chcesz usunąć to wiki i całą jego zawartość ? text_workflow_edit: Zaznacz rolę i typ zagadnienia do edycji przepływu +label_user_activity: "%s's activity" diff --git a/lang/pt-br.yml b/lang/pt-br.yml index b6fdf9d02..7083d9680 100644 --- a/lang/pt-br.yml +++ b/lang/pt-br.yml @@ -693,3 +693,4 @@ label_example: Exemplo text_repository_usernames_mapping: "Seleciona ou atualiza os usuários do Redmine mapeando para cada usuário encontrado no log do repositório.\nUsuários com o mesmo login ou email no Redmine e no repositório serão mapeados automaticamente." permission_edit_own_messages: Editar próprias mensagens permission_delete_own_messages: Excluir próprias mensagens +label_user_activity: "%s's activity" diff --git a/lang/pt.yml b/lang/pt.yml index 604f5dad1..1ada0675b 100644 --- a/lang/pt.yml +++ b/lang/pt.yml @@ -694,3 +694,4 @@ label_example: Example text_repository_usernames_mapping: "Select ou update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lang/ro.yml b/lang/ro.yml index 6527442e2..f3a59b20d 100644 --- a/lang/ro.yml +++ b/lang/ro.yml @@ -692,3 +692,4 @@ label_example: Example text_repository_usernames_mapping: "Select ou update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lang/ru.yml b/lang/ru.yml index 24b580d49..a96b5cadb 100644 --- a/lang/ru.yml +++ b/lang/ru.yml @@ -725,3 +725,4 @@ text_user_mail_option: "Для невыбранных проектов, Вы б text_user_wrote: '%s написал(а):' text_wiki_destroy_confirmation: Вы уверены, что хотите удалить данную Wiki и все ее содержимое? text_workflow_edit: Выберите роль и трекер для редактирования последовательности состояний +label_user_activity: "%s's activity" diff --git a/lang/sk.yml b/lang/sk.yml index 2237be519..09a5f6b5c 100644 --- a/lang/sk.yml +++ b/lang/sk.yml @@ -698,3 +698,4 @@ label_example: Príklad permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages text_repository_usernames_mapping: "Select or update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." +label_user_activity: "%s's activity" diff --git a/lang/sr.yml b/lang/sr.yml index fdfa411d2..702dad7a2 100644 --- a/lang/sr.yml +++ b/lang/sr.yml @@ -693,3 +693,4 @@ setting_gravatar_enabled: Use Gravatar user icons permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages text_repository_usernames_mapping: "Select or update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." +label_user_activity: "%s's activity" diff --git a/lang/sv.yml b/lang/sv.yml index b50fc0c42..8c9b6f6ef 100644 --- a/lang/sv.yml +++ b/lang/sv.yml @@ -693,3 +693,4 @@ label_example: Example text_repository_usernames_mapping: "Select ou update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lang/th.yml b/lang/th.yml index 129982dfa..3611b790c 100644 --- a/lang/th.yml +++ b/lang/th.yml @@ -695,3 +695,4 @@ label_example: Example text_repository_usernames_mapping: "Select ou update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lang/tr.yml b/lang/tr.yml index ba9b4b625..8b6ccc6c9 100644 --- a/lang/tr.yml +++ b/lang/tr.yml @@ -693,3 +693,4 @@ label_example: Example text_repository_usernames_mapping: "Select ou update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lang/uk.yml b/lang/uk.yml index 3934e9ad2..b84392c16 100644 --- a/lang/uk.yml +++ b/lang/uk.yml @@ -694,3 +694,4 @@ label_example: Example text_repository_usernames_mapping: "Select ou update the Redmine user mapped to each username found in the repository log.\nUsers with the same Redmine and repository username or email are automatically mapped." permission_edit_own_messages: Edit own messages permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lang/vn.yml b/lang/vn.yml index d1885d9b4..ecdfba533 100644 --- a/lang/vn.yml +++ b/lang/vn.yml @@ -695,3 +695,4 @@ permission_delete_own_messages: Xóa bài viết cá nhân label_example: Ví dụ text_repository_usernames_mapping: "Chọn hoặc cập nhật ánh xạ người dùng hệ thống với người dùng trong kho lưu trữ.\nNhững trường hợp trùng hợp về tên và email sẽ được tự động ánh xạ." permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lang/zh-tw.yml b/lang/zh-tw.yml index cdc54176c..879e47ca3 100644 --- a/lang/zh-tw.yml +++ b/lang/zh-tw.yml @@ -694,3 +694,4 @@ default_activity_development: 開發 enumeration_issue_priorities: 項目優先權 enumeration_doc_categories: 文件分類 enumeration_activities: 活動 (時間追蹤) +label_user_activity: "%s's activity" diff --git a/lang/zh.yml b/lang/zh.yml index 6c0499010..9159974c5 100644 --- a/lang/zh.yml +++ b/lang/zh.yml @@ -695,3 +695,4 @@ enumeration_issue_priorities: 问题优先级 enumeration_doc_categories: 文档类别 enumeration_activities: 活动(时间跟踪) permission_delete_own_messages: Delete own messages +label_user_activity: "%s's activity" diff --git a/lib/redmine/activity/fetcher.rb b/lib/redmine/activity/fetcher.rb index b12caa441..1d0bd8a16 100644 --- a/lib/redmine/activity/fetcher.rb +++ b/lib/redmine/activity/fetcher.rb @@ -48,8 +48,16 @@ module Redmine end # Sets the scope + # Argument can be :all, :default or an array of event types def scope=(s) - @scope = s & event_types + case s + when :all + @scope = event_types + when :default + default_scope! + else + @scope = s & event_types + end end # Resets the scope to the default scope diff --git a/test/functional/projects_controller_test.rb b/test/functional/projects_controller_test.rb index 1b36a9d6b..d1810b3d4 100644 --- a/test/functional/projects_controller_test.rb +++ b/test/functional/projects_controller_test.rb @@ -203,6 +203,24 @@ class ProjectsControllerTest < Test::Unit::TestCase } end + def test_user_activity + get :activity, :user_id => 2 + assert_response :success + assert_template 'activity' + assert_not_nil assigns(:events_by_day) + + assert_tag :tag => "h3", + :content => /#{3.day.ago.to_date.day}/, + :sibling => { :tag => "dl", + :child => { :tag => "dt", + :attributes => { :class => /issue/ }, + :child => { :tag => "a", + :content => /#{Issue.find(1).subject}/, + } + } + } + end + def test_activity_atom_feed get :activity, :format => 'atom' assert_response :success -- 2.39.5