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
{: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
<table>
<tr>
<th><%= t_m 'Artist.id' -%></th>
+ <th><%= t_m 'Artist.author_id' -%></th>
<th><%= t_m 'Artist.name' -%></th>
<th><%= t_m 'Artist.created_at' -%></th>
<th><%= t_m 'Artist.updated_at' -%></th>
<% @artists.each do |artist| %>
<tr>
<td><%= link_to artist.id, browse_artist_path(artist) %></td>
+ <td><%= link_to artist.author_id, browse_author_path(artist.author) %></td>
<td><%= h(truncate(artist.name, :length => 12)) %></td>
<td><%= l artist.created_at %></td>
<td><%= l artist.updated_at %></td>
<tr>
<td><%= link_to ground_picture.panel_id, panel_path(ground_picture.panel_id) %></td>
- <td><%= tag :img, ground_picture.picture.tmb_opt_img_tag -%></td>
- <td><%= render ground_picture.picture.credit_template, :picture => ground_picture.picture %></td>
+ <% if ground_picture.picture.showable? @author %>
+ <td><%= link_to(tag(:img, ground_picture.picture.tmb_opt_img_tag), ground_picture) -%></td>
+ <td><%= render ground_picture.picture.credit_template, :picture => ground_picture.picture %></td>
+ <% else %>
+ <td>
+ <%= link_to(tag(:img, ground_picture.picture.tail_tmb_opt_img_tag(asset_path('error.png'))), ground_picture) -%>
+ </td>
+ <td></td>
+ <% end %>
<td><%= ground_picture.z %></td>
<td><%= ground_picture.repeat %><%= MagicNumber['ground_picture_repeat_items'][ground_picture.repeat] %></td>
<td><%= ground_picture.x %></td>
<tr>
- <td><%= link_to(tag(:img, panel_picture.tmb_opt_img_tag), panel_picture.picture) %></td>
- <td><%= render panel_picture.picture.credit_template, :picture => panel_picture.picture %></td>
+ <% if panel_picture.picture.showable? @author %>
+ <td>
+ <%= link_to(tag(:img, panel_picture.tmb_opt_img_tag), panel_picture) %>
+ </td>
+ <td><%= render panel_picture.picture.credit_template, :picture => panel_picture.picture %></td>
+ <% else %>
+ <td>
+ <%= link_to(tag(:img, panel_picture.picture.tail_tmb_opt_img_tag(asset_path('error.png'))), panel_picture) -%>
+ </td>
+ <td></td>
+ <% end %>
<td><%= link_to panel_picture.panel.id, panel_path(panel_picture.panel) %></td>
<td><%= link_to h(truncate(panel_picture.link, :length => 12)), panel_picture.link %></td>
<td><%= h(truncate(panel_picture.caption, :length => 12)) %></td>
<%= link_to @panel_picture.panel_id, panel_path(@panel_picture.panel) %>
</p>
-<p>
- <b><%= t_m 'PanelPicture.picture_id' -%>:</b>
- <%= link_to tag(:img, @panel_picture.opt_img_tag), picture_path(@panel_picture.picture) %>
-</p>
+<% if @panel_picture.picture.showable? @author %>
+ <p>
+ <b><%= t_m 'PanelPicture.picture_id' -%>:</b>
+ <%= link_to tag(:img, @panel_picture.opt_img_tag), picture_path(@panel_picture.picture) %>
+ </p>
+ <%= render @panel_picture.picture.credit_template, :picture => @panel_picture.picture %>
+<% else %>
+ <p>
+ <%= tag(:img, @panel_picture.picture.tail_opt_img_tag(asset_path('error.png'))) -%>
+ </p>
+<% end %>
<p>
<b><%= t_m 'PanelPicture.link' -%>:</b>
<table>
<tr>
<td>
- <%= tag :img, :src => asset_path('error.png'), :width => picture.width, :height => picture.height -%>
+ <%= tag(:img, picture.tail_opt_img_tag(asset_path('error.png'))) -%>
</td>
<td>
<h2>
<% end %>
</div>
-<% if @picture.showable? @artist %>
+<% if @picture.showable? @author %>
<%= render 'head', :picture => @picture %>
<% else %>
<%= render 'tail', :picture => @picture %>
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