Added safety to account_settings template

This commit is contained in:
J. Cliff Dyer
2016-03-23 20:08:27 +00:00
parent 74a9989f04
commit 32729eb838
4 changed files with 28 additions and 12 deletions

View File

@@ -34,23 +34,27 @@
// Currently when a non-staff user A access user B's profile, the only way to tell whether user B's
// profile is public is to check if the api has returned fields other than the default public fields
// specified in settings.ACCOUNT_VISIBILITY_CONFIGURATION.
var responseKeys = _.filter(_.keys(response), function (key) {return key !== 'default_public_account_fields'});
response.profile_is_public = _.size(_.difference(responseKeys, response.default_public_account_fields)) > 0;
return response;
var responseKeys = _.filter(_.keys(response), function (key) {
return key !== 'default_public_account_fields';
});
var isPublic = _.size(_.difference(responseKeys, response.default_public_account_fields)) > 0;
response.profile_is_public = isPublic;
return response;
},
hasProfileImage: function () {
var profile_image = this.get('profile_image');
return (_.isObject(profile_image) && profile_image['has_image'] === true);
return (_.isObject(profile_image) && profile_image.has_image === true);
},
profileImageUrl: function () {
return this.get('profile_image')['image_url_large'];
return this.get('profile_image').image_url_large;
},
isAboveMinimumAge: function() {
var isBirthDefined = !(_.isUndefined(this.get('year_of_birth')) || _.isNull(this.get('year_of_birth')));
var yearOfBirth = this.get('year_of_birth');
var isBirthDefined = !(_.isUndefined(yearOfBirth) || _.isNull(yearOfBirth));
return isBirthDefined && !(this.get("requires_parental_consent"));
}
});