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
commit 8ec0070e6d
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] skip_before_filter :verify_user, :only => [:show]
def index def index
@proposal = current_user.person.events.find(params[:proposal_id]) @proposal = Event.find(params[:proposal_id])
@uploads = @proposal.event_attachments @uploads = @proposal.event_attachments
@uploads = @uploads.map{|upload| upload.to_jq_upload }
respond_to do |format| respond_to do |format|
format.html # index.html.erb 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
end end
@ -95,10 +96,9 @@ class EventAttachmentsController < ApplicationController
end end
def destroy def destroy
if organizer_or_admin? @proposal = Event.find(params[:proposal_id])
@upload = Upload.find(params[:id])
else if organizer_or_admin? || current_user.person == @proposal.submitter
@proposal = current_user.person.events.find(params[:proposal_id])
@upload = @proposal.event_attachments.find(params[:id]) @upload = @proposal.event_attachments.find(params[:id])
end end
@ -106,7 +106,8 @@ class EventAttachmentsController < ApplicationController
respond_to do |format| 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 } format.json { head :no_content }
end end
end end

View file

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