allowing publishing
This commit is contained in:
parent
6be5ea92b3
commit
1acbe34d77
@ -2,8 +2,8 @@ class ApplicationController < ActionController::Base
|
||||
# Prevent CSRF attacks by raising an exception.
|
||||
# For APIs, you may want to use :null_session instead.
|
||||
protect_from_forgery with: :null_session
|
||||
before_action :authenticate_user_from_token!
|
||||
before_action :authenticate_user! #unless Rails.env.test?
|
||||
before_action :authenticate_user_from_token!, except: [:publish]
|
||||
before_action :authenticate_user!, except: [:publish] #unless Rails.env.test?
|
||||
|
||||
private
|
||||
|
||||
|
@ -1,54 +1,28 @@
|
||||
class VideolistingsController < ApplicationController
|
||||
before_action :set_videolisting, only: [:show, :edit, :update, :destroy]
|
||||
before_action :set_videolisting, only: [:publish]
|
||||
|
||||
# GET /videolistings
|
||||
def index
|
||||
@videolistings = Videolisting.all
|
||||
end
|
||||
|
||||
# GET /videolistings/1
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /videolistings/new
|
||||
def new
|
||||
@videolisting = Videolisting.new
|
||||
end
|
||||
|
||||
# GET /videolistings/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /videolistings
|
||||
def create
|
||||
@videolisting = Videolisting.new(videolisting_params)
|
||||
|
||||
if @videolisting.save
|
||||
redirect_to @videolisting, notice: 'Videolisting was successfully created.'
|
||||
def publish
|
||||
if @videolisting.published?
|
||||
@message = "Campaign Already Published."
|
||||
elsif @videolisting.campaign.processed?
|
||||
@videolisting.published = true
|
||||
@videolisting.save
|
||||
#TODO: SEND OUT EMAIL HERE.
|
||||
@message = "Campaign Published Successfully."
|
||||
else
|
||||
render action: 'new'
|
||||
@message = "Error: Campaign Not Published."
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /videolistings/1
|
||||
def update
|
||||
if @videolisting.update(videolisting_params)
|
||||
redirect_to @videolisting, notice: 'Videolisting was successfully updated.'
|
||||
else
|
||||
render action: 'edit'
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /videolistings/1
|
||||
def destroy
|
||||
@videolisting.destroy
|
||||
redirect_to videolistings_url, notice: 'Videolisting was successfully destroyed.'
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_videolisting
|
||||
@videolisting = Videolisting.find(params[:id])
|
||||
videocode = params[:videocode]
|
||||
if params[:videolisting]
|
||||
@videolisting = Videolisting.find_by_videocode(params[:videolisting][:videocode]) || not_found
|
||||
else
|
||||
@videolisting = Videolisting.find_by_videocode(videocode) || not_found
|
||||
end
|
||||
end
|
||||
|
||||
# Only allow a trusted parameter "white list" through.
|
||||
|
@ -1,57 +0,0 @@
|
||||
<%= form_for(@videolisting) do |f| %>
|
||||
<% if @videolisting.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<h2><%= pluralize(@videolisting.errors.count, "error") %> prohibited this videolisting from being saved:</h2>
|
||||
|
||||
<ul>
|
||||
<% @videolisting.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="field">
|
||||
<%= f.label :videocode %><br>
|
||||
<%= f.text_field :videocode %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :producttypeid %><br>
|
||||
<%= f.text_field :producttypeid %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :remoteassetsarchive %><br>
|
||||
<%= f.text_field :remoteassetsarchive %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :voiceoverselection %><br>
|
||||
<%= f.text_field :voiceoverselection %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :musicselection %><br>
|
||||
<%= f.text_field :musicselection %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :clientprovidedscript %><br>
|
||||
<%= f.text_field :clientprovidedscript %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :keywords %><br>
|
||||
<%= f.text_field :keywords %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :focus %><br>
|
||||
<%= f.text_field :focus %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :notes %><br>
|
||||
<%= f.text_field :notes %>
|
||||
</div>
|
||||
<div class="field">
|
||||
<%= f.label :asseturls %><br>
|
||||
<%= f.text_field :asseturls %>
|
||||
</div>
|
||||
<div class="actions">
|
||||
<%= f.submit %>
|
||||
</div>
|
||||
<% end %>
|
@ -1,6 +0,0 @@
|
||||
<h1>Editing videolisting</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Show', @videolisting %> |
|
||||
<%= link_to 'Back', videolistings_path %>
|
@ -1,45 +0,0 @@
|
||||
<h1>Listing videolistings</h1>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Videocode</th>
|
||||
<th>Producttypeid</th>
|
||||
<th>Remoteassetsarchive</th>
|
||||
<th>Voiceoverselection</th>
|
||||
<th>Musicselection</th>
|
||||
<th>Clientprovidedscript</th>
|
||||
<th>Keywords</th>
|
||||
<th>Focus</th>
|
||||
<th>Notes</th>
|
||||
<th>Asseturls</th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @videolistings.each do |videolisting| %>
|
||||
<tr>
|
||||
<td><%= videolisting.videocode %></td>
|
||||
<td><%= videolisting.producttypeid %></td>
|
||||
<td><%= videolisting.remoteassetsarchive %></td>
|
||||
<td><%= videolisting.voiceoverselection %></td>
|
||||
<td><%= videolisting.musicselection %></td>
|
||||
<td><%= videolisting.clientprovidedscript %></td>
|
||||
<td><%= videolisting.keywords %></td>
|
||||
<td><%= videolisting.focus %></td>
|
||||
<td><%= videolisting.notes %></td>
|
||||
<td><%= videolisting.asseturls %></td>
|
||||
<td><%= link_to 'Show', videolisting %></td>
|
||||
<td><%= link_to 'Edit', edit_videolisting_path(videolisting) %></td>
|
||||
<td><%= link_to 'Destroy', videolisting, method: :delete, data: { confirm: 'Are you sure?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
|
||||
<br>
|
||||
|
||||
<%= link_to 'New Videolisting', new_videolisting_path %>
|
@ -1,5 +0,0 @@
|
||||
<h1>New videolisting</h1>
|
||||
|
||||
<%= render 'form' %>
|
||||
|
||||
<%= link_to 'Back', videolistings_path %>
|
1
app/views/videolistings/publish.json.erb
Normal file
1
app/views/videolistings/publish.json.erb
Normal file
@ -0,0 +1 @@
|
||||
{"message": "<%= @message %>"}
|
@ -1,54 +0,0 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<strong>Videocode:</strong>
|
||||
<%= @videolisting.videocode %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Producttypeid:</strong>
|
||||
<%= @videolisting.producttypeid %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Remoteassetsarchive:</strong>
|
||||
<%= @videolisting.remoteassetsarchive %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Voiceoverselection:</strong>
|
||||
<%= @videolisting.voiceoverselection %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Musicselection:</strong>
|
||||
<%= @videolisting.musicselection %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Clientprovidedscript:</strong>
|
||||
<%= @videolisting.clientprovidedscript %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Keywords:</strong>
|
||||
<%= @videolisting.keywords %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Focus:</strong>
|
||||
<%= @videolisting.focus %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Notes:</strong>
|
||||
<%= @videolisting.notes %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Asseturls:</strong>
|
||||
<%= @videolisting.asseturls %>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Edit', edit_videolisting_path(@videolisting) %> |
|
||||
<%= link_to 'Back', videolistings_path %>
|
@ -4,12 +4,15 @@ Vidpush::Application.routes.draw do
|
||||
devise_for :users, :controllers => {registrations: "registrations"}
|
||||
else
|
||||
devise_for :users
|
||||
|
||||
end
|
||||
|
||||
root to: "campaigns#index"
|
||||
|
||||
resources :campaigns, param: :listingcode do
|
||||
resources :videolistings, param: :videocode
|
||||
resources :videolistings, param: :videocode do
|
||||
member do
|
||||
get 'publish',:defaults => { :format => 'json' }
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -0,0 +1,5 @@
|
||||
class AddPublishedToVideolisting < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :videolistings, :published, :boolean
|
||||
end
|
||||
end
|
@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20140423215738) do
|
||||
ActiveRecord::Schema.define(version: 20140424185113) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@ -112,6 +112,7 @@ ActiveRecord::Schema.define(version: 20140423215738) do
|
||||
t.datetime "updated_at"
|
||||
t.integer "campaign_id"
|
||||
t.string "toneofvideo"
|
||||
t.boolean "published"
|
||||
end
|
||||
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user