mirror of
https://github.com/reddit-archive/reddit.git
synced 2026-01-26 23:39:11 -05:00
Fix error reporting for app icon uploads.
This commit is contained in:
@@ -2939,10 +2939,6 @@ class ApiController(RedditController, OAuth2ResourceController):
|
||||
docs=dict(file=_("an icon (72x72)"))))
|
||||
@api_doc(api_section.apps)
|
||||
def POST_setappicon(self, form, jquery, client, icon_file):
|
||||
if client:
|
||||
form_id = 'app-icon-upload-%s' % client._id
|
||||
else:
|
||||
form_id = None
|
||||
if not media.can_upload_icon():
|
||||
form.set_error(errors.NOT_SUPPORTED, '')
|
||||
if not icon_file:
|
||||
|
||||
@@ -768,7 +768,8 @@ class MinimalController(BaseController):
|
||||
c.response_content_type = 'text/html'
|
||||
c.response.content = (
|
||||
'<html><head><script type="text/javascript">\n'
|
||||
'parent.$.handleResponse().call(parent.$(window.frameElement.id).parent(), %s)\n'
|
||||
'parent.$.handleResponse().call('
|
||||
'parent.$("#" + window.frameElement.id).parent(), %s)\n'
|
||||
'</script></head></html>') % filters.websafe_json(data)
|
||||
return c.response
|
||||
|
||||
|
||||
@@ -124,6 +124,7 @@ function post_pseudo_form(form, where, block) {
|
||||
}
|
||||
|
||||
function post_multipart_form(form, where) {
|
||||
$(form).find(".error").not(".status").hide();
|
||||
$(form).find(".status").html(reddit.status_msg.submitting).show();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -271,16 +271,29 @@ ${unsafe(txt)}
|
||||
<form method="post" enctype="multipart/form-data" target="${form_id}-iframe"
|
||||
id="${form_id}" class="ajax-upload-form pretty-form" action="${target}"
|
||||
onsubmit="return post_multipart_form(this, '${target}')">
|
||||
<input type="hidden" name="id" value="${form_id}" />
|
||||
<input type="hidden" name="id" value="#${form_id}" />
|
||||
<input type="hidden" name="uh" value="${c.modhash}" />
|
||||
<input type="file" name="file" />
|
||||
<button type="submit">
|
||||
${_('upload')}
|
||||
</button>
|
||||
${error_field('IMAGE_ERROR', '')}
|
||||
%if caller:
|
||||
${caller.body()}
|
||||
%endif
|
||||
<span class="status"></span>
|
||||
<script type="text/javascript">
|
||||
function completedUploadImage (status, img_src, name, errors, form_id) {
|
||||
/* should only be called when the uploaded file is too large */
|
||||
if (status == "failed") {
|
||||
$("#${form_id}").find(".status").html("");
|
||||
for (var i in errors) {
|
||||
$("#${form_id}").find(".error." + errors[i][0])
|
||||
.show().text(errors[i][1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
<iframe src="about:blank" name="${form_id}-iframe" id="${form_id}-iframe">
|
||||
</iframe>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user