예제 #1
0
def createCompany(login_session):
    newCompany = Company(name=login_session['username'],
                         email=login_session['email'],
                         picture=login_session['picture'])
    session.add(newCompany)
    session.commit()
    company = session.query(Company).filter_by(
        email=login_session['email']).one()
    return company.id
예제 #2
0
def newCompany():
    if 'username' not in login_session:
        return redirect('/login')
    if request.method == 'POST':
        newcompany = Company(name=request.form['name'])
        session.add(newcompany)
        session.commit()
        flash("new Company created!")
        return redirect(url_for('menuCompany'))
    else:
        return render_template('newCompany.html')
예제 #3
0
def create_new_company():
    if 'username' not in login_session:
        return render_template("login.html", login=False)
    if request.method == 'POST':
        new_company = Company(name=request.form['name'],
                              slogan=request.form['slogan'],
                              user_id=login_session['user_id'])
        session.add(new_company)
        session.commit()
        flash('New Company %s Successfully Created' % new_company.name)
        return redirect(url_for('get_all_companies'))
    else:
        return render_template("newcompany.html", login=True)
def newCompany():
    if 'username' not in login_session:
        flash("You need to login first")
        return redirect('/login')
    if request.method == 'POST':
        newCompany = Company(name=request.form['Name'],
                             user_id=login_session['user_id'])
        session.add(newCompany)
        flash('New Company %s Created' % newCompany.name)
        session.commit()
        return redirect(url_for('showCompany'))
    else:
        return render_template('newCompany.html')
def addNewCategory():
    if request.method == 'POST':
        if request.form['submit'] == 'Create':
            newCategory = Company(name=request.form['Company_name'],
                                  user_id=login_session['userid'])
            Session.add(newCategory)
            Session.commit()
            flash("New category has been added successfully")
            return redirect(url_for('showCatalog'))
        else:
            return redirect(url_for('showCatalog'))
    else:
        return render_template('newCategory.html')
예제 #6
0
def newCompany():
    session2 = DBSession()
    if 'username' not in login_session:
        return redirect('/login')
    if request.method == 'POST':
        newCompany = Company(name=request.form['name'])
        session2.add(newCompany)
        session2.commit()
        session2.close()
        return redirect(url_for('showCompanies'))
    else:
        session2.close()
        return render_template('newCompany.html')
예제 #7
0
def newcompany():
    if 'username' not in login_session:
        return redirect('/login')
    if request.method == 'POST':
        newcompany = Company(
            name=request.form['name'], user_id=login_session['user_id'],
            description=request.form['Description'], pic=request.form['pic'])
        session.add(newcompany)
        flash('New company %s Successfully Created' % newcompany.name)
        session.commit()
        return redirect(url_for('showcompanys'))
    else:
        return render_template('newcompany.html')
예제 #8
0
def newCompany():
    if 'username' not in login_session:
        return redirect('/login')
    if request.method == 'POST':
        newCompany = Company(name=request.form['name'],
                             email=login_session['email'],
                             picture=login_session['picture'])
        session.add(newCompany)
        flash('New Company %s Successfully Created' % newCompany.name)
        session.commit()
        return redirect(url_for('showCompanies'))
    else:
        return render_template('newCompany.html')
예제 #9
0
def newCompany():
    session = DBSession()
    if 'username' not in login_session:
        return redirect('/login')
    if request.method == 'POST':
        newThing = Company(name=request.form['name'],
                           user_id=login_session['user_id'])
        session.add(newThing)
        flash('New Thing %s Successfully Created' % newThing.name)
        session.commit()
        session.close()
        return redirect(url_for('showCompany'))
    else:
        return render_template('newCompany.html')
예제 #10
0
def addCompany():
    if 'username' not in login_session:
        return redirect('/login')
    if request.method == 'POST':
        newCompany = Company(name=request.form['name'],
                             location=request.form['location'],
                             user_id=login_session['user_id'])
        session.add(newCompany)
        session.commit()
        flash(
            newCompany.name +
            " successfully created!  Check your company page to add available items."
        )
        return redirect(url_for('showCompanies'))
    else:
        return render_template('addCompany.html')
예제 #11
0
def newCompany():
    if 'username' not in login_session:
        return redirect('/login')
    if request.method == 'POST':
        file = request.files['image']
        if os.path.exists("static/" + file.filename):
            return "File already exist rename the file/select another image!"
        else:
            f = os.path.join(app.config['UPLOAD_FOLDER'], file.filename)
            # add your custom code to check that the uploaded file is a \
            # valid image and not a malicious file (out-of-scope for this post)
            file.save(f)
            company = Company(name=request.form['name'],
                              user_id=login_session['user_id'],
                              picture="/static/" + file.filename)
            session.add(company)
            flash('New company %s Successfully Created' % company.name)
        return redirect(url_for('showCompany'))
    else:
        return render_template('newCompany.html')
예제 #12
0
def newCompany():
    """Add new company to the database

    Returns
      on GET: page that used to add company
      on POST: create new company in the database and redirect to /companies
    """
    if 'username' not in session:
        return redirect(
            url_for('login', error='You need to login to add company')
        )

    user = utils.get_user_by_email(session['email'], db_session)

    error = request.args.get('error', '')

    if request.method == 'POST':
        new_company_name = request.form.get('newCompany')

        if new_company_name is None or new_company_name == '':
            error = 'Please enter a valid company name'
        elif db_session.query(Company)\
                       .filter(Company.name == new_company_name).count() > 0:
            error = '%s already exists' % new_company_name
        else:
            new_company = Company(name=new_company_name, user_id=user.id)
            db_session.add(new_company)
            db_session.commit()

            return redirect(url_for('showCompanies'))

    all_companies = db_session.query(Company).all()

    return render_template(
        'new-company.html',
        all_companies=all_companies,
        error=error,
    )
예제 #13
0
# database session object. Any change made against the objects in the
# session won't be persisted into the database until you call
# session.commit(). If you're not happy about the changes, you can
# revert all of them back to the last commit by calling
# session.rollback()
session = DBSession()

# Create dummy user
User1 = User(
    name="priyaranjan reddy", email="*****@*****.**", picture='')
session.add(User1)
session.commit()


# Company 1
company1 = Company(name="Baskins Robins", user_id=1)
session.add(company1)
session.commit()


icecream1 = Icecream(
    user_id=1,
    name="Bavarian chocolate",
    description="qwerty",
    price='10',
    company=company1)
session.add(icecream1)
session.commit()


print "added menu items!"
예제 #14
0
DBSession = sessionmaker(bind=engine)
# A DBSession() instance establishes all conversations with the database
# and represents a "staging zone" for all the objects loaded into the
# database session object. Any change made against the objects in the
# session won't be persisted into the database until you call
# session.commit(). If you're not happy about the changes, you can
# revert all of them back to the last commit by calling
# session.rollback()
session = DBSession()
User1 = User(name="vyshnavi", email="*****@*****.**")
session.add(User1)
session.commit()


company1 = Company(user_id=1, name="Titan")
session.add(company1)
session.commit()
article1 = Article(user_id=1, name="Analog", description="ladies watch",
                   price="$60", type="belt", company=company1)

session.add(article1)
session.commit()

article2 = Article(user_id=1, name="Digital", description="boys watches",
                   type="chain", price="$80", company=company1)

session.add(article2)
session.commit()

article3 = Article(user_id=1, name="Chronograph",
예제 #15
0
# database session object. Any change made against the objects in the
# session won't be persisted into the database until you call
# session.commit(). If you're not happy about the changes, you can
# revert all of them back to the last commit by calling
# session.rollback()
session = DBSession()


# Create dummy user
User1 = User(name="gayathri", email="*****@*****.**",
             picture='https://pbs.twimg.com/profile_images/2671170543/18debd694829ed78203a5a36dd364160_400x400.png')
session.add(User1)
session.commit()

# Menu for UrbanBurger
restaurant1 = Company(user_id=1, name="LG")

session.add(restaurant1)
session.commit()

menuItem2 = Gadgets(user_id=1, name="Washing Machine", description="Long time ",
                     price="Rs.18900",item=restaurant1)

session.add(menuItem2)
session.commit()


menuItem1 = Gadgets(user_id=1, name="Television", description="32 inches",
                     price="Rs.14599",item=restaurant1)

session.add(menuItem1)
예제 #16
0
def insert_rows():
    data = get_company_info()
    print("Adding a company . . .")
    db_session = get_db_connection()

    companies_in_db = db_session.query(Company).\
                                    filter(Company.fair_id == FAIR_ID).all()

    companies_dict = {}

    # Construct {'name': 0 || 1} dictionary
    for c in companies_in_db:
        companies_dict[c.name] = 0

    for i, row in enumerate(data):
        name, url = row[0], row[4]
        companies_dict[name] = 1 if name in companies_dict else 0

        if row[1].strip().lower() == 'int':
            type = 1
        elif row[1].strip().lower() == 'ft':
            type = 2
        else:
            type = 3

        if row[3].strip().lower() == 'bs':
            degree = 1
        elif row[3].strip().lower() == 'ms':
            degree = 2
        elif row[3].strip().lower() == 'phd':
            degree = 3
        elif row[3].strip().lower() == 'bs, ms':
            degree = 4
        elif row[3].strip().lower() == 'bs, phd':
            degree = 5
        elif row[3].strip().lower() == 'ms, phd':
            degree = 6
        else:
            degree = 7

        if row[4].strip().lower() == 'yes':
            visa = 1
        elif row[4].strip().lower() == 'no':
            visa = 2
        else:
            visa = 3
        print(row)
        #_add_tables_temp(name, row[5], db_session)
        if companies_dict[name] == 1:
            print("WARNING: {}:{} already exists in our db.".format(
                i + 1, name))
            continue
        log_string = '''name:{}, type:{}, degree:{}, visa:{}, booth:{} url:{}
        '''.format(name, type, degree, visa, row[5], row[6])
        print("**ADDING: {}".format(log_string))
        company = Company(name=name,
                          hiring_types=type,
                          hiring_majors=row[2],
                          degree=degree,
                          visa=visa,
                          company_url=row[6],
                          fair_id=FAIR_ID,
                          description='')
        if not DEBUG:
            db_session.add(company)
            db_session.commit()
        _add_tables(name, row[5], db_session)
        companies_dict[name] = 1

    # delete not participating companies
    print('Seraching Companies that are no longer participating in ', FAIR_ID)
    for key, val in companies_dict.items():
        if val == 0:
            print('Deleting company {} on fair: {}'.format(key, FAIR_ID))
            c = db_session.query(Company).filter(Company.name == key).filter(
                Company.fair_id == FAIR_ID).one()

            t = db_session.query(CareerFairTable)\
                .filter(c.id == CareerFairTable.company_id)\
                .filter(c.fair_id == CareerFairTable.fair_id)\
                .all()
            for table in t:
                print('Deleting table {} on fair: {}'.format(
                    table.id, FAIR_ID))
                if not DEBUG:
                    db_session.delete(table)
            if not DEBUG:
                db_session.delete(c)
            db_session.commit()
    db_session.close()
# Create dummy user
User1 = User(name="mandar",
             email="*****@*****.**",
             picture="/static/mandar1.jpg")
session.add(User1)
session.commit()

User2 = User(name="Arun",
             email="*****@*****.**",
             picture="/static/blank_user.gif")
session.add(User2)
session.commit()

# Menu for UrbanBurger
company1 = Company(user_id=1, name="Mahindra Motors",\
 picture="/static/Mahindra-logo.png")

session.add(company1)
session.commit()

company2 = Company(user_id=1, name="Sweetlime ventures", \
picture="/static/sweetlime.png")

session.add(company2)
session.commit()


employee1 = Employee(user_id=1, name="Mandar Waghe", \
                     dob="17/12/1994",\
                     email="*****@*****.**", \
                     contact="8007528271", address="Thane",\
예제 #18
0
# declaratives can be accessed through a DBSession instance
Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)
# A DBSession() instance establishes all conversations with the database
# and represents a "staging zone" for all the objects loaded into the
# database session object. Any change made against the objects in the
# session won't be persisted into the database until you call
# session.commit(). If you're not happy about the changes, you can
# revert all of them back to the last commit by calling
# session.rollback()
session = DBSession()


# Create Company 1
Company1 = Company(name="Nasa", email="*****@*****.**",
                   picture='http://t0.gstatic.com/images?q=tbn:ANd9GcQ9u48pu-6IB2FnnYl_H-15le_g8Dkt5d5RN-VWiWIl_-dyJdaa')
session.add(Company1)
session.commit()

# Acheivment 1
acheivment1 = Acheivment(company_id=1, title="First step on moon",
                         description='''Apollo 11 was the spaceflight that
                         landed the first two people on the Moon. Mission
                         commander Neil Armstrong and pilot Buzz Aldrin, both
                         American, landed the lunar module Eagle on July 20,
                         1969, at 20:17 UTC. Armstrong became the first person
                         to step onto the lunar surface six hours after landing
                         on July 21 at 02:56:15 UTC; Aldrin joined him about 20
                         minutes later. They spent about two and a quarter
                         hours together outside the spacecraft, and collected
                         47.5 pounds (21.5 kg) of lunar material to bring back
from database_setup import Company, Base, Product, User

python engine = create_engine('postgresql://*****:*****@localhost/catalog')
Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)
session = DBSession()

#Create Dummy User
User1 = User(name="Abhay Jain", email="*****@*****.**",picture='''https://plus.google.com/u/0/photos/110581984025459992644/albums/profile/6417914292639670386?iso=false''')
session.add(User1)
session.commit()

# Products of Orient
company1 = Company(user_id=1, name="Orient")

session.add(company1)
session.commit()

prod2 = Product(user_id=1, name="Valeria", description="Premium 1500 mm 5 Blade fan with light",
                     price="Rs. 4750",categary="Decorative", company=company1)

session.add(prod2)
session.commit()


prod1 = Product(user_id=1, name="Adelia", description="Premium 1300 mm 5 Blade fan with light",
                     price="Rs. 4250",categary="Decorative", company=company1)

session.add(prod1)
# A DBSession() instance establishes all conversations with the database
# and represents a "staging zone" for all the objects loaded into the
# database session object. Any change made against the objects in the
# session won't be persisted into the database until you call
# session.commit(). If you're not happy about the changes, you can
# revert all of them back to the last commit by calling
# session.rollback()
session = DBSession()

# Create dummy user
ADMIN = User(name="admin", email="*****@*****.**")
session.add(ADMIN)
session.commit()

# Create dummy company
COMPANY_1 = Company(name="Fujifilm")
session.add(COMPANY_1)
session.commit()

COMPANY_2 = Company(name="Sony")
session.add(COMPANY_2)
session.commit()

COMPANY_3 = Company(name="Canon")
session.add(COMPANY_3)
session.commit()

# Create dummy camera
CAMERA_1 = Camera(
    name="X-T20",
    description="mirrorless interchangeable-lens camera announced"
예제 #21
0
Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)

session = DBSession()

'# Create a user : these data mentioned to real data of my email'
app_user = User(name="Faimah Al-Ibrahim",
                email="*****@*****.**",
                picture='https://lh4.googleusercontent.com/-hbKMNuV5Yd0/'
                'AAAAAAAAAAI/AAAAAAAAAAA/wSm7wWWkl4g/photo.jpg')
session.add(app_user)
session.commit()

'# Add First Categoy (HP company) with its items'
appCategory1 = Company(name="Hewlett-Packard (HP)", user_id=1)
session.add(appCategory1)
session.commit()

'# Add First Item Computer to HP'
appc1Item1 = Computers(name="HP 14-bp101nx",
                       description=("""This Device has set of specifications:\n
Processor Type: Intel Core i5-8250U
Operating System: Windows 10 - 64 bit
RAM: 8 GB
Capacity: 1 TB
Processor Speed : 1.6 GHz
Connectivity Technology: WiFi/Bluetooth
Touch Display : No
Display Size: 14 inch
Color : white
예제 #22
0
# session.commit(). If you're not happy about the changes, you can
# revert all of them back to the last commit by calling
# session.rollback()
session = DBSession()


# Create dummy user
User1 = User(name="Robo Barista", email="*****@*****.**",
             picture='https://pbs.twimg.com/profile_images/\
             2671170543/18debd694829ed78203a5a36dd364160_400x400.png')
session.add(User1)
session.commit()


# Menu for Company Toyota
company1 = Company(user_id=1, name="Toyota")
session.add(company1)
session.commit()

MenuCars1 = MenuCars(user_id=1, name="Yaris",
                     description="The Yaris is a sedan and wheel-drive type.",
                     price="45,900 SR", company=company1)
session.add(MenuCars1)
session.commit()

MenuCars2 = MenuCars(user_id=1, name="Rush",
                     description="Toyota Rush is a multi-use sports car.",
                     price="59,300 SR", company=company1)
session.add(MenuCars2)
session.commit()