diff --git a/app/controllers/admin/call_for_booths_controller.rb b/app/controllers/admin/call_for_booths_controller.rb index 39fee8eb..de537742 100644 --- a/app/controllers/admin/call_for_booths_controller.rb +++ b/app/controllers/admin/call_for_booths_controller.rb @@ -3,11 +3,12 @@ module Admin load_and_authorize_resource :conference, find_by: :short_title load_and_authorize_resource through: :conference, singleton: true - def show; end + def show + end def new - @call_for_booth = CallForBooth.new(conference: @conference) + @call_for_booths = CallForBooth.new(conference: @conference) end def edit; end diff --git a/app/controllers/booths_controller.rb b/app/controllers/booths_controller.rb deleted file mode 100644 index 232150a5..00000000 --- a/app/controllers/booths_controller.rb +++ /dev/null @@ -1,71 +0,0 @@ -class BoothsController < ApplicationController - before_action :set_booth, only: [:show, :edit, :update, :destroy] - - # GET /booths - def index - @booths = Booth.all - - respond_to do |format| - format.html # index.html.erb - end - end - - # GET /booths/1 - def show - respond_to do |format| - format.html # show.html.erb - end - end - - # GET /booths/new - def new - @booth = Booth.new - end - - # GET /booths/1/edit - def edit - end - - # POST /booths - def create - @booth = Booth.new(booth_params) - - respond_to do |format| - if @booth.save - format.html { redirect_to @booth, notice: 'Booth was successfully created.' } - else - format.html { render action: 'new' } - end - end - end - - # PATCH/PUT /booths/1 - def update - respond_to do |format| - if @booth.update(booth_params) - format.html { redirect_to @booth, notice: 'Booth was successfully updated.' } - else - format.html { render action: 'edit' } - end - end - end - - # DELETE /booths/1 - def destroy - @booth.destroy - respond_to do |format| - format.html { redirect_to booths_url } - 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/models/booth.rb b/app/models/booth.rb index 5d1c79a8..fe11b1a6 100644 --- a/app/models/booth.rb +++ b/app/models/booth.rb @@ -3,6 +3,7 @@ class Booth < ActiveRecord::Base belongs_to :conference has_many :booth_requests + has_one :call_for_booths has_many :users, through: :booth_requests has_one :submitter_booth_user, -> { where(role: 'submitter') }, class_name: 'BoothRequest' @@ -21,11 +22,7 @@ class Booth < ActiveRecord::Base :conference_id, presence: true - validate :logo_link - include Gravtastic - gravtastic size: 32 - state_machine initial: :submitted do state :submitted state :withdrawn @@ -67,4 +64,5 @@ class Booth < ActiveRecord::Base end alert end + end diff --git a/app/models/call_for_booth.rb b/app/models/call_for_booth.rb index 0f16cdcd..2e04e773 100644 --- a/app/models/call_for_booth.rb +++ b/app/models/call_for_booth.rb @@ -1,10 +1,16 @@ class CallForBooth < ActiveRecord::Base belongs_to :conference + has_many :booths + validates :start_date, :end_date, :booth_limit, presence: true validate :before_end_of_conference validate :start_date_before_end_date + def remaining_days(date = Date.today) + end_date - date > 0 ? (end_date - date) : 0 + end + private def before_end_of_conference diff --git a/app/views/admin/booths/_form.html.haml b/app/views/admin/booths/_form.html.haml index 91ac9ae7..9aa0f74a 100644 --- a/app/views/admin/booths/_form.html.haml +++ b/app/views/admin/booths/_form.html.haml @@ -10,8 +10,7 @@ = f.input :reasoning, input_html: { rows: 5, data: { provide: 'markdown-editable' } }, required: true = responsibles_selector_input f = f.input :logo_link, as: :string, required: true - - + %p.text-right - if @booth.new_record? = f.submit 'Create Booth Request', class: 'btn btn-success' diff --git a/app/views/admin/booths/show.html.haml b/app/views/admin/booths/show.html.haml index 77dd180c..e4b305b3 100644 --- a/app/views/admin/booths/show.html.haml +++ b/app/views/admin/booths/show.html.haml @@ -1,6 +1,7 @@ .row .col-md-12 %h3 + = image_tag(@booth.gravatar_url(size: '48')) = @booth.title .btn-group.pull-right = link_to 'Edit', edit_admin_conference_booth_path(@conference.short_title, @booth), class: 'btn btn-mini btn-primary' diff --git a/app/views/admin/call_for_booths/_form.html.haml b/app/views/admin/call_for_booths/_form.html.haml index 61331987..70b0652f 100644 --- a/app/views/admin/call_for_booths/_form.html.haml +++ b/app/views/admin/call_for_booths/_form.html.haml @@ -1,19 +1,12 @@ -= 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' +.row + .col-md-12 + .page-header + %h1 Call for Booths +.row + .col-md-8 + = semantic_form_for(@call_for_booth, url: admin_conference_call_for_booths_path(@conference.short_title), html: {multipart: true}) do |f| + = f.input :start_date, as: :string, input_html: { id: 'registration-period-start-datepicker', start_date: @conference.start_date, end_date: @conference.end_date, readonly: 'readonly' } + = f.input :end_date, as: :string, input_html: { id: 'registration-period-end-datepicker', readonly: 'readonly' } + = f.input :booth_limit + %p.text-right + = f.action :submit, as: :button, button_html: { class: 'btn btn-primary' } diff --git a/app/views/admin/call_for_booths/new.html.haml b/app/views/admin/call_for_booths/new.html.haml index b8f9c3eb..cf3822ef 100644 --- a/app/views/admin/call_for_booths/new.html.haml +++ b/app/views/admin/call_for_booths/new.html.haml @@ -1,5 +1,3 @@ %h1 New call_for_booth = render 'form' - -= link_to 'Back', call_for_booths_path diff --git a/app/views/admin/call_for_booths/show.html.haml b/app/views/admin/call_for_booths/show.html.haml index 69b4e773..c3cbf85b 100644 --- a/app/views/admin/call_for_booths/show.html.haml +++ b/app/views/admin/call_for_booths/show.html.haml @@ -1,15 +1,36 @@ -%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 +.row + .col-md-12 + .page-header + %h1 Call for Booths + %p.text-muted + Call for people to submit booth requests to your conference +- if @call_for_booth + .row + .col-md-8 + %dl.dl-horizontal + %dt + Start Date + %dd + = @call_for_booth.start_date.strftime('%A, %B %-d. %Y') + %dt + End Date + %dd + = @call_for_booth.end_date.strftime('%A, %B %-d. %Y') + %dt + Days Left + %dd + = pluralize(@call_for_booth.remaining_days, 'day') + %dt + Maximum Booths + %dd + = @call_for_booth.booth_limit + .row + .col-md-12.text-right + = link_to(edit_admin_conference_call_for_booths_path(@conference.short_title), class: 'btn btn-primary') do + Edit + = link_to(admin_conference_call_for_booths_path(@conference.short_title), method: 'delete', class: 'btn btn-danger', data: {confirm: 'Are you sure you want to delete the Call for Booths?'}) do + Delete +- else + .row + .col-md-12.text-right + = link_to 'Create new Call for Pappers', new_admin_conference_call_for_booths_path(@conference.short_title), class: 'btn btn-primary'