Fixed image resizing

This commit is contained in:
Fergal Moran
2013-09-26 21:07:47 +01:00
parent a85adbfe1d
commit aff49a5dc4
7 changed files with 22 additions and 47 deletions

View File

@@ -15,7 +15,7 @@ from dss import settings
from spa.models._basemodel import _BaseModel
from templated_email import send_templated_mail
from sorl import thumbnail
from sorl.thumbnail.helpers import ThumbnailError
logger = logging.getLogger(__name__)
@@ -160,14 +160,18 @@ class UserProfile(_BaseModel):
def get_small_profile_image(self):
try:
image = self.get_avatar_image()
if self.avatar_type == 'custom':
image = self.avatar_image
image = "%s%s" % (settings.MEDIA_URL, get_thumbnail(image, "32x32", crop='center').name)
return image
return image
except SuspiciousOperation, ex:
self.logger.warn("Error getting small profile image: %s", ex.message)
self.logger.error("Error getting small profile image: %s", ex.message)
except IOError, ex:
self.logger.warn("Error getting small profile image: %s", ex.message)
self.logger.error("Error getting small profile image: %s", ex.message)
except ThumbnailError:
pass
return self.get_avatar_image()
def get_sized_avatar_image(self, width, height):
try:

View File

@@ -406,7 +406,7 @@ div.event-content td {
.mix-image-container img {
max-width: 100%;
max-height: 100%;
height: autoE;
}
.btn.loading {

View File

@@ -1,6 +1,6 @@
define ['app.lib/editableView', 'moment', 'utils', 'backbone.syphon', 'text!/tpl/MixEditView'
'jquery.fileupload', 'jquery.fileupload-process', 'jquery.fileupload-audio', 'jquery.fileupload-ui',
'jquery.iframe-transport', 'jquery.ui.widget',
'jquery.iframe-transport', 'jquery.ui.widget', 'lib/bootstrap-fileupload',
'lib/select2', 'lib/ajaxfileupload', 'ace', 'lib/bootstrap-tag.min'],
(EditableView, moment, utils, Syphon, Template) ->
class MixEditView extends EditableView

View File

@@ -1,18 +1,18 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.3.3
(function() {
var __bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
define(['app.lib/editableView', 'moment', 'utils', 'backbone.syphon', 'text!/tpl/MixEditView', 'jquery.fileupload', 'jquery.fileupload-process', 'jquery.fileupload-audio', 'jquery.fileupload-ui', 'jquery.iframe-transport', 'jquery.ui.widget', 'lib/select2', 'lib/ajaxfileupload', 'ace', 'lib/bootstrap-tag.min'], function(EditableView, moment, utils, Syphon, Template) {
var MixEditView, _ref;
define(['app.lib/editableView', 'moment', 'utils', 'backbone.syphon', 'text!/tpl/MixEditView', 'jquery.fileupload', 'jquery.fileupload-process', 'jquery.fileupload-audio', 'jquery.fileupload-ui', 'jquery.iframe-transport', 'jquery.ui.widget', 'lib/bootstrap-fileupload', 'lib/select2', 'lib/ajaxfileupload', 'ace', 'lib/bootstrap-tag.min'], function(EditableView, moment, utils, Syphon, Template) {
var MixEditView;
return MixEditView = (function(_super) {
__extends(MixEditView, _super);
function MixEditView() {
this.saveChanges = __bind(this.saveChanges, this); _ref = MixEditView.__super__.constructor.apply(this, arguments);
return _ref;
this.saveChanges = __bind(this.saveChanges, this);
return MixEditView.__super__.constructor.apply(this, arguments);
}
MixEditView.prototype.template = _.template(Template);
@@ -45,7 +45,6 @@
MixEditView.prototype.onDomRefresh = function() {
var _this = this;
$("#fileupload", this.el).fileupload({
downloadTemplateId: void 0,
url: "/_upload/",
@@ -71,7 +70,6 @@
MixEditView.prototype.onRender = function() {
var parent;
console.log("MixEditView: onRender");
this.sendImage = false;
parent = this;
@@ -103,7 +101,6 @@
},
initSelection: function(element, callback) {
var genres, result;
console.log("MixEditView: genres:initSelection");
result = [];
genres = parent.model.get("genre-list");
@@ -134,7 +131,6 @@
MixEditView.prototype.saveChanges = function() {
var data,
_this = this;
console.log("MixEditView: saveChanges");
data = Syphon.serialize($("#mix-details-form", this.el)[0]);
this.model.set(data);
@@ -191,6 +187,7 @@
MixEditView;
return MixEditView;
})(EditableView);

View File

@@ -11,12 +11,6 @@ define ['app', 'toastr', 'app.lib/editableView', 'moment', 'utils', 'backbone.sy
avatarType = @model.get('avatar_type')
$('#avatar_' + avatarType, @el).attr('checked', true);
if avatarType is "custom"
@setupImageEditable
el: $("#div_avatar_image_upload", @el)
showbuttons: false
chooseMessage: "Choose avatar image"
$("#mix-imageupload", @el).jas_fileupload uploadtype: "image"
$("#div_avatar_image_upload", @el).show()
#$("#file_upload").uploadifive uploadScript: "ajax/upload_avatar_image/"
else

View File

@@ -1,17 +1,16 @@
// Generated by CoffeeScript 1.6.2
// Generated by CoffeeScript 1.3.3
(function() {
var __hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
define(['app', 'toastr', 'app.lib/editableView', 'moment', 'utils', 'backbone.syphon', 'text!/tpl/UserEditView'], function(App, toastr, EditableView, moment, utils, Syphon, Template) {
var UserEditView, _ref;
var UserEditView;
UserEditView = (function(_super) {
__extends(UserEditView, _super);
function UserEditView() {
_ref = UserEditView.__super__.constructor.apply(this, arguments);
return _ref;
return UserEditView.__super__.constructor.apply(this, arguments);
}
UserEditView.prototype.template = _.template(Template);
@@ -23,19 +22,10 @@
UserEditView.prototype.onRender = function() {
var avatarType;
console.log("MixEditView: onRender");
avatarType = this.model.get('avatar_type');
$('#avatar_' + avatarType, this.el).attr('checked', true);
if (avatarType === "custom") {
this.setupImageEditable({
el: $("#div_avatar_image_upload", this.el),
showbuttons: false,
chooseMessage: "Choose avatar image"
});
$("#mix-imageupload", this.el).jas_fileupload({
uploadtype: "image"
});
$("#div_avatar_image_upload", this.el).show();
} else {
$("#div_avatar_image_upload", this.el).hide();
@@ -45,7 +35,6 @@
UserEditView.prototype.selectAvatar = function(evt) {
var type;
type = $(evt.currentTarget).val();
this.model.set("avatar_type", type);
if (type === "custom") {
@@ -57,14 +46,12 @@
UserEditView.prototype.saveChanges = function() {
var data, ref;
data = Backbone.Syphon.serialize(this);
this.model.set(data);
ref = this;
this._saveChanges({
success: function() {
var _this = this;
if (ref.model.get('avatar_type') === "custom") {
$.ajaxFileUpload({
url: "ajax/upload_avatar_image/",

View File

@@ -59,13 +59,6 @@
</p>
</div>
<div class="col-md-7">
<div class="row">
<p>
<h5>Tell us a bit about yourself.</h5>
</p>
<textarea style="width: 100%" name="description" id="description" rows="5"><%= description
%></textarea>
</div>
<div class="row">
<p>
<h5>What can we share about you?</h5>