def testForLoggedInAccountWithNoUserEntity(self): """Tests that None is returned for a logged-in user with no entity.""" # sign in a user with an account but with no user entity profile_utils.signInToGoogleAccount(TEST_EMAIL, TEST_ACCOUNT_ID) result = user_logic.getByCurrentAccount() self.assertIsNone(result)
def testForLoggedInAccountWithNoUserEntity(self): """Tests that None is returned for a logged-in user with no entity.""" # sign in a user with an account but with no user entity profile_utils.signInToGoogleAccount(TEST_EMAIL, TEST_ACCOUNT_ID) result = user_logic.getByCurrentAccount() self.assertIsNone(result)
def testForNonLoggedInAccount(self): """Tests that None is returned for a not logged-in user.""" # seed a user but make sure that nobody is logged in profile_utils.seedNDBUser() profile_utils.logout() result = user_logic.getByCurrentAccount() self.assertIsNone(result)
def testForNonLoggedInAccount(self): """Tests that None is returned for a not logged-in user.""" # seed a user but make sure that nobody is logged in profile_utils.seedNDBUser() profile_utils.logout() result = user_logic.getByCurrentAccount() self.assertIsNone(result)
def testForLoggedInAccountWithUserEntity(self): """Tests that user entity is returned for a logged-in user with entity.""" # seed a user entity and log them in user = profile_utils.seedNDBUser() profile_utils.loginNDB(user) result = user_logic.getByCurrentAccount() self.assertIsNotNone(result) self.assertEqual(user.key, result.key) self.assertEqual(user.account_id, result.account_id)
def wrapped(self): """Decorator wrapper method.""" user_id = clean_link_id(field_name)(self) current_user = user_logic.getByCurrentAccount() if not current_user or current_user.user_id != user_id: # this user is not the current user raise forms.ValidationError('This user is not you.') return current_user if as_user else user_id
def wrapped(self): """Decorator wrapper method.""" user_id = clean_link_id(field_name)(self) current_user = user_logic.getByCurrentAccount() if not current_user or current_user.user_id != user_id: # this user is not the current user raise forms.ValidationError('This user is not you.') return current_user if as_user else user_id
def testForLoggedInAccountWithUserEntity(self): """Tests that user entity is returned for a logged-in user with entity.""" # seed a user entity and log them in user = profile_utils.seedNDBUser() profile_utils.loginNDB(user) result = user_logic.getByCurrentAccount() self.assertIsNotNone(result) self.assertEqual(user.key, result.key) self.assertEqual(user.account_id, result.account_id)
def wrapped(self): """Decorator wrapper method. """ clean_user_field = clean_existing_user(field_name) user = clean_user_field(self) current_user = user_logic.getByCurrentAccount() if user.key == current_user.key: # users are equal raise forms.ValidationError('You cannot enter yourself here.') return user
def wrapped(self): """Decorator wrapper method. """ clean_user_field = clean_existing_user(field_name) user = clean_user_field(self) current_user = user_logic.getByCurrentAccount() if user.key == current_user.key: # users are equal raise forms.ValidationError('You cannot enter yourself here.') return user
def ndb_user(self): """Returns the ndb_user field.""" if not self._isSet(self._ndb_user): self._ndb_user = ndb_user_logic.getByCurrentAccount() # TODO(daniel): add support for "Logged in as" feature # developer may view the page as another user if self._ndb_user and users.is_current_user_admin(): settings = settings_logic.getUserSettings(self._ndb_user.key) if settings.view_as is not None: user = settings.view_as.get() if user: self._ndb_user = user else: user_settings_url = links.LINKER.user( self._ndb_user, urls.UrlNames.USER_SETTINGS) raise exception.BadRequest( message=VIEW_AS_USER_DOES_NOT_EXIST % user_settings_url) return self._ndb_user