Skip to content

Commit

Permalink
Refactor. [#64]
Browse files Browse the repository at this point in the history
  • Loading branch information
marnen committed Dec 29, 2011
1 parent 0c8b8d5 commit dbc0e00
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions app/controllers/events_controller.rb
Expand Up @@ -37,7 +37,7 @@ def create
end

def edit
@event = Event.find params[:id]
load_event
if @event.allow? :edit
@page_title = _("Edit event")
respond_with @event
Expand All @@ -47,12 +47,12 @@ def edit
end

def update
@event = Event.find params[:id]
load_event
respond_with_flash { @event.update_attributes params[:event] }
end

def show
@event = Event.find params[:id]
load_event
if @event.allow? :show
@page_title = @event.name
respond_with @event
Expand All @@ -74,7 +74,7 @@ def feed

# Delete an #Event, subject to #Event#allow?.
def delete
event = Event.find(params[:id].to_i)
load_event
begin
if event.allow?(:delete)
event.hide
Expand Down Expand Up @@ -117,7 +117,7 @@ def change_status
# Display a map page for the current #Event.
def map
begin
@event = Event.find(params[:id])
load_event
@host = request.host_with_port
rescue
flash[:error] = _("Couldn't find that event!")
Expand Down Expand Up @@ -164,6 +164,10 @@ def ical_header
headers['Content-Type'] = 'text/calendar'
end

def load_event
@event = Event.find params[:id]
end

# Log user in based on single_access_token.
def login_from_key
params[:feed_user] = User.find_by_single_access_token(params[:key])
Expand Down

0 comments on commit dbc0e00

Please sign in to comment.