def deactivate(self): if self.participant: if not self._validate(): return 'Invalid Google Wave account or activation code' self.account = phone.get_account(self.participant) if not self.account: return 'Participant doesn\'t have an account' query = model.ParticipantPreferences.all() query.filter('account_id =', self.account.account_id) if len(list(query)) == 1: return 'Cannot deactivate this participant from account. There\'s only participant linked to the account.' pp = model.ParticipantPreferences.get_by_pk(self.participant) pp.account_id = None pp.put() elif self.phone_type and self.phone_uid and self.phone_token: self._find_account_by_phone() query = model.Phone.all() query.filter('phone_type =', self.phone_type) query.filter('phone_uid =', self.phone_uid) query.filter('phone_token =', self.phone_token) db.delete(query)
def info(self): '''Gets info about an account by participant of phone''' if self.participant: self.account = phone.get_account(self.participant) if not self.account: return 'No account found for participant' self._find_account_by_phone() if not self.account and not self.participant: return 'No account found for phone'
def activate(self): '''Activates either a phone or a participant''' if self.participant and not self._validate(): return 'Invalid Google Wave account or activation code' self.account = phone.get_account(self.participant) self._find_account_by_phone() or self._create_account() if not self.account: return 'No account found or account could not be created.' if self.receipt_data: error = self._update_account() else: error = self._register_phone() return error
def _create_account(self): '''Try to create an account''' if self.account or not self.participant: return self.account = phone.get_account(self.participant, create=True)