def test_method_get_instance(self): """User instance get single user by primary key""" user = User.get(TEST_USERNAME) # make sure one user is returned self.assertIsInstance(user, User)
def test_method_get_instance(self): """User instance get single user by primary key""" user = User.get(TEST_USERNAME) # make sure one user is returned self.assertIsInstance(user, User)
def validate(self): if not self._message: raise ActionError("Message can not be empty.") try: self._sender = User.current() except UserError: raise ActionError("Could not identify current user.") # get ooto notification recipients from the configs ptask_area = PTaskArea.current() ooto_config = ptask_area.config( OOTO_CONFIG_PATH, composite_ancestors=True, composite_method="append", ) ooto_notify = ooto_config.get('notify', []) self._to.extend(ooto_notify) # for all usernames specified, make sure they're a valid user, # get their email addresses. recipients = set() for recipient in self._to: # assume already a valid email address if "@" in recipient: recipients.add(recipient) else: try: recipient = User.get(recipient) except UserError: raise ActionError( "Could not identify user: "******"\n\nCurrent ptask: {p}".format(p=ptask_area.spec) self._message += "\n\n- {s}".format(s=self._sender.full_name) self._subject = "OOTO: {fn} ({un})".format( fn=self.sender.full_name, un=self.sender.username, )
def validate(self): if not self._message: raise ActionError("Message can not be empty.") try: self._sender = User.current() except UserError: raise ActionError("Could not identify current user.") # get ooto notification recipients from the configs ptask_area = PTaskArea.current() ooto_config = ptask_area.config( OOTO_CONFIG_PATH, composite_ancestors=True, composite_method="append", ) ooto_notify = ooto_config.get('notify', []) self._to.extend(ooto_notify) # for all usernames specified, make sure they're a valid user, # get their email addresses. recipients = set() for recipient in self._to: # assume already a valid email address if "@" in recipient: recipients.add(recipient) else: try: recipient = User.get(recipient) except UserError: raise ActionError( "Could not identify user: "******"\n\nCurrent ptask: {p}".format(p=ptask_area.spec) self._message += "\n\n- {s}".format(s=self._sender.full_name) self._subject = "OOTO: {fn} ({un})".format( fn=self.sender.full_name, un=self.sender.username, )
def emails_from_unames(unames): emails = set() for uname in unames: # assume already a valid email address if "@" in uname: emails.add(uname) else: try: user = User.get(uname) except UserError: raise NotificationError("Could not identify user: " + str(uname)) else: emails.add(user.email) return list(emails)
def emails_from_unames(unames): emails = set() for uname in unames: # assume already a valid email address if "@" in uname: emails.add(uname) else: try: user = User.get(uname) except UserError: raise NotificationError("Could not identify user: " + str(uname)) else: emails.add(user.email) return list(emails)
def execute(self): try: user = User.get(self.username) except UserError: self.logger.error( 'Could not determine user from: "{u}"'.format(u=self.username) ) raise # output headers. reused while defining the look of the output username = '******' last_name = 'Last' first_name = 'First' email = 'Email' active = 'Active' # define the look of the output output = Output() # defining the data headers output.header_names = [username, email] output.add_item( { username: user.username, email: user.email, }, color_all=Style.bright, ) # build the title title = " {u.first_name} {u.last_name}".format(u=user) if not user.is_active: title += " [INACTIVE]" title += " " output.title = title # dump the output as a list of key/value pairs output.dump()
def execute(self): try: user = User.get(self.username) except UserError: self.logger.error( 'Could not determine user from: "{u}"'.format(u=self.username)) raise # output headers. reused while defining the look of the output username = '******' last_name = 'Last' first_name = 'First' email = 'Email' active = 'Active' # define the look of the output output = Output() # defining the data headers output.header_names = [username, email] output.add_item( { username: user.username, email: user.email, }, color_all=Style.bright, ) # build the title title = " {u.first_name} {u.last_name}".format(u=user) if not user.is_active: title += " [INACTIVE]" title += " " output.title = title # dump the output as a list of key/value pairs output.dump()
def user(self): """:returns: a User object for the user assigned to the ptask.""" return User.get(self.user_username)
def creator(self): """:returns: a User object for the creator of this ptask.""" return User.get(self.creator_username)
def creator(self): """:returns: a User object for the creator of this ptask.""" return User.get(self.creator_username)
def setUp(self): """Get a new user object for each test.""" self.user = User.get(TEST_USERNAME)
def creator(self): return User.get(self.creator_username)
def creator(self): return User.get(self.creator_username)
def setUp(self): """Get a new user object for each test.""" self.user = User.get(TEST_USERNAME)
def user(self): """:returns: a User object for the user assigned to the ptask.""" return User.get(self.user_username)