This commit is contained in:
Stella Rouzi 2014-07-22 21:28:42 +00:00
commit ce9950755e
3 changed files with 32 additions and 32 deletions

View file

@ -1,15 +1,15 @@
class EventAttachmentsController < ApplicationController
before_filter :verify_user
skip_before_filter :verify_user, :only => [:show]
skip_before_filter :verify_user, only: [:show]
def index
@proposal = Event.find(params[:proposal_id])
@uploads = @proposal.event_attachments
@uploads = @uploads.map{|upload| upload.to_jq_upload }
@uploads = @uploads.map { |upload| upload.to_jq_upload }
respond_to do |format|
format.html # index.html.erb
format.json { render json: @uploads.to_json}
format.json { render json: @uploads.to_json }
end
end
@ -53,7 +53,7 @@ class EventAttachmentsController < ApplicationController
if !organizer_or_admin?
begin
event = current_user.events.find(params[:proposal_id])
rescue Exception => e
rescue => e
# They certainly aren't allowed to attach a file to someone else's proposal
raise ActionController::RoutingError.new('Invalid proposal')
end
@ -67,14 +67,15 @@ class EventAttachmentsController < ApplicationController
respond_to do |format|
if @upload.save
format.html {
render :json => [@upload.to_jq_upload].to_json,
:content_type => 'text/html',
:layout => false
render json: [@upload.to_jq_upload].to_json,
content_type: 'text/html',
layout: false
}
format.json { render json: [@upload.to_jq_upload].to_json, status: :created,
location: conference_proposal_event_attachment_path(@upload.event.conference.short_title, @upload.event, @upload) }
format.json { render json: { files: [@upload.to_jq_upload] }, status: :created,
location: conference_proposal_event_attachment_path(
@upload.event.conference.short_title, @upload.event, @upload) }
else
format.html { render action: "new" }
format.html { render action: 'new' }
format.json { render json: @upload.errors, status: :unprocessable_entity }
end
end
@ -89,7 +90,7 @@ class EventAttachmentsController < ApplicationController
format.html { redirect_to @upload, notice: 'Upload was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
format.html { render action: 'edit' }
format.json { render json: @upload.errors, status: :unprocessable_entity }
end
end
@ -97,16 +98,17 @@ class EventAttachmentsController < ApplicationController
def destroy
@proposal = Event.find(params[:proposal_id])
if organizer_or_admin? || current_user == @proposal.submitter
@upload = @proposal.event_attachments.find(params[:id])
end
@upload.destroy if !@upload.nil?
respond_to do |format|
format.html { redirect_back_or_to conference_proposal_index_path(@conference.short_title), :notice => "Deleted successfully attachment '#{@upload.title}' for proposal '#{@proposal.title}'" }
format.html { redirect_back_or_to conference_proposal_index_path(@conference.short_title),
notice: "Deleted successfully attachment '#{@upload.title}' for proposal '#{@proposal.title}'" }
format.json { head :no_content }
end