Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import Backbone from "backbone";
import Badge from "models/Badge";
import globals from "globals";
export default Backbone.Collection.extend({
model: Badge,
url: globals.BADGE_HOST + "/1",
parse: function(response) {
this.meta = {
count: response.count,
next: response.next,
previous: response.previous
};
return response.instances.map(function(instance) {
return instance.badge;
});
}
});
grant: function(params) {
try {
var badge = params.badge,
email = stores.ProfileStore.get().get("email"),
system = globals.BADGE_SYSTEM,
secret = globals.BADGE_SECRET,
csrftoken = this.getCookie("csrftoken"),
badgeSlug = badge.get("slug");
} catch (err) {
return;
}
$.ajax({
url: globals.BADGE_HOST,
type: "POST",
dataType: "json",
contentType: "application/json",
headers: {
"X-CSRFToken": csrftoken
},
data: JSON.stringify({
email: email,
system: system,
badgeSlug: badgeSlug,
secret: secret
}),
success: function() {
NotificationController.info("You have earned a badge!");
Utils.dispatch(BadgeConstants.GRANT_BADGE, {
badge: badge
import Backbone from "backbone";
import globals from "globals";
export default Backbone.Model.extend({
urlRoot: globals.BADGE_HOST
});
import Backbone from "backbone";
import Badge from "models/Badge";
import globals from "globals";
export default Backbone.Collection.extend({
model: Badge,
url: globals.BADGE_HOST,
parse: function(response) {
this.meta = {
count: response.count,
next: response.next,
previous: response.previous
};
return response.badges;
}
});