style fixes
This commit is contained in:
parent
1d4ec06bac
commit
48b9b49655
3 changed files with 27 additions and 28 deletions
|
|
@ -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: {files: [@upload.to_jq_upload]}, 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
|
||||
|
|
@ -106,7 +107,8 @@ class EventAttachmentsController < ApplicationController
|
|||
|
||||
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
|
||||
|
|
|
|||
|
|
@ -4,27 +4,24 @@ class EventAttachment < ActiveRecord::Base
|
|||
belongs_to :event
|
||||
attr_accessible :public, :attachment, :event_id, :title
|
||||
|
||||
has_attached_file :attachment, :path => ":rails_root/storage/:rails_env/attachments/:id/:style/:basename.:extension"
|
||||
has_attached_file :attachment, path: ':rails_root/storage/:rails_env/attachments/:id/:style/:basename.:extension'
|
||||
include Rails.application.routes.url_helpers
|
||||
do_not_validate_attachment_file_type :attachment
|
||||
|
||||
def to_jq_upload
|
||||
{
|
||||
"name" => read_attribute(:attachment_file_name),
|
||||
"size" => read_attribute(:attachment_file_size),
|
||||
"title" => read_attribute(:title),
|
||||
"public" => read_attribute(:public),
|
||||
#"url" => attachment.url(:original),
|
||||
"url" => conference_proposal_event_attachment_path(self.event.conference.short_title, self.event_id, self.id),
|
||||
"delete_url" => conference_proposal_event_attachment_path(self.event.conference.short_title, self.event_id, self.id),
|
||||
"delete_type" => "DELETE"
|
||||
'name' => read_attribute(:attachment_file_name),
|
||||
'size' => read_attribute(:attachment_file_size),
|
||||
'title' => read_attribute(:title),
|
||||
'public' => read_attribute(:public),
|
||||
# "url" => attachment.url(:original),
|
||||
'url' => conference_proposal_event_attachment_path(event.conference.short_title, event_id, id),
|
||||
'delete_url' => conference_proposal_event_attachment_path(event.conference.short_title, event_id, id),
|
||||
'delete_type' => 'DELETE'
|
||||
}
|
||||
|
||||
end
|
||||
#:path => ":rails_root/public/system/:attachment/:id/:style/:filename",
|
||||
# :url => "/system/:attachment/:id/:style/:filename"
|
||||
|
||||
#has_paper_trail :meta => {:associated_id => :event_id, :associated_type => "Event"}
|
||||
|
||||
|
||||
# has_paper_trail :meta => {:associated_id => :event_id, :associated_type => "Event"}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,14 +3,14 @@
|
|||
.tabbable
|
||||
%ul.nav.nav-tabs
|
||||
%li.active
|
||||
= link_to "Proposal", "#proposal-content", "data-toggle"=>"tab"
|
||||
= link_to 'Proposal', '#proposal-content', 'data-toggle'=>'tab'
|
||||
%li
|
||||
= link_to "Attachments", "#attachment-content", "data-toggle"=>"tab"
|
||||
= link_to 'Attachments', '#attachment-content', 'data-toggle'=>'tab'
|
||||
.tab-content
|
||||
#proposal-content.tab-pane.active
|
||||
= render 'proposal/proposal_form'
|
||||
#attachment-content.tab-pane
|
||||
= form_for EventAttachment.new, :url => conference_proposal_event_attachment_index_path(@conference.short_title, @event), :html => { :multipart => true, :id => "fileupload" } do |f|
|
||||
= form_for EventAttachment.new, url: conference_proposal_event_attachment_index_path(@conference.short_title, @event), html: { multipart: true, id: 'fileupload' } do |f|
|
||||
%table.table.table-striped
|
||||
%thead
|
||||
%th
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue