Exemple #1
0
 def get_customer_address_other():
     customer_address_others = input(
         "Enter other address information (NA = Not applies): ")
     v = Validators(customer_address_others)
     validated_customer_address_others = v.validate_customer_address_others(
     )
     return validated_customer_address_others
Exemple #2
0
 def get_customer_address_street_and_number():
     customer_address_street_and_number = input(
         "Enter the customer's street and street number: ")
     v = Validators(customer_address_street_and_number)
     validated_customer_address_street_and_number = v.validate_customer_address_street_and_number(
     )
     return validated_customer_address_street_and_number
Exemple #3
0
    def post(self):
        """User can login"""

        request_data = Login.parser.parse_args()

        username = request_data['username']
        password = request_data['password']

        if not Validators().valid_username(username):
            return {'message': 'enter a valid username'}, 401

        if not Validators().valid_password(password):
            return {'message': 'Enter a valid password'}, 401

        user = User().get_user_by_username(username)
        if not user:
            return {'message': 'user does not exist'}, 404
        if not check_password_hash(user.password, password):
            return {
                'message': 'Invalid password, enter the correct password'
            }, 401

        return {'message': f'successfully logged in as {user.username}'}
Exemple #4
0
    def post(self):
        """User can signup"""

        request_data = SignUp.parser.parse_args()
        fname = request_data['first_name']
        lname = request_data['last_name']
        username = request_data['username']
        email = request_data['email']
        password = request_data['password']
        confirm_password = request_data['confirm_password']

        if not Validators().valid_fname(first_name):
            return {'message': 'enter a valid first_name'}, 401

        if not Validators().valid_lname(last_name):
            return {'message': 'enter a valid last_name'}, 401

        if User().get_user_by_username(username):
            return {"message": f"User with username {username} already exists"}

        if not Validators().valid_username(username):
            return {'message': 'enter a valid username'}, 401

        if not Validators().valid_email(email):
            return {"message": "Enter a valid email"}, 401

        if not Validators().valid_password(password):
            return {'message': 'Enter a valid password'}, 401

        if password != confirm_password:
            return {'message': 'passwords do not match'}, 200

        user = User(first_name, last_name, username, email, password,
                    confirm_password)
        users.append(user)

        return {'message': f'Account for {username} created successfully'}, 201
Exemple #5
0
 def get_appointment_duration(self):
     appointment_duration = input(
         "Enter the Appointment's duration (HH:MM-HH:MM): ")
     v = Validators(appointment_duration)
     validated_appointment_duration = v.validate_appointment_duration()
     return validated_appointment_duration
Exemple #6
0
 def get_appointment_day():
     appointment_day = input("Enter the appointment's day: ")
     v = Validators(appointment_day)
     validated_appointment_day = v.validate_appointment_day()
     return validated_appointment_day
Exemple #7
0
 def get_customer_id():
     customer_id = input("Enter the customer's ID: ")
     v = Validators(customer_id)
     validated_customer_id = v.validate_customer_id()
     return validated_customer_id
Exemple #8
0
 def get_customer_address_state():
     customer_address_state = input("Enter the customer's state: ")
     v = Validators(customer_address_state)
     validated_customer_address_state = v.validate_customer_adress_state()
     return validated_customer_address_state
Exemple #9
0
 def get_customer_address_city():
     customer_address_city = input("Enter the customer's city: ")
     v = Validators(customer_address_city)
     validated_customer_address_city = v.validate_customer_adress_city()
     return validated_customer_address_city
Exemple #10
0
 def get_customer_forename():
     customer_forename = input("Enter the customer's forename: ")
     v = Validators(customer_forename)
     validated_customer_forename = v.validate_customer_forename()
     return validated_customer_forename
Exemple #11
0
 def get_customer_personal_id():
     customer_personal_id = input("Enter the customer's ID number: ")
     v = Validators(customer_personal_id)
     validated_customer_personal_id = v.validate_customer_personal_id()
     return validated_customer_personal_id
Exemple #12
0
 def get_customer_birthday():
     customer_birthdate = input(
         "Enter the customer's birthday (DD-MM-YYYY): ")
     v = Validators(customer_birthdate)
     validated_customer_birthday = v.validate_customer_birthdate()
     return validated_customer_birthday
Exemple #13
0
 def get_user_input(self, CHOOSE_OPTION_TEXT, VALID_OPTIONS):
     user_input = input(CHOOSE_OPTION_TEXT)
     v = Validators(user_input)
     self.validated_user_input = v.validate_selected_input(
         VALID_OPTIONS, CHOOSE_OPTION_TEXT)
     print("")
 def remove_customer_from_registry_by_index(self, max_range):
     inputed_customer_index = input(
         "Enter the id of the customer to be removed: ")
     v = Validators(inputed_customer_index)
     validated_customer_index = v.validate_customer_index(max_range)
     return validated_customer_index