Refactoring venue
This commit is contained in:
parent
c0cdf3e6e5
commit
9d08f52636
13 changed files with 108 additions and 57 deletions
|
|
@ -1,27 +0,0 @@
|
||||||
module Admin
|
|
||||||
class VenueController < Admin::BaseController
|
|
||||||
load_and_authorize_resource :conference, find_by: :short_title
|
|
||||||
load_and_authorize_resource :venue, through: :conference, singleton: true
|
|
||||||
|
|
||||||
def index; end
|
|
||||||
|
|
||||||
def update
|
|
||||||
@venue = @conference.venue
|
|
||||||
@venue.assign_attributes(params[:venue])
|
|
||||||
send_mail = @venue.venue_notify?(@conference)
|
|
||||||
if @venue.update_attributes(params[:venue])
|
|
||||||
Mailbot.delay.send_email_on_venue_update(@conference) if send_mail
|
|
||||||
redirect_to(admin_conference_venue_info_path(conference_id: @conference.short_title),
|
|
||||||
notice: 'Venue was successfully updated.')
|
|
||||||
else
|
|
||||||
redirect_to(admin_conference_venue_info_path(conference_id: @conference.short_title),
|
|
||||||
notice: 'Venue Updation Failed!')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def show
|
|
||||||
@venue = @conference.venue
|
|
||||||
render :venue_info
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
18
app/controllers/admin/venues_controller.rb
Normal file
18
app/controllers/admin/venues_controller.rb
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
module Admin
|
||||||
|
class VenuesController < Admin::BaseController
|
||||||
|
load_and_authorize_resource :conference, find_by: :short_title
|
||||||
|
load_and_authorize_resource :venue, through: :conference, singleton: true
|
||||||
|
|
||||||
|
def edit; end
|
||||||
|
|
||||||
|
def update
|
||||||
|
if @venue.update_attributes(params[:venue])
|
||||||
|
redirect_to(edit_admin_conference_venue_path(conference_id: @conference.short_title),
|
||||||
|
notice: 'Venue was successfully updated.')
|
||||||
|
else
|
||||||
|
flash[:error] = "Update venue failed: #{@venue.errors.full_messages.join('. ')}."
|
||||||
|
render :edit
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -12,6 +12,16 @@ class Venue < ActiveRecord::Base
|
||||||
size: { in: 0..500.kilobytes }
|
size: { in: 0..500.kilobytes }
|
||||||
accepts_nested_attributes_for :lodgings, allow_destroy: true
|
accepts_nested_attributes_for :lodgings, allow_destroy: true
|
||||||
|
|
||||||
|
after_update :send_mail_notification
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
def send_mail_notification
|
||||||
|
conferences.each do |conference|
|
||||||
|
Mailbot.delay.send_email_on_venue_update(conference) if venue_notify?(conference)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def venue_notify?(conference)
|
def venue_notify?(conference)
|
||||||
(self.name_changed? || self.address_changed?) &&
|
(self.name_changed? || self.address_changed?) &&
|
||||||
(!self.name.blank? && !self.address.blank?) &&
|
(!self.name.blank? && !self.address.blank?) &&
|
||||||
|
|
@ -20,8 +30,6 @@ class Venue < ActiveRecord::Base
|
||||||
conference.email_settings.venue_update_template)
|
conference.email_settings.venue_update_template)
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
# TODO: create a module to be mixed into model to perform same operation
|
# TODO: create a module to be mixed into model to perform same operation
|
||||||
# event.rb has same functionality which can be shared
|
# event.rb has same functionality which can be shared
|
||||||
# TODO: rename guid to UUID as guid is specifically Microsoft term
|
# TODO: rename guid to UUID as guid is specifically Microsoft term
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
%li{'class'=>class_for_todo(conference_progress['venue'])}
|
%li{'class'=>class_for_todo(conference_progress['venue'])}
|
||||||
%span{'class'=>icon_for_todo(conference_progress['venue'])}
|
%span{'class'=>icon_for_todo(conference_progress['venue'])}
|
||||||
- if can? :update, @conference.venue
|
- if can? :update, @conference.venue
|
||||||
= link_to 'Add venue', admin_conference_venue_info_path(conference_progress['short_title'])
|
= link_to 'Add venue', edit_admin_conference_venue_path(conference_progress['short_title'])
|
||||||
- else
|
- else
|
||||||
Add venue
|
Add venue
|
||||||
%li{'class'=>class_for_todo(conference_progress['rooms'])}
|
%li{'class'=>class_for_todo(conference_progress['rooms'])}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +0,0 @@
|
||||||
.row
|
|
||||||
.col-md-8
|
|
||||||
= semantic_form_for(@venue, :url => admin_conference_venue_update_path(@conference.short_title),:html => {:multipart => true}) do |f|
|
|
||||||
= f.input :name, :input_html => {:rows => 1}
|
|
||||||
= f.input :address, :input_html => {:rows => 1}
|
|
||||||
= f.input :website
|
|
||||||
= f.input :description, :input_html => { :rows => 10, :cols => 20, data: { provide: "markdown-editable" } }, hint: markdown_hint
|
|
||||||
- unless @venue.photo.blank?
|
|
||||||
= image_tag @venue.photo(:thumb)
|
|
||||||
= f.input :photo
|
|
||||||
= f.action :submit, :as => :button, :button_html => {:class => "btn btn-primary"}
|
|
||||||
9
app/views/admin/venues/_form.html.haml
Normal file
9
app/views/admin/venues/_form.html.haml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
= semantic_form_for(@venue, url: admin_conference_venue_path(@conference.short_title)) do |f|
|
||||||
|
= f.input :name, input_html: { rows: 1 }
|
||||||
|
= f.input :address, input_html: { rows: 1 }
|
||||||
|
= f.input :website
|
||||||
|
= f.input :description, input_html: { rows: 5, cols: 20, data: { provide: 'markdown-editable' } }, hint: markdown_hint
|
||||||
|
- unless @venue.photo.blank?
|
||||||
|
= image_tag @venue.photo(:thumb)
|
||||||
|
= f.input :photo
|
||||||
|
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
||||||
38
app/views/admin/venues/_show.html.haml
Normal file
38
app/views/admin/venues/_show.html.haml
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
.row{'style'=>'padding-top: 15px;'}
|
||||||
|
.col-md-6
|
||||||
|
%dl.dl-horizontal
|
||||||
|
%dt
|
||||||
|
Name
|
||||||
|
%dd
|
||||||
|
= @venue.name
|
||||||
|
%dt
|
||||||
|
Address
|
||||||
|
%dd
|
||||||
|
= @venue.address
|
||||||
|
%dt
|
||||||
|
Website
|
||||||
|
%dd
|
||||||
|
= @venue.website
|
||||||
|
%dt
|
||||||
|
Description
|
||||||
|
%dd
|
||||||
|
- unless @venue.description.blank?
|
||||||
|
= markdown(@venue.description)
|
||||||
|
.row.row-flex.row-flex-wrap
|
||||||
|
.col-md-4
|
||||||
|
.thumbnail.flex-col
|
||||||
|
%h3.text-center
|
||||||
|
Venue Logo
|
||||||
|
- if @venue.photo
|
||||||
|
= image_tag(@venue.photo(:large), class: 'img-responsive')
|
||||||
|
.caption.flex-grow
|
||||||
|
.caption
|
||||||
|
%p
|
||||||
|
%dl.dl-horizontal
|
||||||
|
%dt
|
||||||
|
Filename
|
||||||
|
%dd
|
||||||
|
= @venue.photo_file_name
|
||||||
|
-else
|
||||||
|
%h4.text-center
|
||||||
|
Not set!
|
||||||
16
app/views/admin/venues/edit.html.haml
Normal file
16
app/views/admin/venues/edit.html.haml
Normal file
|
|
@ -0,0 +1,16 @@
|
||||||
|
.row
|
||||||
|
.col-md-12
|
||||||
|
%ul.nav.nav-tabs{'role'=>'tablist'}
|
||||||
|
%li.active
|
||||||
|
%a{'href'=> '#show', 'role'=>'tab', 'data-toggle'=>'tab'}
|
||||||
|
Show
|
||||||
|
%li
|
||||||
|
%a{'href'=> '#edit', 'role'=>'tab', 'data-toggle'=>'tab'}
|
||||||
|
Edit
|
||||||
|
.row
|
||||||
|
.col-md-8
|
||||||
|
.tab-content
|
||||||
|
.tab-pane.active#show
|
||||||
|
= render partial: 'show'
|
||||||
|
.tab-pane#edit
|
||||||
|
= render partial: 'form'
|
||||||
|
|
@ -46,8 +46,8 @@
|
||||||
%li{:class=> active_nav_li(admin_conference_splashpage_path(@conference.short_title))}
|
%li{:class=> active_nav_li(admin_conference_splashpage_path(@conference.short_title))}
|
||||||
= link_to 'Splashpage', admin_conference_splashpage_path(@conference.short_title)
|
= link_to 'Splashpage', admin_conference_splashpage_path(@conference.short_title)
|
||||||
- if can? :index, @conference.venue
|
- if can? :index, @conference.venue
|
||||||
%li{:class=> "#{active_nav_li(admin_conference_venue_info_path(@conference.short_title))}"}
|
%li{:class=> "#{active_nav_li(edit_admin_conference_venue_path(@conference.short_title))}"}
|
||||||
= link_to(admin_conference_venue_info_path(@conference.short_title)) do
|
= link_to(edit_admin_conference_venue_path(@conference.short_title)) do
|
||||||
%span.fa.fa-road
|
%span.fa.fa-road
|
||||||
Venue
|
Venue
|
||||||
%ul
|
%ul
|
||||||
|
|
|
||||||
|
|
@ -27,8 +27,6 @@ Osem::Application.routes.draw do
|
||||||
resource :schedule, only: [:show, :update]
|
resource :schedule, only: [:show, :update]
|
||||||
resources :commercials, except: [:show]
|
resources :commercials, except: [:show]
|
||||||
get '/stats' => 'stats#index'
|
get '/stats' => 'stats#index'
|
||||||
get '/venue' => 'venue#show', as: 'venue_info'
|
|
||||||
patch '/venue' => 'venue#update', as: 'venue_update'
|
|
||||||
get '/dietary_choices' => 'dietchoices#show', as: 'dietary_list'
|
get '/dietary_choices' => 'dietchoices#show', as: 'dietary_list'
|
||||||
patch '/dietary_choices' => 'dietchoices#update', as: 'dietary_update'
|
patch '/dietary_choices' => 'dietchoices#update', as: 'dietary_update'
|
||||||
get '/volunteers_list' => 'volunteers#show'
|
get '/volunteers_list' => 'volunteers#show'
|
||||||
|
|
@ -42,6 +40,8 @@ Osem::Application.routes.draw do
|
||||||
|
|
||||||
resource :splashpage
|
resource :splashpage
|
||||||
|
|
||||||
|
resource :venue, only: [:edit, :update]
|
||||||
|
|
||||||
resources :difficulty_levels, only: [:show, :update, :index]
|
resources :difficulty_levels, only: [:show, :update, :index]
|
||||||
|
|
||||||
resources :rooms, only: [:show, :update, :index]
|
resources :rooms, only: [:show, :update, :index]
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ feature 'Has correct abilities' do
|
||||||
expect(page).to have_link('Schedule', href: "/admin/conference/#{conference1.short_title}/schedule")
|
expect(page).to have_link('Schedule', href: "/admin/conference/#{conference1.short_title}/schedule")
|
||||||
expect(page).to have_link('Campaigns', href: "/admin/conference/#{conference1.short_title}/campaigns")
|
expect(page).to have_link('Campaigns', href: "/admin/conference/#{conference1.short_title}/campaigns")
|
||||||
expect(page).to have_link('Goals', href: "/admin/conference/#{conference1.short_title}/targets")
|
expect(page).to have_link('Goals', href: "/admin/conference/#{conference1.short_title}/targets")
|
||||||
expect(page).to have_link('Venue', href: "/admin/conference/#{conference1.short_title}/venue")
|
expect(page).to have_link('Venue', href: "/admin/conference/#{conference1.short_title}/venue/edit")
|
||||||
expect(page).to have_link('Rooms', href: "/admin/conference/#{conference1.short_title}/rooms")
|
expect(page).to have_link('Rooms', href: "/admin/conference/#{conference1.short_title}/rooms")
|
||||||
expect(page).to have_link('Lodgings', href: "/admin/conference/#{conference1.short_title}/lodgings")
|
expect(page).to have_link('Lodgings', href: "/admin/conference/#{conference1.short_title}/lodgings")
|
||||||
expect(page).to have_link('Sponsorship', href: "/admin/conference/#{conference1.short_title}/sponsorship_levels")
|
expect(page).to have_link('Sponsorship', href: "/admin/conference/#{conference1.short_title}/sponsorship_levels")
|
||||||
|
|
@ -64,8 +64,8 @@ feature 'Has correct abilities' do
|
||||||
visit admin_conference_targets_path(conference1.short_title)
|
visit admin_conference_targets_path(conference1.short_title)
|
||||||
expect(current_path).to eq(admin_conference_targets_path(conference1.short_title))
|
expect(current_path).to eq(admin_conference_targets_path(conference1.short_title))
|
||||||
|
|
||||||
visit admin_conference_venue_info_path(conference1.short_title)
|
visit edit_admin_conference_venue_path(conference1.short_title)
|
||||||
expect(current_path).to eq(admin_conference_venue_info_path(conference1.short_title))
|
expect(current_path).to eq(edit_admin_conference_venue_path(conference1.short_title))
|
||||||
|
|
||||||
visit admin_conference_sponsorship_levels_path(conference1.short_title)
|
visit admin_conference_sponsorship_levels_path(conference1.short_title)
|
||||||
expect(current_path).to eq(admin_conference_sponsorship_levels_path(conference1.short_title))
|
expect(current_path).to eq(admin_conference_sponsorship_levels_path(conference1.short_title))
|
||||||
|
|
@ -100,7 +100,7 @@ feature 'Has correct abilities' do
|
||||||
expect(page).to have_link('Schedule', href: "/admin/conference/#{conference2.short_title}/schedule")
|
expect(page).to have_link('Schedule', href: "/admin/conference/#{conference2.short_title}/schedule")
|
||||||
expect(page).to_not have_link('Campaigns', href: "/admin/conference/#{conference2.short_title}/campaigns")
|
expect(page).to_not have_link('Campaigns', href: "/admin/conference/#{conference2.short_title}/campaigns")
|
||||||
expect(page).to_not have_link('Goals', href: "/admin/conference/#{conference2.short_title}/targets")
|
expect(page).to_not have_link('Goals', href: "/admin/conference/#{conference2.short_title}/targets")
|
||||||
expect(page).to have_link('Venue', href: "/admin/conference/#{conference2.short_title}/venue")
|
expect(page).to have_link('Venue', href: "/admin/conference/#{conference2.short_title}/venue/edit")
|
||||||
expect(page).to have_link('Rooms', href: "/admin/conference/#{conference2.short_title}/rooms")
|
expect(page).to have_link('Rooms', href: "/admin/conference/#{conference2.short_title}/rooms")
|
||||||
expect(page).to_not have_link('Lodgings', href: "/admin/conference/#{conference2.short_title}/lodgings")
|
expect(page).to_not have_link('Lodgings', href: "/admin/conference/#{conference2.short_title}/lodgings")
|
||||||
expect(page).to_not have_link('Sponsorship', href: "/admin/conference/#{conference2.short_title}/sponsorship_levels")
|
expect(page).to_not have_link('Sponsorship', href: "/admin/conference/#{conference2.short_title}/sponsorship_levels")
|
||||||
|
|
@ -135,7 +135,7 @@ feature 'Has correct abilities' do
|
||||||
visit admin_conference_targets_path(conference2.short_title)
|
visit admin_conference_targets_path(conference2.short_title)
|
||||||
expect(current_path).to eq(root_path)
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
visit admin_conference_venue_info_path(conference2.short_title)
|
visit edit_admin_conference_venue_path(conference2.short_title)
|
||||||
expect(current_path).to eq(root_path)
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
visit admin_conference_sponsorship_levels_path(conference2.short_title)
|
visit admin_conference_sponsorship_levels_path(conference2.short_title)
|
||||||
|
|
@ -171,7 +171,7 @@ feature 'Has correct abilities' do
|
||||||
expect(page).to_not have_link('Schedule', href: "/admin/conference/#{conference3.short_title}/schedule")
|
expect(page).to_not have_link('Schedule', href: "/admin/conference/#{conference3.short_title}/schedule")
|
||||||
expect(page).to_not have_link('Campaigns', href: "/admin/conference/#{conference3.short_title}/campaigns")
|
expect(page).to_not have_link('Campaigns', href: "/admin/conference/#{conference3.short_title}/campaigns")
|
||||||
expect(page).to_not have_link('Targets', href: "/admin/conference/#{conference3.short_title}/targets")
|
expect(page).to_not have_link('Targets', href: "/admin/conference/#{conference3.short_title}/targets")
|
||||||
expect(page).to_not have_link('Venue', href: "/admin/conference/#{conference3.short_title}/venue")
|
expect(page).to_not have_link('Venue', href: "/admin/conference/#{conference3.short_title}/venue/edit")
|
||||||
expect(page).to_not have_link('Rooms', href: "/admin/conference/#{conference3.short_title}/rooms")
|
expect(page).to_not have_link('Rooms', href: "/admin/conference/#{conference3.short_title}/rooms")
|
||||||
expect(page).to_not have_link('Lodgings', href: "/admin/conference/#{conference3.short_title}/lodgings")
|
expect(page).to_not have_link('Lodgings', href: "/admin/conference/#{conference3.short_title}/lodgings")
|
||||||
expect(page).to_not have_link('Sponsorship', href: "/admin/conference/#{conference3.short_title}/sponsorship_levels")
|
expect(page).to_not have_link('Sponsorship', href: "/admin/conference/#{conference3.short_title}/sponsorship_levels")
|
||||||
|
|
@ -206,7 +206,7 @@ feature 'Has correct abilities' do
|
||||||
visit admin_conference_targets_path(conference3.short_title)
|
visit admin_conference_targets_path(conference3.short_title)
|
||||||
expect(current_path).to eq(root_path)
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
visit admin_conference_venue_info_path(conference3.short_title)
|
visit edit_admin_conference_venue_path(conference3.short_title)
|
||||||
expect(current_path).to eq(root_path)
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
visit admin_conference_sponsorship_levels_path(conference3.short_title)
|
visit admin_conference_sponsorship_levels_path(conference3.short_title)
|
||||||
|
|
@ -243,7 +243,7 @@ feature 'Has correct abilities' do
|
||||||
expect(page).to_not have_link('Schedule', href: "/admin/conference/#{conference4.short_title}/schedule")
|
expect(page).to_not have_link('Schedule', href: "/admin/conference/#{conference4.short_title}/schedule")
|
||||||
expect(page).to_not have_link('Campaigns', href: "/admin/conference/#{conference4.short_title}/campaigns")
|
expect(page).to_not have_link('Campaigns', href: "/admin/conference/#{conference4.short_title}/campaigns")
|
||||||
expect(page).to_not have_link('Goals', href: "/admin/conference/#{conference4.short_title}/targets")
|
expect(page).to_not have_link('Goals', href: "/admin/conference/#{conference4.short_title}/targets")
|
||||||
expect(page).to_not have_link('Venue', href: "/admin/conference/#{conference4.short_title}/venue")
|
expect(page).to_not have_link('Venue', href: "/admin/conference/#{conference4.short_title}/venue/edit")
|
||||||
expect(page).to_not have_link('Rooms', href: "/admin/conference/#{conference4.short_title}/rooms")
|
expect(page).to_not have_link('Rooms', href: "/admin/conference/#{conference4.short_title}/rooms")
|
||||||
expect(page).to_not have_link('Lodgings', href: "/admin/conference/#{conference4.short_title}/lodgings")
|
expect(page).to_not have_link('Lodgings', href: "/admin/conference/#{conference4.short_title}/lodgings")
|
||||||
expect(page).to_not have_link('Sponsorship', href: "/admin/conference/#{conference4.short_title}/sponsorship_levels")
|
expect(page).to_not have_link('Sponsorship', href: "/admin/conference/#{conference4.short_title}/sponsorship_levels")
|
||||||
|
|
@ -278,7 +278,7 @@ feature 'Has correct abilities' do
|
||||||
visit admin_conference_targets_path(conference4.short_title)
|
visit admin_conference_targets_path(conference4.short_title)
|
||||||
expect(current_path).to eq(root_path)
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
visit admin_conference_venue_info_path(conference4.short_title)
|
visit edit_admin_conference_venue_path(conference4.short_title)
|
||||||
expect(current_path).to eq(root_path)
|
expect(current_path).to eq(root_path)
|
||||||
|
|
||||||
visit admin_conference_sponsorship_levels_path(conference4.short_title)
|
visit admin_conference_sponsorship_levels_path(conference4.short_title)
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ feature Conference do
|
||||||
|
|
||||||
sign_in organizer
|
sign_in organizer
|
||||||
|
|
||||||
visit admin_conference_venue_info_path(
|
visit edit_admin_conference_venue_path(
|
||||||
conference_id: conference.short_title)
|
conference_id: conference.short_title)
|
||||||
|
|
||||||
expect(page.find("//*[@id='venue_submit_action']").
|
expect(page.find("//*[@id='venue_submit_action']").
|
||||||
|
|
@ -1,8 +1,8 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe 'admin/venue/venue_info' do
|
describe 'admin/venues/edit' do
|
||||||
|
|
||||||
it 'renders venue#show' do
|
it 'renders venues#show' do
|
||||||
@conference = create(:conference)
|
@conference = create(:conference)
|
||||||
@venue = @conference.venue
|
@venue = @conference.venue
|
||||||
@venue.name = 'Croatia'
|
@venue.name = 'Croatia'
|
||||||
Loading…
Add table
Add a link
Reference in a new issue