Пример #1
0
    def test_user_creation_and_editing(self):
        test_user = users.User('*****@*****.**')
        new = Customer.create(url='test', user=test_user)
        self.assertTrue(new)
        self.assertEqual(Customer.get_points_for('test').__len__(), 0)
        self.assertTrue(Point.create_point(new, dict(lat=63.345, lon= -4.23)))
        self.assertEqual(Customer.get_points_for('test').__len__(), 1)

        self.assertRaises(Exception, Customer.create, url='test', user=users.User('*****@*****.**'))
        self.assertRaises(Exception, Customer.create, url='TeSt', user=users.User('*****@*****.**'))
        self.assertRaises(Exception, Customer.create, url='new_test', user=test_user)

        renew = Customer.create(url='newtest', user=test_user)
        self.assertTrue(renew)
        self.assertEqual(Customer.get_points_for('newtest').__len__(), 1)
        self.assertTrue(Point.create_point(renew, dict(lat=43.345, lon= -3.23)))
        self.assertEqual(Customer.get_points_for('newtest').__len__(), 2)
Пример #2
0
    def run(self, username, password, bank_name):

        try:
            bank = Bank.get(bank_name=bank_name)
        except Bank.DoesNotExist:
            raise Exception("no bank exists with this name")

        try:
            user = User.create_user(username, password)

        except IntegrityError as e:
            raise Exception("username is duplicate, please choose another")

        try:
            Customer.create(user=user, bank=bank)
            print("Welcome to virtual bank world ;)")
        except Exception as e:
            print(e)
            raise Exception('Some problem happened in creating customer')
Пример #3
0
def create_customer(first_name,
                    last_name,
                    business_id,
                    email=None,
                    phone_number=None):
    from models import Customer

    return Customer.create(first_name=first_name,
                           last_name=last_name,
                           business_id=business_id,
                           email=email,
                           phone_number=phone_number)
Пример #4
0
def register():
    name = input("Enter full name: ")
    pin = int(input("Enter a four digit PIN: "))
    while True:
        temp_acc = randrange(10000, 99999)
        acc = Customer.select().where(Customer.acc_num == temp_acc)
        if acc.exists():
            continue
        else:
            gen_acc = temp_acc
            break
    init_bal = float(input("Enter initial balance: "))
    print(f"Your account number is: {gen_acc}")
    Customer.create(full_name=name, pin=pin, acc_num=gen_acc, balance=init_bal)
    Statement.create(ac_no=gen_acc,
                     credit=init_bal,
                     debit=0,
                     timestamp=datetime.now(),
                     os_balance=init_bal,
                     description="Opening balance")
    print("Press any key")
    dummy = input()
Пример #5
0
    def create(self):
        try:
            plan = Plan.get(id=self.plan)
            customer = Customer.create(name=self.name,
                                       password=self.password,
                                       email_address=self.email,
                                       plan=plan.id,
                                       renewal_date=self.renewal_date)
            customer.save()
        except IntegrityError:

            return {"message": "Customer already exist"}
        else:
            return {"message": "Account created successfully"}
Пример #6
0
def new_cust(loc_name):
    print 'new cust ' + loc_name
    try:
        location = Location.get(
            Location.name == loc_name)  #get location if exists
    except Location.DoesNotExist:
        location = Location.create(name=loc_name, curr_number=0,
                                   high_number=0)  #create location if not
        queues[location.name] = Queue()  #create new queue for location
        pass
    location.high_number += 1  #increment location's high number
    location.save()  #write to database
    #add new customer to queue
    queues[location.name].put(
        Customer.create(location=location,
                        number=location.high_number,
                        checkin=datetime.now()))
    return 'Adding cust at ' + location.name + ' with num ' + str(
        location.high_number)
Пример #7
0
def process_iden_conversation(msg, created=True, conv=None):
    resp = VoiceResponse()
    app.logger.info('customer is registered')
    conversation = new_conversation()
    if created:
        input_msg=''
    else:
        input_msg=request.form['SpeechResult'] if 'SpeechResult' in request.form else 'donno'
    app.logger.info('input_message [%s] created [%s]', input_msg, created)
    #conv.log_json()
    watson_response = new_conversation_msg(conversation, context=conv.context, input_msg=input_msg, first=False)
    conv.store_context()
    # check if watson identified the customer
    twilio_resp, watson_dialog = create_response(watson_response, conv, twilio_voice=resp)
    app.logger.info('output_message [%s] ', watson_dialog)
    if 'action' in conv.context:
        if conv.context['action'] == 'register_customer':
            cust=Customer.create(
                name=str(conv.context['name']).lower(),
                business=conv.business,
                phone=conv.call_number
            )
            conv.customer = cust
        elif conv.context['action'] == 'create_app':
            app_date = conv.context['app_date']
            app_time = conv.context['app_time']
            start = datetime.strptime(f"{app_date} {app_time}", '%Y-%m-%d %H:%M:%S')
            end = start+timedelta(hours=float(conv.context['app_duration']))
            appoint = Appointment(
                customer=conv.customer,
                note='tutoring',
                start=start,
                end=end
            )
            app.logger.info(f"created a new appointment {start} to {end}")
            appoint.save()
            conv.context['success'] = 'true'
        elif conv.context['action'] == 'end':
            twilio_resp.hangup()
        conv.context.pop('action', None)
    conv.save()
    return str(resp)
Пример #8
0
 def post(self):
     data = json_decode(self.request.body)
     scheme = {
         'name': {
             'type': 'string',
             'required': True},
         'passport': {
             'type': 'string',
             'required': True}}
     if not self.valid_data(scheme, data):
         return
     try:
         customer = Customer.create(**data)
         self.set_response(
             content=dict(customer=model_to_dict(customer)),
             status=201,
             headers={'Location': self.reverse_url('customer', customer.id)})
     except peewee.IntegrityError:
         self.set_response(
             content={'message': 'Customer with passport code {} already exists'.format(data['passport'])},
             status=409)
Пример #9
0
def create_customer(url, user):
    return Customer.create(url, user)
Пример #10
0
		page = requests.get(url)
		print "2"
		bf = BeautifulSoup(page.content)
		print "3"	
		review_list = bf.find_all('div',{'class','criticinfo'})
		#print "getting " + len(review_list) + " customer info"

		for review in review_list:
			info = review.find('a')
			customer_name = info.text
			customer_href = info.get('href')			 
			print "try to save customer " + customer_name

			try:
				customer = Customer.create(
					name = customer_name,
					href = customer_href,
					fetched = False)
				customer.save()
				print "customer saved"

				customer_movie = Customer_Movie.create(
					customer = customer,
					movie = movie)
				customer_movie.save()
				print "customer_movie saved"

			except Exception, e:
				print "exception when saving customer"

		movie.fetched = True;
		movie.save()