migrate: flags.ads -> purchased.ads (boolean); flags.newStuff to boolean

This commit is contained in:
Tyler Renelle
2013-10-22 18:50:50 -07:00
parent c40697761b
commit 44cb797063
6 changed files with 11 additions and 7 deletions

View 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}});
});

View File

@@ -1 +1 @@
db.users.update({},{$set:{'flags.newStuff':'show'}},{multi:true})
db.users.update({},{$set:{'flags.newStuff':true}},{multi:true})

View File

@@ -14,7 +14,7 @@ habitrpg.controller("FooterCtrl", ['$scope', '$rootScope', 'User', '$http',
$.getScript('//checkout.stripe.com/v2/checkout.js');
// 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() {
// $('body').append('<img src="//wms.assoc-amazon.com/20070822/US/img/noscript.gif?tag=ha0d2-20" alt="" />');
// });

View File

@@ -627,7 +627,7 @@ api.buyGems = function(req, res) {
},
function(response, cb) {
res.locals.user.balance += 5;
res.locals.user.flags.ads = 'hide';
res.locals.user.purchased.ads = true;
res.locals.user.save(cb);
}
], function(err, saved){
@@ -652,7 +652,7 @@ api.buyGemsPaypalIPN = function(req, res) {
if (err) throw err;
if (_.isEmpty(user)) throw "user not found with uuid " + uuid + " when completing paypal transaction"
user.balance += 5;
user.flags.ads = 'hide';
user.purchased.ads = true;
user.save();
console.log('PayPal transaction completed and user updated');
});

View File

@@ -78,10 +78,9 @@ var UserSchema = new Schema({
flags: {
customizationsNotification: {type: Boolean, 'default': false},
showTour: {type: Boolean, 'default': true},
ads: {type: String, 'default': 'show'}, // FIXME make this a boolean, run migration
dropsEnabled: {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},
partyEnabled: Boolean, // FIXME do we need this?
petsEnabled: {type: Boolean, 'default': false},

View File

@@ -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"')
a(ng-click='modals.buyGems=true', tooltip='Remove Ads')
i.icon-remove