]> git.openstreetmap.org Git - rails.git/blob - app/helpers/changeset_helper.rb
Update bundle
[rails.git] / app / helpers / changeset_helper.rb
1 module ChangesetHelper
2   def changeset_user_link(changeset)
3     if changeset.user.status == "deleted"
4       t("user.no_such_user.deleted")
5     elsif changeset.user.data_public?
6       link_to(changeset.user.display_name, user_path(changeset.user.display_name))
7     else
8       t("browse.anonymous")
9     end
10   end
11
12   def changeset_details(changeset)
13     if changeset.closed_at > DateTime.now
14       action = :created
15       time = distance_of_time_in_words_to_now(changeset.created_at)
16       title = l(changeset.created_at)
17     else
18       action = :closed
19       time = distance_of_time_in_words_to_now(changeset.closed_at)
20       title = "#{t('browse.created')}: #{l(changeset.created_at)}
#{t('browse.closed')}: #{l(changeset.closed_at)}".html_safe
21     end
22
23     if params.key?(:display_name)
24       t "browse.#{action}_html",
25         :time => time,
26         :title => title
27     else
28       t "browse.#{action}_by_html",
29         :time => time,
30         :title => title,
31         :user => changeset_user_link(changeset)
32     end
33   end
34
35   def changeset_list_title(params, user)
36     if params[:friends] && user
37       t "changeset.list.title_friend"
38     elsif params[:nearby] && user
39       t "changeset.list.title_nearby"
40     elsif params[:display_name]
41       t "changeset.list.title_user", :user => params[:display_name]
42     else
43       t "changeset.list.title"
44     end
45   end
46 end