Merge pull request #65 from differentreality/attachments_final

fix controller (find and json output). Now attachments get listed (no pr...
This commit is contained in:
Henne Vogelsang
2014-04-23 15:04:43 +02:00
2 changed files with 19 additions and 17 deletions

View File

@@ -3,12 +3,13 @@ class EventAttachmentsController < ApplicationController
skip_before_filter :verify_user, :only => [:show]
def index
@proposal = current_user.person.events.find(params[:proposal_id])
@proposal = Event.find(params[:proposal_id])
@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.map{|upload| upload.to_jq_upload } }
format.json { render json: @uploads.to_json}
end
end
@@ -95,18 +96,18 @@ class EventAttachmentsController < ApplicationController
end
def destroy
if organizer_or_admin?
@upload = Upload.find(params[:id])
else
@proposal = current_user.person.events.find(params[:proposal_id])
@proposal = Event.find(params[:proposal_id])
if organizer_or_admin? || current_user.person == @proposal.submitter
@upload = @proposal.event_attachments.find(params[:id])
end
@upload.destroy if !@upload.nil?
respond_to do |format|
format.html { redirect_to uploads_url }
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

View File

@@ -23,7 +23,10 @@
%th
%b Public
%th
%th
%tbody.files
.row-fluid.fileupload-buttonbar
.btn.btn-success.fileinput-button
%span.glyphicon.glyphicon-icon-plus.icon-white
@@ -60,16 +63,15 @@
{% for (var i=0, file; file=o.files[i]; i++) { %}
<tr class="template-upload fade">
<td class="preview"><span class="fade"></span></td>
<td class="name"><span>{%=file.name%}</span></td>
<td class="name"><span>{%=file.name%}</span>
<div class="progress progress-success progress-striped active"><div class="bar" style="width:0%;"></div></div>
</td>
<td class="name"><input type="text" name="title[]" value="{%=file.name%}"/></td>
<td class="size"><span>{%=o.formatFileSize(file.size)%}</span></td>
<td class="name"><input checked type="checkbox" name="public">Public</input></td>
{% if (file.error) { %}
<td class="error" colspan="2"><span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}</td>
<td class="error"><span class="label label-important">{%=locale.fileupload.error%}</span> {%=locale.fileupload.errors[file.error] || file.error%}</td>
{% } else if (o.files.valid && !i) { %}
<td>
<div class="progress progress-success progress-striped active"><div class="bar" style="width:0%;"></div></div>
</td>
<td class="start">{% if (!o.options.autoUpload) { %}
<button class="btn btn-primary">
<span class="glyphicon glyphicon-upload"></span>
@@ -77,7 +79,7 @@
</button>
{% } %}</td>
{% } else { %}
<td colspan="2"></td>
<td></td>
{% } %}
<td class="cancel">{% if (!i) { %}
<button class="btn btn-warning">
@@ -107,9 +109,8 @@
<td>{%=file.title%}</td>
<td class="size">{%=o.formatFileSize(file.size)%}</td>
<td>{%=file.public%}</td>
<td colspan="2"></td>
{% } %}
<td class="delete">
<td class="delete" colspan="2">
<button class="btn btn-danger pull-right" data-type="{%=file.delete_type%}" data-url="{%=file.delete_url%}">
<span class="glyphicon glyphicon-trash"></i>
<span>{%=locale.fileupload.destroy%}</span>