diff options
| author | hukl <contact@smyck.org> | 2009-04-18 14:23:02 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-04-18 14:23:02 +0200 |
| commit | 1a80d6cd79235694cc8babf8dc779be3155c9111 (patch) | |
| tree | 4bea63bf7db094de8ca6027e9af45e371e4d865c | |
| parent | 51797bf2b5f86d14139ba985e9c777fa0160af46 (diff) | |
adding event information to the metadata section allowing to add and edit events
| -rw-r--r-- | app/controllers/events_controller.rb | 6 | ||||
| -rw-r--r-- | app/helpers/nodes_helper.rb | 9 | ||||
| -rw-r--r-- | app/views/nodes/edit.html.erb | 4 |
3 files changed, 16 insertions, 3 deletions
diff --git a/app/controllers/events_controller.rb b/app/controllers/events_controller.rb index c25c73f..04e9908 100644 --- a/app/controllers/events_controller.rb +++ b/app/controllers/events_controller.rb | |||
| @@ -24,7 +24,7 @@ class EventsController < ApplicationController | |||
| 24 | # GET /events/new | 24 | # GET /events/new |
| 25 | # GET /events/new.xml | 25 | # GET /events/new.xml |
| 26 | def new | 26 | def new |
| 27 | @event = Event.new | 27 | @event = Event.new(:node_id => params[:node_id]) |
| 28 | 28 | ||
| 29 | respond_to do |format| | 29 | respond_to do |format| |
| 30 | format.html # new.html.erb | 30 | format.html # new.html.erb |
| @@ -45,7 +45,7 @@ class EventsController < ApplicationController | |||
| 45 | respond_to do |format| | 45 | respond_to do |format| |
| 46 | if @event.save | 46 | if @event.save |
| 47 | flash[:notice] = 'Event was successfully created.' | 47 | flash[:notice] = 'Event was successfully created.' |
| 48 | format.html { redirect_to(@event) } | 48 | format.html { redirect_to(edit_node_path(@event.node)) } |
| 49 | format.xml { render :xml => @event, :status => :created, :location => @event } | 49 | format.xml { render :xml => @event, :status => :created, :location => @event } |
| 50 | else | 50 | else |
| 51 | format.html { render :action => "new" } | 51 | format.html { render :action => "new" } |
| @@ -62,7 +62,7 @@ class EventsController < ApplicationController | |||
| 62 | respond_to do |format| | 62 | respond_to do |format| |
| 63 | if @event.update_attributes(params[:event]) | 63 | if @event.update_attributes(params[:event]) |
| 64 | flash[:notice] = 'Event was successfully updated.' | 64 | flash[:notice] = 'Event was successfully updated.' |
| 65 | format.html { redirect_to(@event) } | 65 | format.html { redirect_to(edit_node_path(@event.node)) } |
| 66 | format.xml { head :ok } | 66 | format.xml { head :ok } |
| 67 | else | 67 | else |
| 68 | format.html { render :action => "edit" } | 68 | format.html { render :action => "edit" } |
diff --git a/app/helpers/nodes_helper.rb b/app/helpers/nodes_helper.rb index 63db995..9bee8d8 100644 --- a/app/helpers/nodes_helper.rb +++ b/app/helpers/nodes_helper.rb | |||
| @@ -11,4 +11,13 @@ module NodesHelper | |||
| 11 | def custom_page_templates | 11 | def custom_page_templates |
| 12 | Page.custom_templates.map {|x| [x.gsub("_", " ").titlecase, x]} | 12 | Page.custom_templates.map {|x| [x.gsub("_", " ").titlecase, x]} |
| 13 | end | 13 | end |
| 14 | |||
| 15 | |||
| 16 | def event_information | ||
| 17 | if @node.event | ||
| 18 | "#{@node.event.start_time} - #{@node.event.end_time} > #{link_to 'edit', edit_event_path(@node.event)}" | ||
| 19 | else | ||
| 20 | "no event attached > #{link_to 'add', new_event_path(:event_node_id => @node.id)}" | ||
| 21 | end | ||
| 22 | end | ||
| 14 | end | 23 | end |
diff --git a/app/views/nodes/edit.html.erb b/app/views/nodes/edit.html.erb index 0d0b0d3..fe4934f 100644 --- a/app/views/nodes/edit.html.erb +++ b/app/views/nodes/edit.html.erb | |||
| @@ -13,6 +13,10 @@ | |||
| 13 | 13 | ||
| 14 | <table id="metadata"> | 14 | <table id="metadata"> |
| 15 | <tr> | 15 | <tr> |
| 16 | <td class="description">Event</td> | ||
| 17 | <td><%= event_information %></td> | ||
| 18 | </tr> | ||
| 19 | <tr> | ||
| 16 | <td class="description">Slug</td> | 20 | <td class="description">Slug</td> |
| 17 | <td><%= f.text_field :slug %></td> | 21 | <td><%= f.text_field :slug %></td> |
| 18 | </tr> | 22 | </tr> |
