diff --git a/Gemfile b/Gemfile index 83f5395c..2509b74f 100644 --- a/Gemfile +++ b/Gemfile @@ -51,7 +51,6 @@ gem 'bootstrap3-datetimepicker-rails', '~> 3.0.2' # Use jquery as the JavaScript library gem 'jquery-rails' -gem 'jquery-fileupload-rails' gem 'cocoon' # Use gravtastic for user avatars diff --git a/Gemfile.lock b/Gemfile.lock index f4a3d54f..4f4f441c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -164,9 +164,6 @@ GEM i18n (0.6.11) inversion (0.12.3) loggability (~> 0.4) - jquery-fileupload-rails (0.4.1) - actionpack (>= 3.1) - railties (>= 3.1) jquery-rails (3.1.0) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) @@ -431,7 +428,6 @@ DEPENDENCIES guard-rspec (~> 4.2.8) haml-rails hoptoad_notifier (~> 2.3) - jquery-fileupload-rails jquery-rails letter_opener mina diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 24cbfee5..a1d9df0b 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -12,7 +12,6 @@ // //= require jquery //= require jquery_ujs -//= require jquery-fileupload //= require jquery.dataTables //= require cocoon //= require bootstrap diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index dfc33e56..585394ab 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -1,7 +1,6 @@ /* *= require strap-on *= require formtastic-bootstrap - *= require jquery.fileupload-ui *= require jquery.dataTables_themeroller *= require osem *= require osem-rating diff --git a/app/controllers/event_attachments_controller.rb b/app/controllers/event_attachments_controller.rb deleted file mode 100644 index f58e4989..00000000 --- a/app/controllers/event_attachments_controller.rb +++ /dev/null @@ -1,110 +0,0 @@ -class EventAttachmentsController < ApplicationController - load_and_authorize_resource :conference, find_by: :short_title - load_and_authorize_resource :proposal, class: Event - load_and_authorize_resource :upload, class: EventAttachment, through: :proposal - before_filter :verify_user - skip_before_filter :verify_user, only: [:show] - - def index - @uploads = @proposal.event_attachments - @uploads = @uploads.map{|upload| upload.to_jq_upload } - - respond_to do |format| - format.html # index.html.erb - format.json { render json: @uploads.to_json} - end - end - - def show - if @upload.public? - send_file @upload.attachment.path - return - end - - if current_user.nil? - verify_user - return - end - - if organizer_or_admin? || current_user == upload.event.submitter - send_file @upload.attachment.path - else - raise ActionController::RoutingError.new('Not Found') - end - end - - def new - @upload = EventAttachment.new - - respond_to do |format| - format.html # new.html.erb - format.json { render json: @upload } - end - end - - def edit; end - - def create - params[:event_attachment][:title] = params[:title][0] - params[:event_attachment][:public] = false - params[:event_attachment][:event_id] = params[:proposal_id] - - if cannot? :create, EventAttachment - begin - current_user.events.find(params[:proposal_id]) - rescue - # They certainly aren't allowed to attach a file to someone else's proposal - raise ActionController::RoutingError.new('Invalid proposal') - end - end - - if params.has_key?(:public) - params[:event_attachment][:public] = true - end - @upload = EventAttachment.new(params[:event_attachment]) - - respond_to do |format| - if @upload.save - format.html do - render json: [@upload.to_jq_upload].to_json, - content_type: 'text/html', - layout: false - end - format.json do - render json: [@upload.to_jq_upload].to_json, status: :created, - location: conference_proposal_event_attachment_path(@upload.event.conference.short_title, @upload.event, @upload) - end - else - format.html { render action: "new" } - format.json { render json: @upload.errors, status: :unprocessable_entity } - end - end - end - - def update - respond_to do |format| - if @upload.update_attributes(params[:upload]) - format.html { redirect_to @upload, notice: 'Upload was successfully updated.' } - format.json { head :no_content } - else - format.html { render action: "edit" } - format.json { render json: @upload.errors, status: :unprocessable_entity } - end - end - end - - def destroy - if can? :destroy, @proposal - @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.json { head :no_content } - end - end -end diff --git a/app/controllers/proposal_controller.rb b/app/controllers/proposal_controller.rb index 31c8299b..8c097a50 100644 --- a/app/controllers/proposal_controller.rb +++ b/app/controllers/proposal_controller.rb @@ -19,7 +19,6 @@ class ProposalController < ApplicationController def edit authorize! :edit, @event @url = conference_proposal_path(@conference.short_title, params[:id]) - @attachments = @event.event_attachments end def create diff --git a/app/models/ability.rb b/app/models/ability.rb index e0395047..559c46c3 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -140,10 +140,5 @@ class Ability can :manage, Commercial, commercialable_type: 'Event', commercialable_id: user.events.pluck(:id) # View commercials of confirmed events can :show, Commercial, commercialable_type: 'Event', commercialable_id: Event.where(state: 'confirmed').pluck(:id) - - can :manage, EventAttachment do |ea| - Event.find(ea.event_id).event_users.where(user_id: user.id).present? - end - can :create, EventAttachment end end diff --git a/app/models/event_attachment.rb b/app/models/event_attachment.rb deleted file mode 100644 index 41915248..00000000 --- a/app/models/event_attachment.rb +++ /dev/null @@ -1,26 +0,0 @@ -class EventAttachment < ActiveRecord::Base - has_paper_trail - - 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" - include Rails.application.routes.url_helpers - - 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" - } - 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"} -end diff --git a/app/views/admin/events/_proposal.html.haml b/app/views/admin/events/_proposal.html.haml index 2a1131ce..239b6852 100644 --- a/app/views/admin/events/_proposal.html.haml +++ b/app/views/admin/events/_proposal.html.haml @@ -110,36 +110,6 @@ - if @conference.call_for_papers && @conference.call_for_papers.rating && @conference.call_for_papers.rating > 0 = render :partial => "voting" - - if @event.event_attachments.size > 0 - %table.table - %thead - %th - %b Filename - %th - %b Title - %th - %b Size - %th - %b Public? - %th - %tbody - - @event.event_attachments.each do |a| - %tr - %td - = link_to a.attachment_file_name, conference_proposal_event_attachment_path(@conference.short_title, @event.id, a.id) - %td - = a.title - %td - = number_to_human_size a.attachment_file_size - %td - - if a.public? - Public - - else - Not Public - %td - = link_to "Delete", conference_proposal_event_attachment_path(@conference.short_title, @event.id, a.id), - :method => :delete, :confirm => "Are you sure you want to delete this attachment? It's permanant!" - .row = link_to "Comments (#{@comment_count})", "#", :id => "event-comment-link" #comments-div @@ -153,4 +123,4 @@ %br - @comments.each do |comment| %div - = raw format_comments(comment) \ No newline at end of file + = raw format_comments(comment) diff --git a/app/views/proposal/_form.html.haml b/app/views/proposal/_form.html.haml index 3eb85510..16f9384b 100644 --- a/app/views/proposal/_form.html.haml +++ b/app/views/proposal/_form.html.haml @@ -6,8 +6,6 @@ = link_to "Proposal", "#proposal-content", "data-toggle"=>"tab" %li = link_to 'Commercials', '#commercials-content', 'data-toggle'=>'tab' - %li - = link_to "Attachments", "#attachment-content", "data-toggle"=>"tab" .tab-content #proposal-content.tab-pane.active = render 'proposal/proposal_form' @@ -34,114 +32,3 @@ - if can? :create, @event.commercials.new %hr = link_to 'Add Commercial', new_conference_proposal_commercial_path(@conference.short_title, @event.id), class: 'btn btn-primary' - - #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| - %table.table.table-striped - %thead - %th - %th - %b Filename - %th - %b Title - %th - %b Size - %th - %b Public - %th - %th - %tbody.files - - - .row-fluid.fileupload-buttonbar - .btn.btn-success.fileinput-button - %span.fa.fa-plus - Add files... - = f.file_field :attachment - = f.hidden_field :event_id, :value => @event.id - -:javascript - $(document).ready( function() { - $('#fileupload').fileupload(); - $('#fileupload').bind('fileuploadsubmit', function (e, data) { - var inputs = data.context.find(':input'); - if (inputs.filter('[required][value=""]').first().focus().length) { - return false; - } - data.formData = inputs.serializeArray(); - }); - $.getJSON($('#fileupload').prop('action'), function (files) { - var fu = $('#fileupload').data('fileupload'), - template; - fu._adjustMaxNumberOfFiles(-files.length); - template = fu._renderDownload(files) - .appendTo($('#fileupload .files')); - fu._reflow = fu._transition && template.length && - template[0].offsetWidth; - template.addClass('in'); - $('#loading').remove(); - }); - - } ); - -:plain - - -