add and show photos for seeds

close #1457
This commit is contained in:
Brenda Wallace
2017-12-13 22:32:59 +13:00
parent 4f64698403
commit 1c8b75b7cb
2 changed files with 49 additions and 6 deletions

View File

@@ -0,0 +1,40 @@
- if can? :edit, @seed
= link_to edit_seed_path(@seed), class: 'btn btn-default btn-xs' do
%span.glyphicon.glyphicon-pencil{ title: "Edit" }
Edit
= link_to new_photo_path(id: seed.id, type: 'seed'), class: 'btn btn-default btn-xs' do
%span.glyphicon.glyphicon-camera{ title: "Add photo" }
Add photo
- if can? :destroy, @seed
= link_to @seed, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs' do
%span.glyphicon.glyphicon-trash{ title: "Delete" }
Delete
-# - if can?(:edit, planting) || can?(:destroy, planting)
-# - if can? :edit, planting
-# = link_to edit_planting_path(planting), class: 'btn btn-default btn-xs' do
-# %span.glyphicon.glyphicon-pencil{ title: "Edit" }
-# Edit
-# - if can? :destroy, planting
-# = link_to planting, method: :delete,
-# data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs' do
-# %span.glyphicon.glyphicon-trash{ title: "Delete" }
-# Delete
-# - unless planting.finished
-# = link_to planting_path(planting, planting: { finished: 1 }),
-# method: :put, class: 'btn btn-default btn-xs append-date' do
-# %span.glyphicon.glyphicon-ok{ title: "Finished" }
-# Mark as finished
-# - if can?(:create, Harvest)
-# = link_to new_planting_harvest_path(planting), class: 'btn btn-default btn-xs' do
-# %span.glyphicon.glyphicon-leaf{ title: "Harvest" }
-# Harvest
-# - if can?(:edit, planting) && can?(:create, Photo)
-# = link_to new_photo_path(id: planting.id, type: 'planting'), class: 'btn btn-default btn-xs' do
-# %span.glyphicon.glyphicon-camera{ title: "Add photo" }
-# Add photo

View File

@@ -58,15 +58,11 @@
subject: "Interested in your #{@seed.crop} seeds"),
class: 'btn btn-primary'
- else
= render partial: 'shared/signin_signup', locals: { to: 'request seeds' }
= render 'shared/signin_signup', to: 'request seeds'
- if can?(:edit, @seed) || can?(:destroy, @seed)
%p
- if can? :edit, @seed
= link_to 'Edit', edit_seed_path(@seed), class: 'btn btn-default btn-xs'
- if can? :destroy, @seed
= link_to 'Delete', @seed, method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-default btn-xs'
= render 'actions', seed: @seed
.col-md-6
= render partial: "crops/index_card", locals: { crop: @seed.crop }
- if @seed.owner.location
@@ -79,3 +75,10 @@
Or
= link_to "purchase seeds via Ebay",
crop_ebay_seeds_url(@seed.crop), target: "_blank", rel: "noopener noreferrer"
.row
- @seed.photos.includes(:owner).each do |p|
.col-md-2.six-across
= render 'photos/thumbnail', photo: p
- if can?(:create, Photo) && can?(:edit, @seed)
.col-md-2
= link_to "Add photo", new_photo_path(type: "seed", id: @seed.id), class: 'btn btn-primary'