23 |
23 |
24 |
24 |
25 from google.appengine.api import users |
25 from google.appengine.api import users |
26 from google.appengine.ext import db |
26 from google.appengine.ext import db |
27 |
27 |
|
28 from soc.cache import sidebar |
28 from soc.logic.helper import notifications |
29 from soc.logic.helper import notifications |
29 from soc.logic.models import base |
30 from soc.logic.models import base |
30 from soc.logic.models.site import logic as site_logic |
31 from soc.logic.models.site import logic as site_logic |
31 |
32 |
32 import soc.models.user |
33 import soc.models.user |
129 """See base.Logic.getKeyFieldNames. |
130 """See base.Logic.getKeyFieldNames. |
130 """ |
131 """ |
131 |
132 |
132 return ['link_id'] |
133 return ['link_id'] |
133 |
134 |
134 def _updateField(self, model, name, value): |
135 def _updateField(self, entity, name, value): |
135 """Special case logic for account. |
136 """Special case logic for account. |
136 |
137 |
137 When the account is changed, the former_accounts field should be appended |
138 When the account is changed, the former_accounts field should be appended |
138 with the old account. |
139 with the old account. |
|
140 Also, if either is_developer or agrees_to_tos change, the user's |
|
141 rights have changed, so we need to flush the sidebar. |
139 """ |
142 """ |
140 if (name == 'account') and (model.account != value): |
143 |
141 model.former_accounts.append(model.account) |
144 if (name == 'is_developer') and (entity.is_developer != value): |
|
145 sidebar.flush(entity.account) |
|
146 |
|
147 if (name == 'agrees_to_tos') and (entity.agrees_to_tos != value): |
|
148 sidebar.flush(entity.account) |
|
149 |
|
150 if (name == 'account') and (entity.account != value): |
|
151 entity.former_accounts.append(entity.account) |
142 |
152 |
143 return True |
153 return True |
144 |
154 |
145 def _onCreate(self, entity): |
155 def _onCreate(self, entity): |
146 """Send out a message to welcome the new user. |
156 """Send out a message to welcome the new user. |
147 """ |
157 """ |
|
158 |
148 notifications.sendWelcomeMessage(entity) |
159 notifications.sendWelcomeMessage(entity) |
|
160 sidebar.flush(entity.account) |
149 |
161 |
150 |
162 |
151 logic = Logic() |
163 logic = Logic() |