Exemplo n.º 1
0
def create_user_request():
    error = None
    if not validUserRequest(request):
        error = 'Invalid data entered'
        print('invalid data entered')
        return render_template('signup.html', error=error)

    name = request.form['inputName']
    password = request.form['inputPassword']
    password2 = request.form['inputPassword2']
    user_company = request.form['inputCompanyName']
    phone = request.form['inputPhone']
    email = request.form['inputEmail']
    streetAddress1 = request.form['inputStreetAddress1']
    streetAddress2 = request.form['inputStreetAddress2']
    city = request.form['inputCity']
    state = request.form['inputState']
    country = request.form['inputCountry']
    postal = request.form['inputZip']

    if not checkEmailAvailable(request):
        error = 'Sorry, that email is already taken'
        return render_template('signup.html',  retUserName=name, retCompany=user_company, \
            retEmail=email, retPhone=phone, retStreet1=streetAddress1, retStreet2=streetAddress2, \
            retCity=city, retState=state, retZip=postal, retCountry=country, error=error)
    
    uid = str(uuid.uuid4())
    
    if password == password2:
        u = User(uid, name, email, password, user_company, phone, streetAddress1, \
            streetAddress2, city, state, postal, country)

        db_session.add(u)
        db_session.commit()

        #result = send(None, email, "Registration Confirmation", "Thanks for registering with MyServiceCompany.com")
        result = 1
        
        if(result != 1):
            #couldn't send email
            print("error when sending email: " + result)
        else:
            session['logged_in'] = True
            session['user_id'] = uid
            session['user_name'] = User.query.filter_by(id=uid).first().name
            return redirect(url_for('new_service_request'))
    else:
        #print('unsuccessful add')
        error="passwords do not match"
        return render_template('signup.html', retUserName=name, retCompany=user_company, \
            retEmail=email, retPhone=phone, retStreet1=streetAddress1, retStreet2=streetAddress2, \
            retCity=city, retState=state, retZip=postal, retCountry=country, error=error)
Exemplo n.º 2
0
def saveRequest(request):
    ticket = request.get_data().decode('utf-8')
    reporter = session.get('user_id')
    
    if not reporter:
        return None
    
    if not (ticket is None):
        i = str(uuid.uuid4())
        jticket = json.loads(ticket)
        t = Ticket(i, reporter, jticket['type'], jticket['quantity'], jticket['pm'], jticket['desc'], \
        jticket['timeframe'], jticket['date_requested'], 1)

        db_session.add(t)
        db_session.commit()

    return t
Exemplo n.º 3
0
def create_customer_request():
    if not session.get('logged_in'):
        abort(401)

    error = None
    if not validCustomerAdd(request):
        error = 'Invalid data entered'
        return render_template('new_customer.html', error=error)

    companyName = request.form['inputCompanyName']
    customerType = request.form['inputCustomerType']
    customerLastName = request.form['inputCustomerLastName']
    customerFirstName = request.form['inputCustomerFirstName']
    phone1 = request.form['inputCustomerPhone1']
    phone2 = request.form['inputCustomerPhone2']
    fax = request.form['inputCustomerFax']
    webAddy = request.form['inputCustomerWebsite']
    email = request.form['inputCustomerEmail']
    streetAddress1 = request.form['inputCustomerAddress1']
    streetAddress2 = request.form['inputCustomerAddress2']
    city = request.form['inputCustomerCity']
    state = request.form['inputCustomerState']
    postal = request.form['inputCustomerZip']
    country = request.form['inputCustomerCountry']
    streetAddress1Bill = request.form['inputCustomerBillAddress1']
    streetAddress2Bill = request.form['inputCustomerBillAddress2']
    cityBill = request.form['inputCustomerBillCity']
    stateBill = request.form['inputCustomerBillState']
    postalBill = request.form['inputCustomerBillZip']
    countryBill = request.form['inputCustomerBillCountry']

    i = str(uuid.uuid4())
    user_ID = session['user_id']

    c = Customer(i, user_ID, customerType, companyName, customerLastName, customerFirstName, email, \
        phone1, phone2, fax, webAddy, streetAddress1, streetAddress2, city, state, postal, country, \
        streetAddress1Bill, streetAddress2Bill, cityBill, stateBill, postalBill, countryBill)

    db_session.add(c)
    db_session.commit()

    flash('New customer was successfully added')
    return redirect(url_for('home'))
Exemplo n.º 4
0
def saveRequest(request):
    ticket = request.get_data().decode('utf-8')
    reporter = session.get('user_id')

    if not reporter:
        return None

    if not (ticket is None):
        i = str(uuid.uuid4())
        jticket = json.loads(ticket)

        contract = 1 if (jticket['pm'] == 'on') else 0
        t = Ticket(i, reporter, jticket['type'], jticket['quantity'], contract, jticket['desc'], \
        jticket['timeframe'], jticket['date_requested'], 1)

        db_session.add(t)
        db_session.commit()

    return t
Exemplo n.º 5
0
def create_customer_request():
    if not session.get('logged_in'):
        abort(401)

    error = None
    if not validCustomerAdd(request):
        error = 'Invalid data entered'
        return render_template('new_customer.html', error=error)

    companyName = request.form['inputCompanyName']
    customerType = request.form['inputCustomerType']
    customerLastName = request.form['inputCustomerLastName']
    customerFirstName = request.form['inputCustomerFirstName']
    phone1 = request.form['inputCustomerPhone1']
    phone2 = request.form['inputCustomerPhone2']
    fax = request.form['inputCustomerFax']
    webAddy = request.form['inputCustomerWebsite']
    email = request.form['inputCustomerEmail']
    streetAddress1 = request.form['inputCustomerAddress1']
    streetAddress2 = request.form['inputCustomerAddress2']
    city = request.form['inputCustomerCity']
    state = request.form['inputCustomerState']
    postal = request.form['inputCustomerZip']
    country = request.form['inputCustomerCountry']
    streetAddress1Bill = request.form['inputCustomerBillAddress1']
    streetAddress2Bill = request.form['inputCustomerBillAddress2']
    cityBill = request.form['inputCustomerBillCity']
    stateBill = request.form['inputCustomerBillState']
    postalBill = request.form['inputCustomerBillZip']
    countryBill = request.form['inputCustomerBillCountry']

    i = str(uuid.uuid4())
    user_ID =  session['user_id']

    c = Customer(i, user_ID, customerType, companyName, customerLastName, customerFirstName, email, \
        phone1, phone2, fax, webAddy, streetAddress1, streetAddress2, city, state, postal, country, \
        streetAddress1Bill, streetAddress2Bill, cityBill, stateBill, postalBill, countryBill)

    db_session.add(c)
    db_session.commit()

    flash('New customer was successfully added')
    return redirect(url_for('home'))