Modified: trunk/app/controllers/networks_controller.rb (3481 => 3482)
--- trunk/app/controllers/networks_controller.rb 2013-03-15 15:25:53 UTC (rev 3481)
+++ trunk/app/controllers/networks_controller.rb 2013-03-19 09:12:41 UTC (rev 3482)
@@ -255,99 +255,8 @@
# GET /networks/1
def show
-
- @item_sort_options = [
- ["rank", "Rank"],
- ["most_recent", "Most recent"],
- ["title", "Title"],
- ["uploader", "Uploader"],
- ["last_updated", "Last updated"],
- ["rating", "User rating"],
- ["licence", "Licence"],
- ["content_type", "Content Type"]
- ]
-
@shared_items = @network.shared_contributions
- case params[:item_sort]
-
- when "rank"; @shared_items.sort! do |a, b|
- b.rank <=> a.rank
- end
-
- when "title"; @shared_items.sort! do |a, b|
- a.contributable.label <=> b.contributable.label
- end
-
- when "most_recent"; @shared_items.sort! do |a, b|
- b.contributable.created_at <=> a.contributable.created_at
- end
-
- when "uploader"; @shared_items.sort! do |a, b|
- if a.contributor.label == b.contributor.label
- b.rank <=> a.rank
- else
- a.contributor.label <=> b.contributor.label
- end
- end
-
- when "last_updated"; @shared_items.sort! do |a, b|
- b.contributable.updated_at <=> a.contributable.updated_at
- end
-
- when "rating"; @shared_items.sort! do |a, b|
-
- a_rating = a.rating
- b_rating = b.rating
-
- if a_rating == b_rating
- b.rank <=> a.rank
- else
- b.rating <=> a.rating
- end
- end
-
- when "licence"; @shared_items.sort! do |a, b|
-
- a_has_licence = a.contributable.respond_to?('license')
- b_has_licence = b.contributable.respond_to?('license')
-
- if (a_has_licence && b_has_licence)
- if a.contributable.license == b.contributable.license
- b.rank <=> a.rank
- else
- a.contributable.license.title <=> b.contributable.license.title
- end
- elsif (a_has_licence && !b_has_licence)
- -1
- elsif (!a_has_licence && b_has_licence)
- 1
- else
- b.rank <=> a.rank
- end
- end
-
- when "content_type"; @shared_items.sort! do |a, b|
-
- a_has_content_type = a.contributable.respond_to?('content_type')
- b_has_content_type = b.contributable.respond_to?('content_type')
-
- if (a_has_content_type && b_has_content_type)
- if a.contributable.content_type == b.contributable.content_type
- b.rank <=> a.rank
- else
- a.contributable.content_type.title <=> b.contributable.content_type.title
- end
- elsif (a_has_content_type && !b_has_content_type)
- -1
- elsif (!a_has_content_type && b_has_content_type)
- 1
- else
- b.rank <=> a.rank
- end
- end
- end
-
respond_to do |format|
format.html {