From be9eff023d50bd38ed47c050da435051f0c91bd2 Mon Sep 17 00:00:00 2001 From: yasushiito Date: Wed, 19 Dec 2012 18:10:45 +0900 Subject: [PATCH] t#30144:hide old edition pictures on pp, gp --- app/models/picture.rb | 14 +++++++++++--- app/views/artists/list.html.erb | 2 ++ app/views/ground_pictures/_list_item.html.erb | 11 +++++++++-- app/views/panel_pictures/_list_item.html.erb | 13 +++++++++++-- app/views/panel_pictures/show.html.erb | 15 +++++++++++---- app/views/pictures/_tail.html.erb | 2 +- app/views/pictures/show.html.erb | 2 +- spec/models/picture_spec.rb | 6 +++--- 8 files changed, 49 insertions(+), 16 deletions(-) diff --git a/app/models/picture.rb b/app/models/picture.rb index 4e5472d8..dfaf5838 100644 --- a/app/models/picture.rb +++ b/app/models/picture.rb @@ -43,9 +43,8 @@ class Picture < ActiveRecord::Base return true end - def showable? ar - return false unless ar.is_a?(Artist) - return true if self.own?(ar) + def showable? au = nil + return true if self.own?(au) self.enable? and self.head? end @@ -74,6 +73,15 @@ class Picture < ActiveRecord::Base {:src => self.url, :width => tw, :height => th} end + def tail_opt_img_tag img + {:src => img, :width => self.width, :height => self.height} + end + + def tail_tmb_opt_img_tag img + tw, th = PettanImager.thumbnail_size(self.width, self.height) + {:src => img, :width => tw, :height => th} + end + def new_revision Picture.maximum(:revision, :conditions => ['original_picture_id = ?', self.original_picture_id]).to_i + 1 end diff --git a/app/views/artists/list.html.erb b/app/views/artists/list.html.erb index abca0851..5fe1d68b 100644 --- a/app/views/artists/list.html.erb +++ b/app/views/artists/list.html.erb @@ -3,6 +3,7 @@ + @@ -11,6 +12,7 @@ <% @artists.each do |artist| %> + diff --git a/app/views/ground_pictures/_list_item.html.erb b/app/views/ground_pictures/_list_item.html.erb index e2bd16b1..88a71eb4 100644 --- a/app/views/ground_pictures/_list_item.html.erb +++ b/app/views/ground_pictures/_list_item.html.erb @@ -1,7 +1,14 @@ - - + <% if ground_picture.picture.showable? @author %> + + + <% else %> + + + <% end %> diff --git a/app/views/panel_pictures/_list_item.html.erb b/app/views/panel_pictures/_list_item.html.erb index e7c1ff92..6c59f5bb 100644 --- a/app/views/panel_pictures/_list_item.html.erb +++ b/app/views/panel_pictures/_list_item.html.erb @@ -1,6 +1,15 @@ - - + <% if panel_picture.picture.showable? @author %> + + + <% else %> + + + <% end %> diff --git a/app/views/panel_pictures/show.html.erb b/app/views/panel_pictures/show.html.erb index c0b19b72..f0b4fab0 100644 --- a/app/views/panel_pictures/show.html.erb +++ b/app/views/panel_pictures/show.html.erb @@ -6,10 +6,17 @@ <%= link_to @panel_picture.panel_id, panel_path(@panel_picture.panel) %>

-

- <%= t_m 'PanelPicture.picture_id' -%>: - <%= link_to tag(:img, @panel_picture.opt_img_tag), picture_path(@panel_picture.picture) %> -

+<% if @panel_picture.picture.showable? @author %> +

+ <%= t_m 'PanelPicture.picture_id' -%>: + <%= link_to tag(:img, @panel_picture.opt_img_tag), picture_path(@panel_picture.picture) %> +

+ <%= render @panel_picture.picture.credit_template, :picture => @panel_picture.picture %> +<% else %> +

+ <%= tag(:img, @panel_picture.picture.tail_opt_img_tag(asset_path('error.png'))) -%> +

+<% end %>

<%= t_m 'PanelPicture.link' -%>: diff --git a/app/views/pictures/_tail.html.erb b/app/views/pictures/_tail.html.erb index bcf0044d..c12759a3 100644 --- a/app/views/pictures/_tail.html.erb +++ b/app/views/pictures/_tail.html.erb @@ -1,7 +1,7 @@

<%= t_m 'Artist.id' -%><%= t_m 'Artist.author_id' -%> <%= t_m 'Artist.name' -%> <%= t_m 'Artist.created_at' -%> <%= t_m 'Artist.updated_at' -%>
<%= link_to artist.id, browse_artist_path(artist) %><%= link_to artist.author_id, browse_author_path(artist.author) %> <%= h(truncate(artist.name, :length => 12)) %> <%= l artist.created_at %> <%= l artist.updated_at %>
<%= link_to ground_picture.panel_id, panel_path(ground_picture.panel_id) %><%= tag :img, ground_picture.picture.tmb_opt_img_tag -%><%= render ground_picture.picture.credit_template, :picture => ground_picture.picture %><%= link_to(tag(:img, ground_picture.picture.tmb_opt_img_tag), ground_picture) -%><%= render ground_picture.picture.credit_template, :picture => ground_picture.picture %> + <%= link_to(tag(:img, ground_picture.picture.tail_tmb_opt_img_tag(asset_path('error.png'))), ground_picture) -%> + <%= ground_picture.z %> <%= ground_picture.repeat %><%= MagicNumber['ground_picture_repeat_items'][ground_picture.repeat] %> <%= ground_picture.x %>
<%= link_to(tag(:img, panel_picture.tmb_opt_img_tag), panel_picture.picture) %><%= render panel_picture.picture.credit_template, :picture => panel_picture.picture %> + <%= link_to(tag(:img, panel_picture.tmb_opt_img_tag), panel_picture) %> + <%= render panel_picture.picture.credit_template, :picture => panel_picture.picture %> + <%= link_to(tag(:img, panel_picture.picture.tail_tmb_opt_img_tag(asset_path('error.png'))), panel_picture) -%> + <%= link_to panel_picture.panel.id, panel_path(panel_picture.panel) %> <%= link_to h(truncate(panel_picture.link, :length => 12)), panel_picture.link %> <%= h(truncate(panel_picture.caption, :length => 12)) %>
- <%= tag :img, :src => asset_path('error.png'), :width => picture.width, :height => picture.height -%> + <%= tag(:img, picture.tail_opt_img_tag(asset_path('error.png'))) -%>

diff --git a/app/views/pictures/show.html.erb b/app/views/pictures/show.html.erb index 8d40ab6d..5a11460d 100644 --- a/app/views/pictures/show.html.erb +++ b/app/views/pictures/show.html.erb @@ -25,7 +25,7 @@ <% end %> -<% if @picture.showable? @artist %> +<% if @picture.showable? @author %> <%= render 'head', :picture => @picture %> <% else %> <%= render 'tail', :picture => @picture %> diff --git a/spec/models/picture_spec.rb b/spec/models/picture_spec.rb index a4e372e5..81664005 100644 --- a/spec/models/picture_spec.rb +++ b/spec/models/picture_spec.rb @@ -297,19 +297,19 @@ describe Picture do it '自身にhead判定と有効性判定を問い合わせ、両者がTrueならTrueを返す。' do Picture.any_instance.stub(:head?).with(any_args).and_return(true) Picture.any_instance.stub(:enable?).with(any_args).and_return(true) - r = @p.showable?(@artist) + r = @p.showable?(@author) r.should be_true end it 'head判定がFalseならFalseを返す。' do Picture.any_instance.stub(:head?).with(any_args).and_return(false) Picture.any_instance.stub(:enable?).with(any_args).and_return(true) - r = @p.showable?(@artist) + r = @p.showable?(@author) r.should be_false end it '有効性判定がFalseならFalseを返す。' do Picture.any_instance.stub(:enable?).with(any_args).and_return(false) Picture.any_instance.stub(:head?).with(any_args).and_return(true) - r = @p.showable?(@artist) + r = @p.showable?(@author) r.should be_false end end -- 2.11.0