Skip to content

Commit f3e702a

Browse files
committed
fix image/file upload section in eportfolios, fixes #3756
It looks like at some point we switched from an "upload" to an "attachment" section type, which broke this Change-Id: I49f1a45ad5b39acd00376504962b9841264d4bd0 Reviewed-on: https://gerrit.instructure.com/2227 Tested-by: Hudson <hudson@instructure.com> Reviewed-by: Brian Whitmer <brian@instructure.com>
1 parent 4a96bd6 commit f3e702a

6 files changed

Lines changed: 16 additions & 13 deletions

File tree

app/models/eportfolio_entry.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def full_slug
7474
def attachments
7575
res = []
7676
content_sections.each do |section|
77-
res << (self.eportfolio.user.all_attachments.find_by_uuid(section["attachment_id"]) rescue nil) if section["section_type"] == "upload"
77+
res << (self.eportfolio.user.all_attachments.find_by_id(section["attachment_id"]) rescue nil) if section["section_type"] == "attachment"
7878
end
7979
res.compact
8080
end

app/stylesheets/instructure_eportfolio.sass

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,15 @@ ul.submission_list.instTree li.submission.leaf
141141

142142
#page_content
143143
.section
144-
.upload
144+
.attachment
145145
:font-size 1.1em
146146

147147
.filename
148148
:font-weight bold
149149
:text-decoration underline
150+
151+
img
152+
:max-width 100%
150153

151154
.file_list
152155
:text-align left

app/views/eportfolios/_page_section.html.erb

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
HTML/Embedded Content
88
<% elsif page_section["section_type"] == "submission" %>
99
Course Submission
10-
<% elsif page_section["section_type"] == "upload" %>
10+
<% elsif page_section["section_type"] == "attachment" %>
1111
Image/File Upload
1212
<% end %>
1313
</div>
@@ -18,9 +18,9 @@
1818
<% if page_section %>
1919
<% if !page_section["section_type"] || page_section["section_type"] == "rich_text" || page_section["section_type"] == "html" %>
2020
<%= raw(page_section["content"] || "Nothing Entered Yet") %>
21-
<% elsif page_section["section_type"] == "upload" %>
22-
<div style="text-align: center;" class="upload">
23-
<% attachment = @attachments.find{|a| a.uuid == page_section["attachment_id"]} %>
21+
<% elsif page_section["section_type"] == "attachment" %>
22+
<div style="text-align: center;" class="attachment">
23+
<% attachment = @portfolio.user.attachments.find(page_section["attachment_id"]) %>
2424
<% if attachment && attachment.content_type.match(/\Aimage/) %>
2525
<a href="<%= eportfolio_entry_view_file_path(@portfolio, @page, attachment.uuid) %>" class="no-hover"><%= image_tag eportfolio_entry_view_file_path(@portfolio, @page, attachment.uuid) %></a>
2626
<% elsif attachment %>

app/views/eportfolios/_page_section_static.html.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
<div class="section_content">
55
<% if !page_section["section_type"] || page_section["section_type"] == "rich_text" || page_section["section_type"] == "html" %>
66
<%= page_section["content"] || "Nothing Entered Yet" %>
7-
<% elsif page_section["section_type"] == "upload" %>
8-
<div style="text-align: center;" class="upload">
7+
<% elsif page_section["section_type"] == "attachment" %>
8+
<div style="text-align: center;" class="attachment">
99
<% attachment = @static_attachments.find{|a| a.uuid == page_section["attachment_id"]} %>
1010
<% if attachment && attachment.content_type.match(/\Aimage/) %>
1111
<a href="<%= attachment.filename %>"><img src="<%= attachment.filename %>" alt="<%= attachment.filename %>"/></a>

public/javascripts/eportfolio.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,7 @@
304304
var id = data.id;
305305
var uuid = $("#file_uuid_" + id).text();
306306
var name = data.name;
307-
$section.find(".attachment_id").text(uuid);
307+
$section.find(".attachment_id").text(id);
308308
var url = $(".eportfolio_download_url").attr('href');
309309
url = $.replaceTags(url, 'uuid', uuid);
310310
if($file.hasClass('image')) {
@@ -334,7 +334,7 @@
334334
success: function(data) {
335335
var $section = $(this).data('section');
336336
var attachment = data.attachment;
337-
$section.find(".attachment_id").text(attachment.uuid);
337+
$section.find(".attachment_id").text(attachment.id);
338338
var url = $(".eportfolio_download_url").attr('href');
339339
url = $.replaceTags(url, 'uuid', attachment.uuid);
340340
if(attachment.content_type.indexOf("image") != -1) {

public/stylesheets/static/eportfolio_static.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ img {
211211

212212
#page_content .section .upload {
213213
font-size: 1.1em; }
214-
#page_content .section .upload .filename {
215-
font-weight: bold;
216-
text-decoration: underline; }
214+
#page_content .section .upload .filename {
215+
font-weight: bold;
216+
text-decoration: underline; }
217217
#page_content .section .file_list {
218218
text-align: left; }
219219
#page_content .section .file_list .instTree .leaf.active {

0 commit comments

Comments
 (0)