def create(self): new_message = Message() new_message.customer_number = "1234567890" new_message.product_code = str(random.randrange(100, 999)) new_message.shop_code = "123" new_message.timestamp = datetime.now() new_message.notified = False return new_message
def _parse_query(self, query_params): shop_code = query_params.reply[:3] product_code = query_params.reply[3:] if not (Shop(shop_code).is_valid() and Product(product_code).is_valid()): raise Exception('Invalid product or shop code.') message = Message() message.customer_number = query_params.cellno message.product_code = product_code message.shop_code = shop_code message.timestamp = query_params.replydate #TODO: date conversion return message