Skip to content
This repository was archived by the owner on Jan 5, 2024. It is now read-only.

Commit e226642

Browse files
author
caleb
committed
Made events/new and events/update location creation/editing
more betterer with some magical javscript. Removed this task from the TODO list. Also removed an old item I don't care about anymore (index caching), and moved another item to the IDEAS file. git-svn-id: http://svn.pdxruby.org/repos/www/trunk@209 f0fbaf97-c700-0410-a5eb-8ea856f8537e
1 parent f39449e commit e226642

File tree

6 files changed

+51
-30
lines changed

6 files changed

+51
-30
lines changed

app/controllers/events_controller.rb

+22-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ def index
77
render :action => 'list'
88
end
99

10+
def add_location
11+
render :layout => false
12+
end
13+
1014
def list
1115
@event_pages, @events = paginate :event, :per_page => 10, :order_by => 'starts_at DESC'
1216
end
@@ -36,7 +40,7 @@ def new
3640
def create
3741
@event = Event.new(params[:event])
3842
@event.member = session[:member]
39-
if params[:event][:location_id] == ""
43+
if params[:event][:location_id].nil?
4044
location = Location.find_by_name(params[:location][:name])
4145
if location.nil?
4246
location = Location.new(params[:location])
@@ -82,6 +86,23 @@ def update
8286
redirect_to :action => 'list'
8387
return
8488
end
89+
90+
# deal with updates to location
91+
if params[:event][:location_id].nil?
92+
location = Location.find_by_name(params[:location][:name])
93+
if location.nil?
94+
location = Location.new(params[:location])
95+
unless location.save
96+
@location = location
97+
render :action => 'new' and return
98+
end
99+
end
100+
@location = location
101+
else
102+
@location = Location.find(params[:event][:location_id].to_i)
103+
end
104+
@event.location = @location
105+
85106
if @event.update_attributes(params[:event])
86107
flash[:notice] = 'Event was successfully updated.'
87108
MailBot::deliver_change_message(self, @event) if params[:trivial].nil?

app/views/events/_form.rhtml

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
<%= error_messages_for 'event' %>
2+
<%= error_messages_for 'location' %>
23

34
<!--[form:event]-->
45
<p><label for="event_name">Name</label><br/>
56
<%= text_field 'event', 'name' %></p>
67

7-
<p><label for="location_id">Location (leave blank for other)</label><br/>
8-
<%= collection_select 'event', 'location_id', Location.find(:all), :id, :name, {:include_blank => true } %>
9-
10-
<%= render :partial => "locations/form" %>
8+
<div id="location_select">
9+
<p><label for="location_id">Location (leave blank for other)</label><br />
10+
<%= collection_select 'event', 'location_id', Location.find(:all), :id, :name %>
11+
<%= link_to_remote "Add New", :update => 'location_select', :url => { :action => "add_location" } %>
12+
</div>
1113

1214
<p><label for="event_starts_at">Starts at</label><br/>
1315
<%= datetime_select 'event', 'starts_at' %></p>

app/views/events/add_location.rhtml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!--[form:location]-->
2+
<p><label for="location_name">Location Name</label><br/>
3+
<%= text_field 'location', 'name' %></p>
4+
5+
<p><label for="location_address">Location Address</label><br/>
6+
<%= text_area 'location', 'address' %></p>
7+
8+
<p><label for="location_homepage">Location Homepage</label><br/>
9+
<%= text_field 'location', 'homepage' %></p>
10+
11+
<!--[eoform:location]-->

app/views/layouts/application.rhtml

+3-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,9 @@
66
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
77
<meta http-equiv="Content-Language" content="en-us">
88
<meta name="copyright" content="(c) Copyright 2005 John Labovitz">
9-
<%= stylesheet_link_tag 'stylesheet' %>
10-
<%= stylesheet_link_tag 'scaffold' %>
9+
<%= stylesheet_link_tag 'stylesheet' %>
10+
<%= stylesheet_link_tag 'scaffold' %>
11+
<%= javascript_include_tag 'prototype' %>
1112
<title>The Portland Ruby Brigade (PDX.rb)</title>
1213
</head>
1314

doc/IDEAS

+9
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,15 @@ _Community Stuff_
2020

2121
- poll for event location (suggested by bleything on the dev list)
2222

23+
- It would be nice if the feeds could be moderated by people. If one
24+
person posts a bunch of off-topic entries, then the last 5 isn't very
25+
Ruby-based. Currently, a user can delete his or her own articles, which is probably
26+
good-enough for a little while.
27+
- Perhaps a field should be added to the articles relation
28+
that contains the number of 'nay' votes. When some threshold
29+
is reached, the article is not shown (but not deleted - if
30+
it were, the feeder would just grab it again next run)
31+
2332
_UI Stuff_
2433

2534
- "calender view" for events, perhaps week-at-a-time too

doc/TODO

-23
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,6 @@ _Spamming_
1313

1414
_Other_
1515

16-
- Bug in location view code when editing an event. Prevented me from
17-
adding minutes for the April Monthly. The whole location part of the
18-
event form really needs some TLC. If nothing else, it is confusing.
19-
(we can't make this happen in the latest code, so it may not be a bug anymore)
20-
21-
- Cache index page. How should this be done? Periodically or when some set of DB modifications
22-
occurs (i.e. when scripts/feeder runs, and when an event is added or deleted or modified). Ideally
23-
the index should be able to handle a slashdotting.
24-
2516
- User should be able to delete their own account...
2617

2718
- Validation for Article, plus tests to match.
@@ -31,9 +22,6 @@ _Other_
3122

3223
_Cosmetic_
3324

34-
- on Edit/New Event, when existing location is selected, alternative location
35-
inputs can be greyed-out or dissapeared (via some Javascript magic).
36-
3725
- Make timestamps prettier (this and following 2 items suggested by bleything on dev-list)
3826

3927
- Article list enhancements (sort by author, etc.)
@@ -47,14 +35,3 @@ _Testing_
4735
- write functional tests for index_controller.rb
4836
- write functional tests for locations_controller.rb
4937
- write functional tests for participants_controller.rb
50-
51-
_Feeds_
52-
53-
- It would be nice if the feeds could be moderated by people. If one
54-
person posts a bunch of off-topic entries, then the last 5 isn't very
55-
Ruby-based. Currently, a user can delete his or her own articles, which is probably
56-
good-enough for a little while.
57-
- Perhaps a field should be added to the articles relation
58-
that contains the number of 'nay' votes. When some threshold
59-
is reached, the article is not shown (but not deleted - if
60-
it were, the feeder would just grab it again next run)

0 commit comments

Comments
 (0)