public
Description: Old repository for webjam. New one lives at http://github.com/webjam/webjam
Homepage: http://webjam.com.au
Clone URL: git://github.com/toolmantim/webjam.git
Added preso proposal creating, updating and deleting
toolmantim (author)
Sun Aug 10 00:51:50 -0700 2008
commit  197784a8f835b362dcb9904b70643356888fc0c9
tree    6e79f756769b0f1fbd0ead9d89bf7a16e1a7df9a
parent  6ae7dbba280aa6019c3a2f713521d1169c7f3845
...
1
2
3
 
4
5
6
 
 
7
8
 
9
10
11
12
13
 
 
 
 
 
14
15
16
 
17
18
 
 
 
 
 
 
 
 
 
 
 
 
 
19
...
1
2
 
3
4
5
 
6
7
8
 
9
10
11
 
 
 
12
13
14
15
16
17
18
 
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
0
@@ -1,19 +1,35 @@
0
 class PresentationProposalsController < ApplicationController
0
   before_filter :login_required
0
- def new
0
+ def edit
0
     @event = Event.find_by_tag(params[:event_id])
0
     raise NotFound unless @event
0
- @proposal = @event.presentation_proposals.new(params[:presentation_proposal])
0
+ @proposal = @event.presentation_proposals.find_by_user_id(current_user) || @event.presentation_proposals.build(:user => current_user)
0
+ render_edit_or_new
0
   end
0
- def create
0
+ def update
0
     @event = Event.find_by_tag(params[:event_id])
0
     raise NotFound unless @event
0
- @proposal = @event.presentation_proposals.build(params[:presentation_proposal])
0
- @proposal.user = current_user
0
- if @proposal.save
0
+ @proposal = @event.presentation_proposals.find_by_user_id(current_user) || @event.presentation_proposals.build(:user => current_user)
0
+ raise NotFound unless @event
0
+ @proposal.attributes = params[:presentation_proposal]
0
+ if @proposal.valid?
0
+ @proposal.save
0
       redirect_to event_path(@event)
0
     else
0
- render :action => :new
0
+ render_edit_or_new
0
     end
0
   end
0
+ def destroy
0
+ @event = Event.find_by_tag(params[:event_id])
0
+ raise NotFound unless @event
0
+ proposal = @event.presentation_proposals.find_by_user_id(current_user)
0
+ raise NotFound unless proposal
0
+ proposal.destroy
0
+ redirect_to event_path(@event)
0
+ end
0
+
0
+ private
0
+ def render_edit_or_new
0
+ @proposal.new_record? ? render(:action => :new) : render(:action => :edit)
0
+ end
0
 end
...
1
2
 
3
4
5
 
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
 
 
...
1
2
3
4
 
 
5
6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
7
8
9
0
@@ -1,20 +1,8 @@
0
 - @page_title = "Submit a presentation proposal for #{h(@event.name)}"
0
 
0
+%h2=h @page_title
0
 
0
-- form_for @proposal, :presentation_proposal, :url => event_presentation_proposals_path do |f|
0
-
0
+- form_for @proposal, :presentation_proposal, :url => event_presentation_proposal_path do |f|
0
   = f.error_messages
0
-
0
- %fieldset
0
-
0
- %label{ :for => "presentation_proposal_title" }
0
- %span
0
- Title
0
- = f.text_field :title
0
-
0
- %label{ :for => "presentation_proposal_title" }
0
- %span
0
- Description
0
- = f.text_area :description
0
-
0
- = submit_tag 'Submit', :class => 'submit'
0
\ No newline at end of file
0
+ = render :partial => "form", :locals => {:f => f}
0
+ = submit_tag 'Submit', :class => 'submit'
...
35
36
37
38
 
 
 
 
 
 
39
40
41
...
52
53
54
55
 
56
57
58
...
35
36
37
 
38
39
40
41
42
43
44
45
46
...
57
58
59
 
60
61
62
63
0
@@ -35,7 +35,12 @@
0
     / Proposals
0
     / TODO: If they've submitted a proposal
0
     - if logged_in? && (proposal = current_user.proposal_for(event))
0
- / Don't show nuthin if you've submitted a proposal
0
+ %dt
0
+ = link_to "Present", event_presentation_proposal_path(event), :class => "button rsvp"
0
+ %dd
0
+ %p
0
+ %strong You&rsquo;ve applied to present.
0
+ Edit your presentation proposal.
0
     - elsif event.not.proposals_open?
0
       %dt
0
         %span.button.closed Too late
0
@@ -52,7 +57,7 @@
0
           There&rsquo;s still time.
0
     - else
0
       %dt
0
- = link_to "Present", new_event_presentation_proposal_path(event), :class => "button rsvp"
0
+ = link_to "Present", event_presentation_proposal_path(event), :class => "button rsvp"
0
       %dd
0
         %p
0
           %strong Want to present?
...
25
26
27
28
29
 
 
 
30
31
32
...
25
26
27
 
 
28
29
30
31
32
33
0
@@ -25,8 +25,9 @@ ActionController::Routing::Routes.draw do |map|
0
   map.event_rsvp ":event_id/rsvps/:id", :controller => "rsvps", :action => "destroy", :conditions => { :method => :delete }, :requirements => {:event_id => EVENT_TAG}
0
   
0
   map.with_options(:controller => "presentation_proposals", :requirements => {:event_id => EVENT_TAG}) do |proposals|
0
- proposals.event_presentation_proposals ":event_id/proposals", :action => "create", :conditions => { :method => :post }
0
- proposals.new_event_presentation_proposal ":event_id/proposals/new", :action => "new", :conditions => { :method => :get }
0
+ proposals.event_presentation_proposal ":event_id/proposal", :action => "edit", :conditions => { :method => :get }
0
+ proposals.event_presentation_proposal ":event_id/proposal", :action => "update", :conditions => { :method => :post }
0
+ proposals.event_presentation_proposal ":event_id/proposal", :action => "destroy", :conditions => { :method => :delete }
0
   end
0
   
0
   map.with_options(:controller => "users") do |user|

Comments

    No one has commented yet.