mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-11-22 12:41:11 +00:00
Draw abilities from profiles
This commit is contained in:
parent
eadb8f3b12
commit
c6c9192dcf
4 changed files with 17 additions and 15 deletions
|
@ -10,9 +10,9 @@ var profileSchema = new Schema({
|
|||
fade: { type: Boolean, default: false },
|
||||
gorge: { type: Boolean, default: false },
|
||||
onos: { type: Boolean, default: false },
|
||||
commander: { type: Boolean, default: false },
|
||||
enslo: { type: Number, default: null }
|
||||
commander: { type: Boolean, default: false }
|
||||
},
|
||||
enslo: { type: Number, default: null },
|
||||
division: { type: String, default: null }
|
||||
});
|
||||
|
||||
|
|
|
@ -633,15 +633,22 @@ var Gatherers = React.createClass({
|
|||
alt={gatherer.user.country} />);
|
||||
};
|
||||
|
||||
var division = (<span className="label label-primary">{gatherer.user.ability.division}</span>);
|
||||
if (gatherer.user.profile.division) {
|
||||
var division = (<span className="label label-primary">{gatherer.user.profile.division}</span>);
|
||||
}
|
||||
|
||||
var abilities = [];
|
||||
for (let attr in gatherer.user.profile.abilities) {
|
||||
if (gatherer.user.profile.abilities[attr]) abilities.push(_.capitalize(attr));
|
||||
}
|
||||
var lifeform = (
|
||||
gatherer.user.ability.lifeforms.map(lifeform => {
|
||||
abilities.map(lifeform => {
|
||||
return (<span className="label label-default"
|
||||
key={[lifeform, gatherer.id].join("-")}>{lifeform}</span>);
|
||||
})
|
||||
);
|
||||
var team;
|
||||
|
||||
var team;
|
||||
if (gatherer.user.team) {
|
||||
team = (<span className="label label-primary">{gatherer.user.team.name}</span>);
|
||||
}
|
||||
|
|
|
@ -30,11 +30,6 @@ function User (user) {
|
|||
nickname: null
|
||||
};
|
||||
}
|
||||
this.ability = {
|
||||
division: "Div " + (Math.floor(Math.random() * 4) + 1),
|
||||
lifeforms: [["Lerk", "Onos", "Fade"][Math.floor(Math.random() * 3)]],
|
||||
commander: true
|
||||
}
|
||||
this.profile = null;
|
||||
}
|
||||
|
||||
|
@ -44,11 +39,11 @@ User.find = (id, callback) => {
|
|||
}, (error, response, body) => {
|
||||
if (error) return callback(error);
|
||||
if (response.statusCode !== 200) return callback(new Error("Unable to auth user against API"));
|
||||
let u = new User(body);
|
||||
Profile.findOrCreate(u, function (error, profile) {
|
||||
let user = new User(body);
|
||||
Profile.findOrCreate(user, function (error, profile) {
|
||||
if (error) return callback(error);
|
||||
u.profile = profile;
|
||||
return callback(null, u);
|
||||
user.profile = profile.toJson();
|
||||
return callback(null, user);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
|
|
@ -23,7 +23,7 @@ describe("Profile model", () => {
|
|||
assert.isFalse(result.abilities.fade);
|
||||
assert.isFalse(result.abilities.onos);
|
||||
assert.isFalse(result.abilities.commander);
|
||||
assert.isNull(result.abilities.enslo);
|
||||
assert.isNull(result.enslo);
|
||||
assert.isNull(result.division);
|
||||
done();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue