mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-15 13:47:33 +01:00
migrate: flags.ads -> purchased.ads (boolean); flags.newStuff to boolean
This commit is contained in:
5
migrations/20131022_purchased_and_newStuff.js
Normal file
5
migrations/20131022_purchased_and_newStuff.js
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
db.users.find().forEach(function(user){
|
||||||
|
if (!user.purchased) user.purchased = {hair: {}, skin: {}};
|
||||||
|
user.purchased.ads = user.flags && !!user.flags.ads;
|
||||||
|
db.users.update({_id:user._id}, {$set:{'purchased': user.purchased, 'flags.newStuff': true}, $unset: {'flags.ads':1}});
|
||||||
|
});
|
||||||
@@ -1 +1 @@
|
|||||||
db.users.update({},{$set:{'flags.newStuff':'show'}},{multi:true})
|
db.users.update({},{$set:{'flags.newStuff':true}},{multi:true})
|
||||||
@@ -14,7 +14,7 @@ habitrpg.controller("FooterCtrl", ['$scope', '$rootScope', 'User', '$http',
|
|||||||
$.getScript('//checkout.stripe.com/v2/checkout.js');
|
$.getScript('//checkout.stripe.com/v2/checkout.js');
|
||||||
|
|
||||||
// Amazon Affiliate
|
// Amazon Affiliate
|
||||||
// if ($rootScope.authenticated() && User.user.flags.ads !== 'hide') {
|
// if ($rootScope.authenticated() && !User.user.purchased.ads) {
|
||||||
// $.getScript('//wms.assoc-amazon.com/20070822/US/js/link-enhancer-common.js?tag=ha0d2-20').fail(function() {
|
// $.getScript('//wms.assoc-amazon.com/20070822/US/js/link-enhancer-common.js?tag=ha0d2-20').fail(function() {
|
||||||
// $('body').append('<img src="//wms.assoc-amazon.com/20070822/US/img/noscript.gif?tag=ha0d2-20" alt="" />');
|
// $('body').append('<img src="//wms.assoc-amazon.com/20070822/US/img/noscript.gif?tag=ha0d2-20" alt="" />');
|
||||||
// });
|
// });
|
||||||
|
|||||||
@@ -627,7 +627,7 @@ api.buyGems = function(req, res) {
|
|||||||
},
|
},
|
||||||
function(response, cb) {
|
function(response, cb) {
|
||||||
res.locals.user.balance += 5;
|
res.locals.user.balance += 5;
|
||||||
res.locals.user.flags.ads = 'hide';
|
res.locals.user.purchased.ads = true;
|
||||||
res.locals.user.save(cb);
|
res.locals.user.save(cb);
|
||||||
}
|
}
|
||||||
], function(err, saved){
|
], function(err, saved){
|
||||||
@@ -652,7 +652,7 @@ api.buyGemsPaypalIPN = function(req, res) {
|
|||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
if (_.isEmpty(user)) throw "user not found with uuid " + uuid + " when completing paypal transaction"
|
if (_.isEmpty(user)) throw "user not found with uuid " + uuid + " when completing paypal transaction"
|
||||||
user.balance += 5;
|
user.balance += 5;
|
||||||
user.flags.ads = 'hide';
|
user.purchased.ads = true;
|
||||||
user.save();
|
user.save();
|
||||||
console.log('PayPal transaction completed and user updated');
|
console.log('PayPal transaction completed and user updated');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -78,10 +78,9 @@ var UserSchema = new Schema({
|
|||||||
flags: {
|
flags: {
|
||||||
customizationsNotification: {type: Boolean, 'default': false},
|
customizationsNotification: {type: Boolean, 'default': false},
|
||||||
showTour: {type: Boolean, 'default': true},
|
showTour: {type: Boolean, 'default': true},
|
||||||
ads: {type: String, 'default': 'show'}, // FIXME make this a boolean, run migration
|
|
||||||
dropsEnabled: {type: Boolean, 'default': false},
|
dropsEnabled: {type: Boolean, 'default': false},
|
||||||
itemsEnabled: {type: Boolean, 'default': false},
|
itemsEnabled: {type: Boolean, 'default': false},
|
||||||
newStuff: {type: String, 'default': 'hide'}, //FIXME to boolean (currently show/hide)
|
newStuff: {type: Boolean, 'default': false},
|
||||||
rewrite: {type: Boolean, 'default': true},
|
rewrite: {type: Boolean, 'default': true},
|
||||||
partyEnabled: Boolean, // FIXME do we need this?
|
partyEnabled: Boolean, // FIXME do we need this?
|
||||||
petsEnabled: {type: Boolean, 'default': false},
|
petsEnabled: {type: Boolean, 'default': false},
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
div(ng-if='authenticated() && user.flags.ads!="hide"')
|
div(ng-if='authenticated() && !user.purchased.ads')
|
||||||
span.pull-right(ng-if='list.type!="reward"')
|
span.pull-right(ng-if='list.type!="reward"')
|
||||||
a(ng-click='modals.buyGems=true', tooltip='Remove Ads')
|
a(ng-click='modals.buyGems=true', tooltip='Remove Ads')
|
||||||
i.icon-remove
|
i.icon-remove
|
||||||
|
|||||||
Reference in New Issue
Block a user