mirror of
https://github.com/sudoxnym/habitica.git
synced 2026-08-04 09:39:23 +00:00
v3 adapt v2: fix tags _id, stickyHeader and unlocking
This commit is contained in:
parent
6380161321
commit
f5144fddaa
7 changed files with 20 additions and 13 deletions
|
|
@ -44,9 +44,11 @@ module.exports = function unlock (user, req = {}, analytics) {
|
|||
|
||||
if (alreadyOwnedItems === setPaths.length) {
|
||||
throw new NotAuthorized(i18n.t('alreadyUnlocked', req.language));
|
||||
} else if (alreadyOwnedItems > 0) {
|
||||
// TODO write math formula to check if buying the full set is cheaper than the items individually
|
||||
// (item cost * number of remaining items) < setCost`
|
||||
} /* else if (alreadyOwnedItems > 0) {
|
||||
throw new NotAuthorized(i18n.t('alreadyUnlockedPart', req.language));
|
||||
}
|
||||
} */
|
||||
} else {
|
||||
alreadyOwns = _.get(user, `purchased.${path}`) === true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -109,7 +109,7 @@ angular.module('habitrpg')
|
|||
if (MOBILE_APP) Notification.push({type:'text',text:message});
|
||||
else Notification.text(message);
|
||||
// In the case of 200s, they're friendly alert messages like "Your pet has hatched!" - still send the op
|
||||
if ((err.code && err.code >= 400) || !err.code) return;
|
||||
if ((err.code && err.code >= 400) || !err.code) return;
|
||||
}
|
||||
userServices.log({op:k, params: req.params, query:req.query, body:req.body});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -54,7 +54,8 @@ describe('shared.ops.unlock', () => {
|
|||
}
|
||||
});
|
||||
|
||||
it('returns an error when user already owns items in a full set', (done) => {
|
||||
// disabled untill fully implemente
|
||||
xit('returns an error when user already owns items in a full set', (done) => {
|
||||
try {
|
||||
unlock(user, {query: {path: unlockPath}});
|
||||
unlock(user, {query: {path: unlockPath}});
|
||||
|
|
|
|||
|
|
@ -988,6 +988,7 @@ api.batchUpdate = function(req, res, next) {
|
|||
response = transformedData;
|
||||
|
||||
response.todos = shared.preenTodos(response.todos);
|
||||
response.wasModified = true;
|
||||
res.status(200).json(response);
|
||||
});
|
||||
// return only the version number
|
||||
|
|
|
|||
|
|
@ -4,13 +4,15 @@ import objectPath from 'object-path'; // TODO use lodash's unset once v4 is out
|
|||
import _ from 'lodash';
|
||||
|
||||
module.exports = function baseModel (schema, options = {}) {
|
||||
schema.add({
|
||||
_id: {
|
||||
type: String,
|
||||
default: uuid,
|
||||
validate: [validator.isUUID, 'Invalid uuid.'],
|
||||
},
|
||||
});
|
||||
if (options._id !== false) {
|
||||
schema.add({
|
||||
_id: {
|
||||
type: String,
|
||||
default: uuid,
|
||||
validate: [validator.isUUID, 'Invalid uuid.'],
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
if (options.timestamps) {
|
||||
schema.add({
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import validator from 'validator';
|
|||
let Schema = mongoose.Schema;
|
||||
|
||||
export let schema = new Schema({
|
||||
_id: false, // use id not _id
|
||||
id: {
|
||||
type: String,
|
||||
default: uuid,
|
||||
|
|
@ -17,10 +16,12 @@ export let schema = new Schema({
|
|||
}, {
|
||||
strict: true,
|
||||
minimize: false, // So empty objects are returned
|
||||
_id: false, // use id instead of _id
|
||||
});
|
||||
|
||||
schema.plugin(baseModel, {
|
||||
noSet: ['_id', 'id', 'challenge'],
|
||||
_id: false, // use id instead of _id
|
||||
});
|
||||
|
||||
export let model = mongoose.model('Tag', schema);
|
||||
|
|
|
|||
|
|
@ -760,7 +760,7 @@ schema.methods.addTasksToUser = function addTasksToUser (tasks) {
|
|||
|
||||
obj.tags = obj.tags.map(tag => {
|
||||
return {
|
||||
id: tag._id,
|
||||
id: tag.id,
|
||||
name: tag.name,
|
||||
challenge: tag.challenge,
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue