Example #1
0
    def post(self):
        form = RequestForm(data = self.request.POST)

        if form.is_valid():
            email = self.request.get('email')
            category = int(self.request.get('category'))
            subject = self.request.get('subject')
            notes = self.request.get('notes')
    
            requestor_manager = RequestorManager(email)
            
            if (self.__session.is_logged_in() == False):
                name = self.request.get('name')
                phone = self.request.get('phone')
                company = self.request.get('company')
                
                if requestor_manager.is_new():
                    requestor_manager.create_requestor(name, phone, company)
                self.__session.register_login(email)
                self.__session.set_requestor(requestor_manager.get_requestor())
            
            request_manager = RequestorRequestManager(requestor_manager.get_requestor())
            request_manager.create_request(category, subject, notes)

        self.get(form = form)
Example #2
0
def create_dummy_requestor(index):
    requestor_manager = RequestorManager(email = '*****@*****.**' % index)

    # Create the requestor
    requestor_manager.create_requestor(
                name = 'First%i, Last' % index,
                phone = '555-405-7685',
                company = 'My Company, Inc'
            )
    
    return requestor_manager
 def test_create_requestor(self):
     """ Create a new requestor and verify it is correctly stored """
     
     requestor_manager = RequestorManager(email = '*****@*****.**')
     
     # Verify the requestor does not exist yet
     requestor = requestor_manager.get_requestor()
     self.assertIsNone(requestor)
     self.assertTrue(requestor_manager.is_new)
     
     # Create the requestor
     requestor_manager.create_requestor(
                 name = 'First, Last',
                 phone = '555-405-7685',
                 company = 'My Company, Inc'
             )
     
     # Reinstance the requestor manager
     requestor_manager = RequestorManager(email = '*****@*****.**')
     
     # Retrieve the requestor and verify it exists
     requestor = requestor_manager.get_requestor()
     
     self.verify_entity_instance(requestor, RequestorEntity)