mirror of
https://github.com/ENSL/ensl.org.git
synced 2025-05-31 17:00:49 +00:00
Purged git history and removed sensitive information.
This commit is contained in:
commit
6bcc8dc76b
862 changed files with 25312 additions and 0 deletions
56
app/controllers/polls_controller.rb
Normal file
56
app/controllers/polls_controller.rb
Normal file
|
@ -0,0 +1,56 @@
|
|||
class PollsController < ApplicationController
|
||||
before_filter :get_poll, :except => [:index, :new, :create]
|
||||
|
||||
def index
|
||||
@polls = Poll.all
|
||||
end
|
||||
|
||||
def show
|
||||
end
|
||||
|
||||
def new
|
||||
@poll = Poll.new
|
||||
@poll.options.build
|
||||
raise AccessError unless @poll.can_create? cuser
|
||||
end
|
||||
|
||||
def edit
|
||||
raise AccessError unless @poll.can_update? cuser
|
||||
end
|
||||
|
||||
def create
|
||||
@poll = Poll.new params[:poll]
|
||||
@poll.user = cuser
|
||||
raise AccessError unless @poll.can_create? cuser
|
||||
|
||||
if @poll.save
|
||||
flash[:notice] = t(:polls_create)
|
||||
redirect_to @poll
|
||||
else
|
||||
render :action => "new"
|
||||
end
|
||||
end
|
||||
|
||||
def update
|
||||
raise AccessError unless @poll.can_update? cuser
|
||||
|
||||
if @poll.update_attributes params[:poll]
|
||||
flash[:notice] = t(:polls_update)
|
||||
redirect_to @poll
|
||||
else
|
||||
render :action => "edit"
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
raise AccessError unless @poll.can_destroy? cuser
|
||||
@poll.destroy
|
||||
redirect_to polls_url
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def get_poll
|
||||
@poll = Poll.find params[:id]
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue