Introduce Call for Booths
This commit is contained in:
parent
66ac45efc8
commit
7ee9b2966a
13 changed files with 191 additions and 16 deletions
83
app/controllers/call_for_booths_controller.rb
Normal file
83
app/controllers/call_for_booths_controller.rb
Normal file
|
|
@ -0,0 +1,83 @@
|
||||||
|
class CallForBoothsController < ApplicationController
|
||||||
|
before_action :set_call_for_booth, only: [:show, :edit, :update, :destroy]
|
||||||
|
|
||||||
|
# GET /call_for_booths
|
||||||
|
# GET /call_for_booths.json
|
||||||
|
def index
|
||||||
|
@call_for_booths = CallForBooth.all
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # index.html.erb
|
||||||
|
format.json { render json: @call_for_booths }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /call_for_booths/1
|
||||||
|
# GET /call_for_booths/1.json
|
||||||
|
def show
|
||||||
|
respond_to do |format|
|
||||||
|
format.html # show.html.erb
|
||||||
|
format.json { render json: @call_for_booth }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /call_for_booths/new
|
||||||
|
def new
|
||||||
|
@call_for_booth = CallForBooth.new
|
||||||
|
end
|
||||||
|
|
||||||
|
# GET /call_for_booths/1/edit
|
||||||
|
def edit
|
||||||
|
end
|
||||||
|
|
||||||
|
# POST /call_for_booths
|
||||||
|
# POST /call_for_booths.json
|
||||||
|
def create
|
||||||
|
@call_for_booth = CallForBooth.new(call_for_booth_params)
|
||||||
|
|
||||||
|
respond_to do |format|
|
||||||
|
if @call_for_booth.save
|
||||||
|
format.html { redirect_to @call_for_booth, notice: 'Call for booth was successfully created.' }
|
||||||
|
format.json { render json: @call_for_booth, status: :created }
|
||||||
|
else
|
||||||
|
format.html { render action: 'new' }
|
||||||
|
format.json { render json: @call_for_booth.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# PATCH/PUT /call_for_booths/1
|
||||||
|
# PATCH/PUT /call_for_booths/1.json
|
||||||
|
def update
|
||||||
|
respond_to do |format|
|
||||||
|
if @call_for_booth.update(call_for_booth_params)
|
||||||
|
format.html { redirect_to @call_for_booth, notice: 'Call for booth was successfully updated.' }
|
||||||
|
format.json { head :no_content }
|
||||||
|
else
|
||||||
|
format.html { render action: 'edit' }
|
||||||
|
format.json { render json: @call_for_booth.errors, status: :unprocessable_entity }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# DELETE /call_for_booths/1
|
||||||
|
# DELETE /call_for_booths/1.json
|
||||||
|
def destroy
|
||||||
|
@call_for_booth.destroy
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { redirect_to call_for_booths_url }
|
||||||
|
format.json { head :no_content }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
private
|
||||||
|
# Use callbacks to share common setup or constraints between actions.
|
||||||
|
def set_call_for_booth
|
||||||
|
@call_for_booth = CallForBooth.find(params[:id])
|
||||||
|
end
|
||||||
|
|
||||||
|
# Never trust parameters from the scary internet, only allow the white list through.
|
||||||
|
def call_for_booth_params
|
||||||
|
params.require(:call_for_booth).permit(:start_date, :end_date, :booth_limit)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -3,7 +3,7 @@ class Booth < ActiveRecord::Base
|
||||||
has_many :booth_requests
|
has_many :booth_requests
|
||||||
has_many :users, through: :booth_requests
|
has_many :users, through: :booth_requests
|
||||||
|
|
||||||
validate :title,
|
validates :title,
|
||||||
uniqueness: { case_sensitive: fasle},
|
uniqueness: { case_sensitive: fasle},
|
||||||
presence: true
|
presence: true
|
||||||
|
|
||||||
|
|
|
||||||
22
app/models/call_for_booth.rb
Normal file
22
app/models/call_for_booth.rb
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
class CallForBooth < ActiveRecord::Base
|
||||||
|
belongs_to :conference
|
||||||
|
|
||||||
|
validates :start_date, :end_date, :booth_limit, presence: true
|
||||||
|
validate :before_end_of_conference
|
||||||
|
validate :start_date_before_end_date
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def before_end_of_conference
|
||||||
|
errors
|
||||||
|
.add(:start_date, "can't be after the conference end date (#{conference.end_date})") if conference && conference.end_date && start_date && (start_date > conference.end_date)
|
||||||
|
|
||||||
|
errors
|
||||||
|
.add(:end_date, "can't be after the conference end date (#{conference.end_date})") if conference && conference.end_date && end_date && (end_date > conference.end_date)
|
||||||
|
end
|
||||||
|
|
||||||
|
def start_date_before_end_date
|
||||||
|
errors
|
||||||
|
.add(:start_date, "can't be after the end date") if start_date && end_date && start_date > end_date
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -16,6 +16,7 @@ class Conference < ActiveRecord::Base
|
||||||
has_one :splashpage, dependent: :destroy
|
has_one :splashpage, dependent: :destroy
|
||||||
has_one :contact, dependent: :destroy
|
has_one :contact, dependent: :destroy
|
||||||
has_one :registration_period, dependent: :destroy
|
has_one :registration_period, dependent: :destroy
|
||||||
|
has_one :call_for_booths, dependent: :destroy
|
||||||
has_one :email_settings, dependent: :destroy
|
has_one :email_settings, dependent: :destroy
|
||||||
has_one :program, dependent: :destroy
|
has_one :program, dependent: :destroy
|
||||||
has_one :venue, dependent: :destroy
|
has_one :venue, dependent: :destroy
|
||||||
|
|
|
||||||
19
app/views/call_for_booths/_form.html.haml
Normal file
19
app/views/call_for_booths/_form.html.haml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
= form_for @call_for_booth do |f|
|
||||||
|
- if @call_for_booth.errors.any?
|
||||||
|
#error_explanation
|
||||||
|
%h2= "#{pluralize(@call_for_booth.errors.count, "error")} prohibited this call_for_booth from being saved:"
|
||||||
|
%ul
|
||||||
|
- @call_for_booth.errors.full_messages.each do |msg|
|
||||||
|
%li= msg
|
||||||
|
|
||||||
|
.field
|
||||||
|
= f.label :start_date
|
||||||
|
= f.date_select :start_date
|
||||||
|
.field
|
||||||
|
= f.label :end_date
|
||||||
|
= f.date_select :end_date
|
||||||
|
.field
|
||||||
|
= f.label :booth_limit
|
||||||
|
= f.number_field :booth_limit
|
||||||
|
.actions
|
||||||
|
= f.submit 'Save'
|
||||||
7
app/views/call_for_booths/edit.html.haml
Normal file
7
app/views/call_for_booths/edit.html.haml
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
%h1 Editing call_for_booth
|
||||||
|
|
||||||
|
= render 'form'
|
||||||
|
|
||||||
|
= link_to 'Show', @call_for_booth
|
||||||
|
\|
|
||||||
|
= link_to 'Back', call_for_booths_path
|
||||||
23
app/views/call_for_booths/index.html.haml
Normal file
23
app/views/call_for_booths/index.html.haml
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
%h1 Listing call_for_booths
|
||||||
|
|
||||||
|
%table
|
||||||
|
%tr
|
||||||
|
%th Start date
|
||||||
|
%th End date
|
||||||
|
%th Booth limit
|
||||||
|
%th
|
||||||
|
%th
|
||||||
|
%th
|
||||||
|
|
||||||
|
- @call_for_booths.each do |call_for_booth|
|
||||||
|
%tr
|
||||||
|
%td= call_for_booth.start_date
|
||||||
|
%td= call_for_booth.end_date
|
||||||
|
%td= call_for_booth.booth_limit
|
||||||
|
%td= link_to 'Show', call_for_booth
|
||||||
|
%td= link_to 'Edit', edit_call_for_booth_path(call_for_booth)
|
||||||
|
%td= link_to 'Destroy', call_for_booth, :method => :delete, :data => { :confirm => 'Are you sure?' }
|
||||||
|
|
||||||
|
%br
|
||||||
|
|
||||||
|
= link_to 'New Call for booth', new_call_for_booth_path
|
||||||
5
app/views/call_for_booths/new.html.haml
Normal file
5
app/views/call_for_booths/new.html.haml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
%h1 New call_for_booth
|
||||||
|
|
||||||
|
= render 'form'
|
||||||
|
|
||||||
|
= link_to 'Back', call_for_booths_path
|
||||||
15
app/views/call_for_booths/show.html.haml
Normal file
15
app/views/call_for_booths/show.html.haml
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
%p#notice= notice
|
||||||
|
|
||||||
|
%p
|
||||||
|
%b Start date:
|
||||||
|
= @call_for_booth.start_date
|
||||||
|
%p
|
||||||
|
%b End date:
|
||||||
|
= @call_for_booth.end_date
|
||||||
|
%p
|
||||||
|
%b Booth limit:
|
||||||
|
= @call_for_booth.booth_limit
|
||||||
|
|
||||||
|
= link_to 'Edit', edit_call_for_booth_path(@call_for_booth)
|
||||||
|
\|
|
||||||
|
= link_to 'Back', call_for_booths_path
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
Osem::Application.routes.draw do
|
Osem::Application.routes.draw do
|
||||||
|
|
||||||
|
|
||||||
if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
if ENV['OSEM_ICHAIN_ENABLED'] == 'true'
|
||||||
devise_for :users, controllers: { registrations: :registrations }
|
devise_for :users, controllers: { registrations: :registrations }
|
||||||
else
|
else
|
||||||
|
|
@ -30,6 +31,7 @@ Osem::Application.routes.draw do
|
||||||
resources :conferences do
|
resources :conferences do
|
||||||
resource :contact, except: [:index, :new, :create, :show, :destroy]
|
resource :contact, except: [:index, :new, :create, :show, :destroy]
|
||||||
resources :schedules, only: [:index, :create, :show, :update, :destroy]
|
resources :schedules, only: [:index, :create, :show, :update, :destroy]
|
||||||
|
resources :booths
|
||||||
resources :event_schedules, only: [:create, :update, :destroy]
|
resources :event_schedules, only: [:create, :update, :destroy]
|
||||||
get 'commercials/render_commercial' => 'commercials#render_commercial'
|
get 'commercials/render_commercial' => 'commercials#render_commercial'
|
||||||
resources :commercials, only: [:index, :create, :update, :destroy]
|
resources :commercials, only: [:index, :create, :update, :destroy]
|
||||||
|
|
@ -52,6 +54,7 @@ Osem::Application.routes.draw do
|
||||||
resources :rooms, except: [:show]
|
resources :rooms, except: [:show]
|
||||||
end
|
end
|
||||||
resource :registration_period
|
resource :registration_period
|
||||||
|
resource :call_for_booths
|
||||||
resource :program do
|
resource :program do
|
||||||
resource :cfp
|
resource :cfp
|
||||||
resources :tracks
|
resources :tracks
|
||||||
|
|
|
||||||
11
db/migrate/20170606182954_create_call_for_booths.rb
Normal file
11
db/migrate/20170606182954_create_call_for_booths.rb
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
class CreateCallForBooths < ActiveRecord::Migration
|
||||||
|
def change
|
||||||
|
create_table :call_for_booths do |t|
|
||||||
|
t.date :start_date
|
||||||
|
t.date :end_date
|
||||||
|
t.integer :booth_limit
|
||||||
|
|
||||||
|
t.timestamps null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
FactoryGirl.define do
|
|
||||||
factory :booth_request do
|
|
||||||
booth nil
|
|
||||||
user nil
|
|
||||||
role "MyString"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
@ -1,7 +0,0 @@
|
||||||
require 'test_helper'
|
|
||||||
|
|
||||||
class BoothRequestTest < ActiveSupport::TestCase
|
|
||||||
# test "the truth" do
|
|
||||||
# assert true
|
|
||||||
# end
|
|
||||||
end
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue