プロジェクト

全般

プロフィール

Vote #67815

未完了

acts_as_event email key

Admin Redmine さんが約2年前に追加. 約2年前に更新.

ステータス:
Confirmed
優先度:
通常
担当者:
-
カテゴリ:
Activity view_50
対象バージョン:
-
開始日:
2010/08/09
期日:
進捗率:

0%

予定工数:
category_id:
50
version_id:
0
issue_org_id:
6082
author_id:
3866
assigned_to_id:
0
comments:
5
status_id:
9
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Confirmed]

説明

When gravatars are enabled, the activity view tries to show the gravatar by passing a user object to the @avatar@ method. While this works for all events that have local users, the changeset model/event can't always create a local user object for the changeset while still having the email of the user that generated this changeset.

Concrete use-case: I have a git repository in which I have cherry-picked 2 revisions from a user not member of my redmine installation, in this case the changeset retains the author not as a user object, but as a string "name " (very much like git presents it), the changeset object only presents the "name" as the author (see source:/trunk/app/models/changeset.rb#L68). While this is correct behavior for places just polling @event_author@ for a name, the @avatar@ won't get the email address from it, though that information is present. I've changed the activity view to try to use @committer@ (the whole "name ", which @avatar@ parses corectly) if the "normal" way doesn't yield an avatar, the following line source:trunk/app/views/projects/activity.rhtml#L10

<%= avatar(e.event_author, :size => "24") if e.respond_to?(:event_author) %>

to read:

<%= (avatar(e.event_author, :size => "24") if e.respond_to?(:event_author)) or (avatar(e.committer, :size => "24") if e.respond_to?(:committer)) %>

This solves the problem for changesets, but will not solve it for the generic case.

I see 2 options here to deal with that: either extend @acts_as_event@ to also provide a method/an interface to query the author's email address (but that feels somewhat kludgy), or mock a (temporary) user object with the information we have (basically the name for the @to_s@ method and the email address for @email@) to provide the same interface as for "local users". This might break further along down the way though if anything polling the events expects to receive a full user object but only gets one with a very limited interface.


journals

--------------------------------------------------------------------------------
I have confirmed the issue on https://bugs.ruby-lang.org/.

Gravatar icons for committers who don't have an account of the Redmine are not displayed on the Activity page.

!{width: 547px; border: 1px solid grey;}.bugs_ruby-lang_org-activity.png!
--------------------------------------------------------------------------------
I created a helper method for the activity because it complicates the Redmine account and the Repository committer decisions.

<pre><code class="diff">
diff --git a/app/helpers/activities_helper.rb b/app/helpers/activities_helper.rb
index 49074b5617..d48a9939e1 100644
--- a/app/helpers/activities_helper.rb
+++ b/app/helpers/activities_helper.rb
@@ -30,4 +30,12 @@ module ActivitiesHelper
end
sorted_events
end
+
+ def activity_avatar(event)
+ return nil unless event.respond_to?(:event_author)
+
+ author = event.event_author
+ committer = event.respond_to?(:committer) ? event.committer : nil
+ avatar(author.is_a?(User) ? author : (committer || author))
+ end
end
diff --git a/app/views/activities/_activities.html.erb b/app/views/activities/_activities.html.erb
index aaeea76bc2..5de9a7fd37 100644
--- a/app/views/activities/_activities.html.erb
+++ b/app/views/activities/_activities.html.erb
@@ -4,7 +4,7 @@
<dl>
<% sort_activity_events(events_by_day[day]).each do |e, in_group| -%>
<dt class="<%= e.event_type %> icon icon-<%= e.event_type %> <%= "grouped" if in_group %> <%= User.current.logged? && e.respond_to?(:event_author) && User.current == e.event_author ? 'me' : nil %>">
- <%= avatar(e.event_author) if e.respond_to?(:event_author) %>
+ <%= activity_avatar(e) %>
<span class="time"><%= format_time(e.event_datetime, false) %></span>
<%= content_tag('span', e.project, :class => 'project') if @project.nil? || @project != e.project %>
<%= link_to format_activity_title(e.event_title), e.event_url %>
</code></pre>
--------------------------------------------------------------------------------
Thank you for posting the patch but the test fails.

<pre>
$ ruby test/functional/activities_controller_test.rb
Run options: --seed 15717

# Running:

.....E

Error:
ActivitiesControllerTest#test_index_with_mercurial_changesets_and_gravatar_enabled_should_display_gravatar:
NoMethodError: undefined method `committer' for nil:NilClass
test/functional/activities_controller_test.rb:312:in `test_index_with_mercurial_changesets_and_gravatar_enabled_should_display_gravatar'

bin/rails test test/functional/activities_controller_test.rb:302
</pre>
--------------------------------------------------------------------------------
Go MAEDA wrote:
> Thank you for posting the patch but the test fails.
>
> [...]

I was able to reproduce the test error.

<pre>
$ rm -rf tmp/test/mercurial_repository

$ ruby test/functional/activities_controller_test.rb
Run options: --seed 63630

# Running:

......E

Error:
ActivitiesControllerTest#test_index_with_mercurial_changesets_and_gravatar_enabled_should_display_gravatar:
NoMethodError: undefined method `committer' for nil:NilClass
test/functional/activities_controller_test.rb:313:in `test_index_with_mercurial_changesets_and_gravatar_enabled_should_display_gravatar'

bin/rails test test/functional/activities_controller_test.rb:303

...........

Finished in 3.751118s, 4.7986 runs/s, 16.5284 assertions/s.
18 runs, 62 assertions, 0 failures, 1 errors, 0 skips
</pre>

Please execute @bundle exec rake test:scm:setup:mercurial@ to create the Mercurial repository.
--------------------------------------------------------------------------------

Admin Redmine さんが約2年前に更新

  • カテゴリActivity view_50 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0