done with creating relationship and generating view for venue_commercials
This commit is contained in:
parent
dc0da8c500
commit
7bbb0da17a
2 changed files with 29 additions and 22 deletions
|
|
@ -3,6 +3,7 @@ module Admin
|
||||||
load_and_authorize_resource :conference, find_by: :short_title
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
load_and_authorize_resource :venue ,through: :conference, singelton: true
|
load_and_authorize_resource :venue ,through: :conference, singelton: true
|
||||||
before_action :set_venue
|
before_action :set_venue
|
||||||
|
before_action :set_commercial , only: [:update , :destroy]
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@commercial = @venue.build_commercial(commercial_params)
|
@commercial = @venue.build_commercial(commercial_params)
|
||||||
|
|
@ -54,5 +55,9 @@ module Admin
|
||||||
def set_venue
|
def set_venue
|
||||||
@venue = @conference.venue
|
@venue = @conference.venue
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def set_commercial
|
||||||
|
@commercial = Commercial.find params[:id]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -22,32 +22,34 @@
|
||||||
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
||||||
|
|
||||||
#commercials-content.tab-pane
|
#commercials-content.tab-pane
|
||||||
- if @venue
|
- if can? :create, @venue.commercial
|
||||||
.row
|
- if @venue.commercial
|
||||||
.col-md-6
|
- if @venue.commercial.persisted?
|
||||||
#resource-content
|
|
||||||
#resource-placeholder{ style: 'background-color:#d3d3d3; float: left; width: 400px; height: 250px; margin: 5px; border-width: 1px; border-style: solid; border-color: rgba(0,0,0,.2);' }
|
|
||||||
.row
|
|
||||||
.col-md-6
|
|
||||||
= semantic_form_for(@venue.create_commercial,as: :commercial, url: admin_conference_venue_venue_commercial_path(conference_id: @conference.short_title)) do |f|
|
|
||||||
= f.input :url, label: 'URL', as: :string, input_html: { required: 'required', type: 'url' },
|
|
||||||
hint: 'Just paste the url of your video/photo provider. Currently supported: YouTube, Vimeo, SpeakerDeck, SlideShare, Instagram, Flickr.'
|
|
||||||
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary pull-right', disabled: true }
|
|
||||||
%hr
|
|
||||||
- @venue.commercial do |commercial|
|
|
||||||
- if commercial.persisted?
|
|
||||||
.col-md-4
|
.col-md-4
|
||||||
.thumbnail
|
.thumbnail
|
||||||
.flexvideo{ id: "resource-content-#{commercial.id}"}
|
.flexvideo{ id: "resource-content-#{@venue.commercial.id}"}
|
||||||
= render partial: 'shared/media_item', locals: { commercial: commercial }
|
= render partial: 'shared/media_item', locals: { commercial: @venue.commercial }
|
||||||
.caption
|
.caption
|
||||||
- if can? :update, commercial
|
- if can? :update, @venue.commercial
|
||||||
= semantic_form_for commercial, url: admin_conference_venue_venue_commercial_path(conference_id: @conference.short_title, id: commercial.id) do |f|
|
= semantic_form_for @venue.commercial, as: :commercial, url: admin_conference_venue_venue_commercial_path(conference_id: @conference.short_title, id: @venue.commercial.id) do |f|
|
||||||
= f.input :url, label: 'URL', as: :string, input_html: { id: "commercial_url_#{commercial.id}", required: 'required' }, hint: 'Just paste the url of your video/photo provider'
|
= f.input :url, label: 'URL', as: :string, input_html: { id: "commercial_url_#{@venue.commercial.id}", required: 'required' }, hint: 'Just paste the url of your video/photo provider'
|
||||||
= f.action :submit, as: :button, button_html: { class: 'btn btn-success' }, label: 'Update'
|
= f.action :submit, as: :button, button_html: { class: 'btn btn-success' }, label: 'Update'
|
||||||
- if can? :destroy, commercial
|
- if can? :destroy, @venue.commercial
|
||||||
= link_to 'Delete', admin_conference_venue_venue_commercial_path(@conference.short_title, commercial.id),
|
= link_to 'Delete', admin_conference_venue_venue_commercial_path(conference_id: @conference.short_title, id: @venue.commercial.id),
|
||||||
method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger'
|
method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger'
|
||||||
%hr
|
%hr
|
||||||
|
- else
|
||||||
|
.row
|
||||||
|
.col-md-6
|
||||||
|
#resource-content
|
||||||
|
#resource-placeholder{ style: 'background-color:#d3d3d3; float: left; width: 400px; height: 250px; margin: 5px; border-width: 1px; border-style: solid; border-color: rgba(0,0,0,.2);' }
|
||||||
|
.row
|
||||||
|
.col-md-6
|
||||||
|
= semantic_form_for(Commercial.new,as: :commercial, url: admin_conference_venue_venue_commercial_path(conference_id: @conference.short_title)) do |f|
|
||||||
|
= f.input :url, label: 'URL', as: :string, input_html: { required: 'required', type: 'url' },
|
||||||
|
hint: 'Just paste the url of your video/photo provider. Currently supported: YouTube, Vimeo, SpeakerDeck, SlideShare, Instagram, Flickr.'
|
||||||
|
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary pull-right', disabled: true }
|
||||||
|
%hr
|
||||||
|
|
||||||
- else
|
- else
|
||||||
hint: 'First Create Venue, then update commercial'
|
hint: 'First Create Venue, then update commercial'
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue