# HG changeset patch # User Sverre Rabbelier # Date 1232900976 0 # Node ID e35b3d98d4698b0b423f3943544e79f654d63b43 # Parent 6fd5c561b446c1079200d34fb60f510012546e92 Flush the sidebar if a user's rights change Patch by: Sverre Rabbelier diff -r 6fd5c561b446 -r e35b3d98d469 app/soc/logic/models/user.py --- a/app/soc/logic/models/user.py Sun Jan 25 16:28:07 2009 +0000 +++ b/app/soc/logic/models/user.py Sun Jan 25 16:29:36 2009 +0000 @@ -25,6 +25,7 @@ from google.appengine.api import users from google.appengine.ext import db +from soc.cache import sidebar from soc.logic.helper import notifications from soc.logic.models import base from soc.logic.models.site import logic as site_logic @@ -131,21 +132,32 @@ return ['link_id'] - def _updateField(self, model, name, value): + def _updateField(self, entity, name, value): """Special case logic for account. When the account is changed, the former_accounts field should be appended with the old account. + Also, if either is_developer or agrees_to_tos change, the user's + rights have changed, so we need to flush the sidebar. """ - if (name == 'account') and (model.account != value): - model.former_accounts.append(model.account) + + if (name == 'is_developer') and (entity.is_developer != value): + sidebar.flush(entity.account) + + if (name == 'agrees_to_tos') and (entity.agrees_to_tos != value): + sidebar.flush(entity.account) + + if (name == 'account') and (entity.account != value): + entity.former_accounts.append(entity.account) return True def _onCreate(self, entity): """Send out a message to welcome the new user. """ + notifications.sendWelcomeMessage(entity) + sidebar.flush(entity.account) logic = Logic()