Пример #1
0
def deploy():
    import finaldata as fd
    db.drop_all()
    db.create_all()

    Country.insertCountries(fd.getCountries())
    City.insertCities(fd.getCities())
    Type.insertTypes(fd.getTypes())
    Museum.insertMuseums(fd.getMuseums())
    Period.insertPeriods(fd.getPeriods())
Пример #2
0
def seed_types():

    type1 = Type(type="Distance Driver")
    type2 = Type(type="Midrange")
    type3 = Type(type="Putter")

    db.session.add(type1)
    db.session.add(type2)
    db.session.add(type3)

    db.session.commit()
Пример #3
0
def seed_types(user_list):
    type_list = [
        Type(owner=user_list[0].id, name="Book"),
        Type(owner=user_list[0].id, name="Movie"),
        Type(owner=user_list[0].id, name="Music")
    ]

    db.session.add_all(type_list)

    db.session.commit()
    return type_list
Пример #4
0
def seed_types():

    photographer = Type(title="Photographer")
    oncameraClass = Type(title="On camera class")
    school = Type(title="Acting School")
    sceneStudy = Type(title="Scene Study")

    db.session.add(photographer)
    db.session.add(oncameraClass)
    db.session.add(school)
    db.session.add(sceneStudy)

    db.session.commit()
Пример #5
0
def addtype():
    type=request.form.get('type')
    try:
        t=Type(name=type)
        db.session.add(t)
        db.session.commit()
        return jsonify({'singal':1})
    except:
        return '添加失败'
Пример #6
0
def get_or_create_type(data):
    session = db_session()
    t = session.query(Type).filter_by(name=data).first()
    if not t:
        new_type = Type(name=data)
        session.add(new_type)
        session.commit()
        session.expunge_all()
        session.close()
        return new_type
    session.expunge_all()
    session.close()
    return t
Пример #7
0
def add():
    if request.method == 'POST':
        name = request.form['name']
        image = request.form['image']
        if not name:
            flash('请输入类型名称')
            return redirect(request.referrer)

        type = Type(name=name, image=image)
        db.session.add(type)
        db.session.commit()
        flash('新增成功')
        return redirect('/admin/type')

    return render_template('admin/type/add.html')
Пример #8
0
def addtype():
    if request.method == "GET":
        return render_template('addtype.html')
    else:
        # 接收数据
        # typeid=request.form.get('typeid')
        typename = request.form.get('typename')
        # 验证数据
        if not all([typename]):
            msg = "数据不完整"
            return render_template('addtype.html', msg=msg)
        type1 = Type.query.filter_by(name=typename).first()
        if type1:
            msg = "改项目类别已存在"
            return render_template('addtype.html', msg=msg)
        # 存储数据
        type = Type(name=typename)
        db.session.add(type)
        db.session.commit()
        return render_template('addtype.html')
Пример #9
0
def departments():
    form1 = DepartmentRegistrationForm()
    form2 = TypeRegistrationForm()
    if form1.validate_on_submit():
        department_name = Department(name=form1.dept_name.data)
        db.session.add(department_name)
        db.session.commit()
        return redirect(url_for('departments'))
    if form2.validate_on_submit():
        type_name = Type(name=form2.type_name.data)
        db.session.add(type_name)
        db.session.commit()
        return redirect(url_for('departments'))
    departments = Department.query.order_by(Department.name.asc()).all()
    types = Type.query.order_by(Type.name.asc()).all()
    return render_template('inventory_management/departments.html',
                           title='Departments',
                           form1=form1,
                           form2=form2,
                           departments=departments,
                           types=types)
Пример #10
0
def seed_types():

    type_1 = Type(name="Kitchen")
    type_2 = Type(name="Office")
    type_3 = Type(name="Bathroom")
    type_4 = Type(name="Closet")
    type_5 = Type(name="Laundry")
    type_6 = Type(name="Miscellaneous")

    db.session.add(type_1)    
    db.session.add(type_2)    
    db.session.add(type_3)    
    db.session.add(type_4)    
    db.session.add(type_5)    
    db.session.add(type_6)    
    
    db.session.commit()       
Пример #11
0
import os
from app.models import Type
from app.engines import db

FILE_PATH = os.path.dirname(os.path.dirname(
    os.path.dirname(__file__))) + '/app/resources/' + 'booktype.txt'

tag_list = []
with open(FILE_PATH, 'r') as f:
    for line in f:
        tag_list.append(line.strip())

for tag in tag_list:
    type = Type()
    type.title = tag
    db.session.add(type)

db.session.commit()
Пример #12
0
def seed_types():

    type1 = Type(name='Normal')
    type2 = Type(name='Fire')
    type3 = Type(name='Water')
    type4 = Type(name='Electric')
    type5 = Type(name='Grass')
    type6 = Type(name='Ice')
    type7 = Type(name='Fighting')
    type8 = Type(name='Poison')
    type9 = Type(name='Ground')
    type10 = Type(name='Flying')
    type11 = Type(name='Psychic')
    type12 = Type(name='Bug')
    type13 = Type(name='Rock')
    type14 = Type(name='Ghost')
    type15 = Type(name='Dragon')
    type16 = Type(name='Dark')
    type17 = Type(name='Steel')
    type18 = Type(name='Fairy')

    db.session.add(type1)
    db.session.add(type2)
    db.session.add(type3)
    db.session.add(type4)
    db.session.add(type5)
    db.session.add(type6)
    db.session.add(type7)
    db.session.add(type8)
    db.session.add(type9)
    db.session.add(type10)
    db.session.add(type11)
    db.session.add(type12)
    db.session.add(type13)
    db.session.add(type14)
    db.session.add(type15)
    db.session.add(type16)
    db.session.add(type17)
    db.session.add(type18)

    db.session.commit()
Пример #13
0
    print('{} items added'.format(len(items)))


# initialise db and create tables
engine = create_pg_engine()
Base.metadata.create_all(engine)
Base.metadata.bind = engine

# populate db with sample data
users = [
    User(email='*****@*****.**'),
    User(email='*****@*****.**')
]

types = [
    Type(name='Blue cheese', description='moldy and good', user_id=1),
    Type(name='Brown cheese', description='fudgy and weird', user_id=1),
    Type(name='Hard cheese', description='Yellow and gnarly', user_id=1),
    Type(name='Washed-rind cheese', description='White and runny', user_id=1),
]

milks = [
    Milk(name='cow', user_id=1),
    Milk(name='goat', user_id=1),
    Milk(name='ewe', user_id=1)
]

cheeses = [
    Cheese(name='Stilton', type_id=1, milk_id=1, user_id=1),
    Cheese(name='Gudbrandsdalsost', type_id=2, milk_id=2, user_id=2),
    Cheese(name='Cheddar', type_id=3, milk_id=1, user_id=1),
Пример #14
0
from app import db
from app.models import Type, Frequency, UeModel, Board

db.create_all()
Type.insert_types()
Frequency.insert_frequency()
UeModel.insert_models()
Board.insert_models()


Пример #15
0
def typeAdd():
    data = request.json
    type = Type(title=data['title'])
    db.session.add(type)
    db.session.commit()
    return type.to_dict()
Пример #16
0
from app import db, create_app
from app.models import Report, Severity, Type

app = create_app()
app_context = app.app_context()
app_context.push()

s1 = Severity(name="high", description="you better call someboday!", weight=5)
s2 = Severity(name="low", description="not a big deal", weight=1)

t1 = Type(name="fire", description="something's burning!")
t2 = Type(name="flood", description="too much water!")

db.session.bulk_save_objects([s1, s2, t1, t2])
db.session.commit()

r1 = Report()
r1.from_dict({
    'latitude': 34.226,
    'longitude': -77.925,
    'guid': 'askjdh12436123',
    'type': 'fire',
    'severity': 'high'
})

r2 = Report()
r2.from_dict({
    'latitude': 34.226,
    'longitude': -77.90,
    'guid': 'xyzhdgaffffffff',
    'type': 'flood',