From f4c5126b1145f05dbf932db3e63d0174d1760213 Mon Sep 17 00:00:00 2001 From: Toks Date: Thu, 11 Jul 2013 20:56:20 -0400 Subject: [PATCH] Add link to last page of pool from index; fixes #1848 --- app/assets/stylesheets/specific/pools.css.scss | 4 ++++ app/models/pool.rb | 4 ++++ app/views/pools/index.html.erb | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/app/assets/stylesheets/specific/pools.css.scss b/app/assets/stylesheets/specific/pools.css.scss index 422018431..4d1fff9b4 100644 --- a/app/assets/stylesheets/specific/pools.css.scss +++ b/app/assets/stylesheets/specific/pools.css.scss @@ -47,6 +47,10 @@ div#c-pools { span.inactive { color: #AAA; } + + a.last-page { + color: #666; + } div#a-show { div#description { diff --git a/app/models/pool.rb b/app/models/pool.rb index 6e126b3a4..29fdf5d90 100644 --- a/app/models/pool.rb +++ b/app/models/pool.rb @@ -289,6 +289,10 @@ class Pool < ActiveRecord::Base end end + def last_page + (post_count / CurrentUser.user.per_page.to_f).ceil + end + def reload(options = {}) super @neighbor_posts = nil diff --git a/app/views/pools/index.html.erb b/app/views/pools/index.html.erb index 5b73f2833..64c5d9a43 100644 --- a/app/views/pools/index.html.erb +++ b/app/views/pools/index.html.erb @@ -17,6 +17,10 @@ <%= link_to h(pool.pretty_name), pool_path(pool), :class => "pool-category-#{pool.category}" %> + + <% if pool.post_count > CurrentUser.user.per_page %> + <%= link_to "page #{pool.last_page}", pool_path(pool, :page => pool.last_page), :class => "last-page" %> + <% end %> <%= pool.post_count %>