Skip to content

Commit

Permalink
you can now add empty tours
Browse files Browse the repository at this point in the history
  • Loading branch information
JKen13579 committed May 7, 2011
1 parent a5b6189 commit 1969747
Show file tree
Hide file tree
Showing 8 changed files with 836 additions and 26 deletions.
19 changes: 19 additions & 0 deletions app/controllers/tours_controller.rb
Expand Up @@ -2,6 +2,25 @@ class ToursController < CmsapplicationController
def index
@tours = Tour.all
end

def tour_items
@tour_item = TourItem.new
@tours = Tour.all
@artworks = Artwork.all

respond_to do |format|
format.html
end
end

def create_tour_item
@tour_item = TourItem.new(params[:touritem])
if @tour_item.save
redirect_to(tours_path)
else
render :action => "tour_item"
end
end

# GET /tours/1
# GET /tours/1.xml
Expand Down
46 changes: 20 additions & 26 deletions app/views/tours/_form.html.erb
@@ -1,28 +1,22 @@
<%= form_for(@tour) do |f| %>
<% if @tour.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@tour.errors.count, "error") %> prohibited this tour from being saved:</h2>

<ul>
<% @tour.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<h1>For now, tours may contain up to 5 items</h1>
<% 5.times do%>
<div class="field">
<%= f.label :artwork_id %><br />
<%= f.text_field :artwork_id %>
</div>
<div class="field">
<%= f.label :position %><br />
<%= f.text_field :position %>
</div>
<% end %>
<div class="actions">
<%= f.submit %>
</div>
<%= semantic_form_for @tour, do |form| %>
<% if @tour.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@tour.errors.count, "error") %> prohibited this exhibition from being saved:</h2>

<ul>
<% @tour.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<%= form.inputs do %>
<%= form.input :name, :required => true, :wrapper_html => { :title => "Name of the Tour" } %>
<%= form.input :desc, :required => true, :wrapper_html => { :title => "Description of the tour" } %>
<% end %>
<%= form.buttons do %>
<%= form.commit_button :button_html => { :class => "primary" } %>
<% end %>
<% end %>
22 changes: 22 additions & 0 deletions app/views/tours/_tour_items.html.erb
@@ -0,0 +1,22 @@
<%= semantic_form_for @touritem, :url=>arts_path do |f| %>
<% if @touritem.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@touritem.errors.count, "error") %> prohibited this artwork from being saved:</h2>

<ul>
<% @touritem.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<%= f.inputs do %>
<%= f.input :tour_id, :required => true, :as => :select, :collection => @tours, :wrapper_html => { :title => "Tour ID" } %>
<%= f.input :artwork_id, :required => true, :as => :select, :collection => @artworks, :wrapper_html => { :title => "Artist ID" } %>
<% end %>
<%= f.buttons do %>
<%= f.commit_button :button_html => { :class => "primary" } %>
<% end %>
<% end %>
1 change: 1 addition & 0 deletions app/views/tours/index.html.erb
Expand Up @@ -21,6 +21,7 @@
<br />

<%= link_to 'New Tour', new_tour_path %>
<%= link_to 'Add Tour Item', '/tours/tour_items' %>
<style type="text/css">
div#navbar a:nth-child(5){
background-color:#CEF6F5;
Expand Down
10 changes: 10 additions & 0 deletions app/views/tours/tour_item.html.erb
@@ -0,0 +1,10 @@
<h2>Edit a Tour Item</h2>

<%= render "tour_items" %>
<%= link_to 'Back', tours_path %>
<style type="text/css">
div#navbar a:nth-child(5){
background-color:#CEF6F5;
}
</style>
1 change: 1 addition & 0 deletions config/routes.rb
@@ -1,4 +1,5 @@
Artgallery::Application.routes.draw do
match '/tours/tour_items', :to => "tours#tour_items"
resources :exhibitions
devise_for :users
resources :tours
Expand Down
Binary file modified db/development.sqlite3
Binary file not shown.
763 changes: 763 additions & 0 deletions log/development.log

Large diffs are not rendered by default.

0 comments on commit 1969747

Please sign in to comment.