diff --git a/app/controllers/booths_controller.rb b/app/controllers/booths_controller.rb new file mode 100644 index 00000000..e739eb3a --- /dev/null +++ b/app/controllers/booths_controller.rb @@ -0,0 +1,83 @@ +class BoothsController < ApplicationController + before_action :set_booth, only: [:show, :edit, :update, :destroy] + + # GET /booths + # GET /booths.json + def index + @booths = Booth.all + + respond_to do |format| + format.html # index.html.erb + format.json { render json: @booths } + end + end + + # GET /booths/1 + # GET /booths/1.json + def show + respond_to do |format| + format.html # show.html.erb + format.json { render json: @booth } + end + end + + # GET /booths/new + def new + @booth = Booth.new + end + + # GET /booths/1/edit + def edit + end + + # POST /booths + # POST /booths.json + def create + @booth = Booth.new(booth_params) + + respond_to do |format| + if @booth.save + format.html { redirect_to @booth, notice: 'Booth was successfully created.' } + format.json { render json: @booth, status: :created } + else + format.html { render action: 'new' } + format.json { render json: @booth.errors, status: :unprocessable_entity } + end + end + end + + # PATCH/PUT /booths/1 + # PATCH/PUT /booths/1.json + def update + respond_to do |format| + if @booth.update(booth_params) + format.html { redirect_to @booth, notice: 'Booth was successfully updated.' } + format.json { head :no_content } + else + format.html { render action: 'edit' } + format.json { render json: @booth.errors, status: :unprocessable_entity } + end + end + end + + # DELETE /booths/1 + # DELETE /booths/1.json + def destroy + @booth.destroy + respond_to do |format| + format.html { redirect_to booths_url } + format.json { head :no_content } + end + end + + private + # Use callbacks to share common setup or constraints between actions. + def set_booth + @booth = Booth.find(params[:id]) + end + + # Never trust parameters from the scary internet, only allow the white list through. + def booth_params + params.require(:booth).permit(:title, :conference_id, :description, :state, :reasoning, :logo_link) + end +end diff --git a/app/controllers/call_for_booths_controller.rb b/app/controllers/call_for_booths_controller.rb new file mode 100644 index 00000000..16d38a33 --- /dev/null +++ b/app/controllers/call_for_booths_controller.rb @@ -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 diff --git a/app/models/booth.rb b/app/models/booth.rb new file mode 100644 index 00000000..59e1a734 --- /dev/null +++ b/app/models/booth.rb @@ -0,0 +1,16 @@ +class Booth < ActiveRecord::Base + belongs_to :conference + has_many :booth_requests + has_many :users, through: :booth_requests + + validates :title, + uniqueness: { case_sensitive: fasle}, + presence: true + + validates :description, + :reasoning, + :state, + :logo_link + :conference_id, + presence: true +end diff --git a/app/models/booth_request.rb b/app/models/booth_request.rb new file mode 100644 index 00000000..d29c88fd --- /dev/null +++ b/app/models/booth_request.rb @@ -0,0 +1,10 @@ +class BoothRequest < ActiveRecord::Base + belongs_to :booth + belongs_to :user + + validates :booth, + :user, + :role, + presence: true + +end diff --git a/app/models/call_for_booth.rb b/app/models/call_for_booth.rb new file mode 100644 index 00000000..0f16cdcd --- /dev/null +++ b/app/models/call_for_booth.rb @@ -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 diff --git a/app/models/conference.rb b/app/models/conference.rb index f58c50ed..fd62c7bb 100644 --- a/app/models/conference.rb +++ b/app/models/conference.rb @@ -16,6 +16,7 @@ class Conference < ActiveRecord::Base has_one :splashpage, dependent: :destroy has_one :contact, dependent: :destroy has_one :registration_period, dependent: :destroy + has_one :call_for_booths, dependent: :destroy has_one :email_settings, dependent: :destroy has_one :program, dependent: :destroy has_one :venue, dependent: :destroy @@ -24,6 +25,7 @@ class Conference < ActiveRecord::Base has_many :supporters, through: :ticket_purchases, source: :user has_many :tickets, dependent: :destroy has_many :resources, dependent: :destroy + has_many :booths, dependent: :destroy has_many :lodgings, dependent: :destroy has_many :registrations, dependent: :destroy diff --git a/app/models/user.rb b/app/models/user.rb index 4be77fe8..8b0224fa 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -50,11 +50,13 @@ class User < ActiveRecord::Base has_many :votes, dependent: :destroy has_many :voted_events, through: :votes, source: :events has_many :subscriptions, dependent: :destroy + has_many :booth_requests + has_many :booths, through: :users_booths accepts_nested_attributes_for :roles scope :admin, -> { where(is_admin: true) } scope :active, -> { where(is_disabled: false) } - + validates :email, presence: true validates :username, diff --git a/app/views/booths/_form.html.haml b/app/views/booths/_form.html.haml new file mode 100644 index 00000000..4f85e0f1 --- /dev/null +++ b/app/views/booths/_form.html.haml @@ -0,0 +1,28 @@ += form_for @booth do |f| + - if @booth.errors.any? + #error_explanation + %h2= "#{pluralize(@booth.errors.count, "error")} prohibited this booth from being saved:" + %ul + - @booth.errors.full_messages.each do |msg| + %li= msg + + .field + = f.label :title + = f.text_field :title + .field + = f.label :conference_id + = f.number_field :conference_id + .field + = f.label :description + = f.text_area :description + .field + = f.label :state + = f.text_field :state + .field + = f.label :reasoning + = f.text_area :reasoning + .field + = f.label :logo_link + = f.text_field :logo_link + .actions + = f.submit 'Save' diff --git a/app/views/booths/edit.html.haml b/app/views/booths/edit.html.haml new file mode 100644 index 00000000..222d6c97 --- /dev/null +++ b/app/views/booths/edit.html.haml @@ -0,0 +1,7 @@ +%h1 Editing booth + += render 'form' + += link_to 'Show', @booth +\| += link_to 'Back', booths_path diff --git a/app/views/booths/index.html.haml b/app/views/booths/index.html.haml new file mode 100644 index 00000000..2554b986 --- /dev/null +++ b/app/views/booths/index.html.haml @@ -0,0 +1,29 @@ +%h1 Listing booths + +%table + %tr + %th Title + %th Conference + %th Description + %th State + %th Reasoning + %th Logo link + %th + %th + %th + + - @booths.each do |booth| + %tr + %td= booth.title + %td= booth.conference_id + %td= booth.description + %td= booth.state + %td= booth.reasoning + %td= booth.logo_link + %td= link_to 'Show', booth + %td= link_to 'Edit', edit_booth_path(booth) + %td= link_to 'Destroy', booth, :method => :delete, :data => { :confirm => 'Are you sure?' } + +%br + += link_to 'New Booth', new_booth_path diff --git a/app/views/booths/new.html.haml b/app/views/booths/new.html.haml new file mode 100644 index 00000000..3a84ba98 --- /dev/null +++ b/app/views/booths/new.html.haml @@ -0,0 +1,5 @@ +%h1 New booth + += render 'form' + += link_to 'Back', booths_path diff --git a/app/views/booths/show.html.haml b/app/views/booths/show.html.haml new file mode 100644 index 00000000..5c076aca --- /dev/null +++ b/app/views/booths/show.html.haml @@ -0,0 +1,24 @@ +%p#notice= notice + +%p + %b Title: + = @booth.title +%p + %b Conference: + = @booth.conference_id +%p + %b Description: + = @booth.description +%p + %b State: + = @booth.state +%p + %b Reasoning: + = @booth.reasoning +%p + %b Logo link: + = @booth.logo_link + += link_to 'Edit', edit_booth_path(@booth) +\| += link_to 'Back', booths_path diff --git a/app/views/call_for_booths/_form.html.haml b/app/views/call_for_booths/_form.html.haml new file mode 100644 index 00000000..61331987 --- /dev/null +++ b/app/views/call_for_booths/_form.html.haml @@ -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' diff --git a/app/views/call_for_booths/edit.html.haml b/app/views/call_for_booths/edit.html.haml new file mode 100644 index 00000000..f6ef190c --- /dev/null +++ b/app/views/call_for_booths/edit.html.haml @@ -0,0 +1,7 @@ +%h1 Editing call_for_booth + += render 'form' + += link_to 'Show', @call_for_booth +\| += link_to 'Back', call_for_booths_path diff --git a/app/views/call_for_booths/index.html.haml b/app/views/call_for_booths/index.html.haml new file mode 100644 index 00000000..767c67b8 --- /dev/null +++ b/app/views/call_for_booths/index.html.haml @@ -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 diff --git a/app/views/call_for_booths/new.html.haml b/app/views/call_for_booths/new.html.haml new file mode 100644 index 00000000..b8f9c3eb --- /dev/null +++ b/app/views/call_for_booths/new.html.haml @@ -0,0 +1,5 @@ +%h1 New call_for_booth + += render 'form' + += link_to 'Back', call_for_booths_path diff --git a/app/views/call_for_booths/show.html.haml b/app/views/call_for_booths/show.html.haml new file mode 100644 index 00000000..69b4e773 --- /dev/null +++ b/app/views/call_for_booths/show.html.haml @@ -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 diff --git a/config/routes.rb b/config/routes.rb index ccca3511..c5889406 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,6 @@ Osem::Application.routes.draw do + if ENV['OSEM_ICHAIN_ENABLED'] == 'true' devise_for :users, controllers: { registrations: :registrations } else @@ -30,6 +31,7 @@ Osem::Application.routes.draw do resources :conferences do resource :contact, except: [:index, :new, :create, :show, :destroy] resources :schedules, only: [:index, :create, :show, :update, :destroy] + resources :booths resources :event_schedules, only: [:create, :update, :destroy] get 'commercials/render_commercial' => 'commercials#render_commercial' resources :commercials, only: [:index, :create, :update, :destroy] @@ -52,6 +54,7 @@ Osem::Application.routes.draw do resources :rooms, except: [:show] end resource :registration_period + resource :call_for_booths resource :program do resource :cfp resources :tracks diff --git a/db/migrate/20170516190048_create_booths.rb b/db/migrate/20170516190048_create_booths.rb new file mode 100644 index 00000000..3b155bc8 --- /dev/null +++ b/db/migrate/20170516190048_create_booths.rb @@ -0,0 +1,14 @@ +class CreateBooths < ActiveRecord::Migration + def change + create_table :booths do |t| + t.string :title + t.text :description + t.text :reasoning + t.string :state + t.string :logo_link + t.integer :conference_id + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20170530112510_create_booth_requests.rb b/db/migrate/20170530112510_create_booth_requests.rb new file mode 100644 index 00000000..75e73a93 --- /dev/null +++ b/db/migrate/20170530112510_create_booth_requests.rb @@ -0,0 +1,11 @@ +class CreateBoothRequests < ActiveRecord::Migration + def change + create_table :booth_requests do |t| + t.references :booth, index: true, foreign_key: true + t.references :user, index: true, foreign_key: true + t.string :role + + t.timestamps null: false + end + end +end diff --git a/db/migrate/20170606182954_create_call_for_booths.rb b/db/migrate/20170606182954_create_call_for_booths.rb new file mode 100644 index 00000000..fe4e6f3c --- /dev/null +++ b/db/migrate/20170606182954_create_call_for_booths.rb @@ -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 diff --git a/db/schema.rb b/db/schema.rb index 9772066a..4e7366a2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,6 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. + ActiveRecord::Schema.define(version: 20170531094819) do create_table "ahoy_events", force: :cascade do |t| @@ -31,6 +32,28 @@ ActiveRecord::Schema.define(version: 20170531094819) do t.datetime "updated_at" end + create_table "booth_requests", force: :cascade do |t| + t.integer "booth_id" + t.integer "user_id" + t.string "role" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + + add_index "booth_requests", ["booth_id"], name: "index_booth_requests_on_booth_id" + add_index "booth_requests", ["user_id"], name: "index_booth_requests_on_user_id" + + create_table "booths", force: :cascade do |t| + t.string "title" + t.text "description" + t.text "reasoning" + t.string "state" + t.string "logo_link" + t.integer "conference_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "campaigns", force: :cascade do |t| t.integer "conference_id" t.string "name"