Skip to content

Commit

Permalink
small fixes, still using old sharing code
Browse files Browse the repository at this point in the history
  • Loading branch information
molpe committed Aug 29, 2009
1 parent 67e201b commit 0a64ea2
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/controllers/member/sharings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def index
end

def new
@sharing = GroupSharing.new(:shareable_type => params[:shareable_type], :shareable_id => params[:shareable_id])
@sharing = Share.new(:shareable_type => params[:shareable_type], :shareable_id => params[:shareable_id])
@shareable = @sharing.shareable
@groups = current_user.groups
@referer = request.referer
Expand Down Expand Up @@ -62,4 +62,4 @@ def find_group
@group = Group.find(params[:group_id]) if params[:group_id]
end

end
end
28 changes: 19 additions & 9 deletions app/helpers/sharings_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,27 @@ def share_link(link_text, share_with, shareable)
:html => {:title => I18n.t("tog_social.sharings.member.share_with", :name => share_with.name)}
end
end

def shared_to_title(sharing)
title_for_object(sharing.shared_to)
end

def shareable_title(sharing)
title_for_object(sharing.shareable)
end

def shareable_title(shareable)
if (shareable.respond_to?(:name))
string = shareable.name
elsif (shareable.respond_to?(:title))
string = shareable.title
else
string = shareable.to_s
private

def title_for_object(obj)
if (obj.respond_to?(:name))
string = obj.name
elsif (obj.respond_to?(:title))
string = obj.title
else
string = obj.to_s
end
string
end
string
end

end

8 changes: 4 additions & 4 deletions app/views/member/sharings/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
<% for sharing in @sharings %>
<tr<%= cycle(' class="pair"', '') -%>>
<td><%= shareable_title(sharing) %></td>
<td><%= link_to sharing.group.name, group_path(sharing.group) %></td>
<td><%= sharing.creation_date %></td>
<td><%= link_to shared_to_title(sharing), sharing.shared_to %></td>
<td><%= I18n.l(sharing.created_at, :format => :short) %></td>
<td><%= link_to I18n.t('tog_social.sharings.member.remove_share'),
member_destroy_sharing_path(sharing.group, sharing),
:method => :delete, :confirm => I18n.t('tog_social.sharings.member.remove_confirmation', :object => shareable_title(sharing), :group => sharing.group.name) %></td>
member_destroy_sharing_path(sharing.shared_to, sharing),
:method => :delete, :confirm => I18n.t('tog_social.sharings.member.remove_confirmation', :object => shareable_title(sharing), :group => shared_to_title(sharing)) %></td>
</tr>
<% end %>
</tbody>
Expand Down

0 comments on commit 0a64ea2

Please sign in to comment.