create_venue_commercial added

This commit is contained in:
Shriyansh 2016-04-03 22:08:46 +05:30
parent 154f4a400c
commit 6f667a865b
4 changed files with 31 additions and 3 deletions

View file

@ -1,11 +1,11 @@
module Admin
class CommercialsController < Admin::BaseController
class VenueCommercialsController < Admin::BaseController
load_and_authorize_resource :conference, find_by: :short_title
load_and_authorize_resource :venue ,through: :conference, singelton: true
before_action :set_venue
def create
@commercial = @venue.commercial.build(commercial_params)
@commercial = @venue.build_commercial(commercial_params)
authorize! :create, @commercial
#FIXME redirect to tab#commercial

View file

@ -4,6 +4,7 @@ class Venue < ActiveRecord::Base
has_many :rooms, dependent: :destroy
before_create :generate_guid
accepts_nested_attributes_for :commercial, allow_destroy: true
validates :name, :street, :city, :country, presence: true
validates :conference_id, presence: true, uniqueness: true

View file

@ -12,3 +12,30 @@
= image_tag @venue.photo(:thumb)
= f.input :photo
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
.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(@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
.thumbnail
.flexvideo{ id: "resource-content-#{commercial.id}"}
= render partial: 'shared/media_item', locals: { commercial: commercial }
.caption
- if can? :update, commercial
= semantic_form_for commercial, url: admin_conference_venue_venue_commercial_path(conference_id: @conference.short_title, id: commercial) 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.action :submit, as: :button, button_html: { class: 'btn btn-success' }, label: 'Update'
- if can? :destroy, commercial
= link_to 'Delete', admin_conference_venue_venue_commercial_path(@conference.short_title, commercial.id),
method: :delete, data: { confirm: 'Are you sure?' }, class: 'btn btn-danger'
%hr

View file

@ -43,7 +43,7 @@ Osem::Application.routes.draw do
# Singletons
resource :splashpage
resource :venue do
get 'venue_commercial/render_commercial' => 'venue_commercial#render_commercial'
get 'venue_commercial/render_commercial' => 'venue_commercials#render_commercial'
resource :venue_commercial, only: [:create, :update, :destroy]
resources :rooms, except: [:show]
end