Exemple #1
0
def ugsave_changes(equipment, form, new=False):
    """
    Save the changes to the database
    """
    # Get data from form and assign it to the correct attributes
    # of the SQLAlchemy table object
    equipment.itemcode = form.itemcode.data
    equipment.masterref = form.masterref.data
    #equipment.chkdate=form.chkdate.data
    equipment.chkdate = Date  #automatic check date update
    equipment.calibby = form.calibby.data
    equipment.remarks = form.remarks.data
    #equipment.nextcalib=form.nextcalib.data
    equipment.nextcalib = equipment.chkdate + timedelta(
        days=int(equipment.calibby)
    )  #auto nextcalib date update ,calibby is freaquency
    equipment.gmajd1 = form.gmajd1.data
    equipment.ngmajd1 = form.ngmajd1.data
    equipment.geffd1 = form.geffd1.data
    equipment.ngeffd1 = form.ngeffd1.data
    equipment.gpitd1 = form.gpitd1.data
    equipment.ngpitd1 = form.ngpitd1.data
    equipment.gmajd2 = form.gmajd2.data
    equipment.ngmajd2 = form.ngmajd2.data
    equipment.geffd2 = form.geffd2.data
    equipment.ngeffd2 = form.ngeffd2.data
    equipment.gpitd2 = form.gpitd2.data
    equipment.ngpitd2 = form.ngpitd2.data

    if new:
        # Add the new album to the database
        db_session.add(equipment)

    # commit the data to the database
    db_session.commit()
Exemple #2
0
def save_changes(album, form, new=False):

    if new:
        # Add the new album to the database
        form_data = dict((key, request.form.get(key)) for key in request.form.keys())
        a = object_as_dict(album)
        form_data["name"] = configuration_type(form_data)
        for key in set(form_data) & set(a):
            a[key] = form_data[key]
        for key, value in a.items():
            setattr(album, key, value)

        db_session.add(album)
    else:

        form_data = dict((key, request.form.get(key)) for key in request.form.keys())
        a = object_as_dict(album)
        form_data["name"] = configuration_type(form_data)
        for key in set(form_data) & set(a):
            a[key] = form_data[key]
        qry3 = db_session.query(Album).get(a["id"])

        for key, value in a.items():
            setattr(qry3, key, value)
        
    # commit the data to the database
    db_session.commit()
Exemple #3
0
def save_changes(rooms, form, new=False):
    """
    Save the changes to the database
    """
    # Get data from form and assign it to the correct attributes
    # of the SQLAlchemy table object
    buildings = Buildings()
    buildings.buildingName = form.buildingName.data
    buildings.address = form.address.data
    buildings.l1 = form.l1.data
    buildings.l2 = form.l2.data
    buildings.l3 = form.l3.data

    rooms.buildings = rooms
    rooms.flatno = form.flatno.data
    rooms.rent = form.rent.data
    rooms.area = form.area.data
    #rooms.bathrooms = form.bathrooms.data
    rooms.electricity = form.electricity.data
    rooms.maintain = form.maintain.data

    if new:
        # Add the new album to the database
        db_session.add(rooms)
        db_session.add(buildings)

    # commit the data to the database
    db_session.commit()
Exemple #4
0
def save_changes(table_name, base_table, form, new=False):
    """
    Save the changes to the database
    """
    # Get data from form and assign it to the correct attributes
    # of the SQLAlchemy table object
    if table_name == 'type':
        base_table.description = form.description.data
        base_table.protocol = form.protocol.data
    elif table_name == 'instrument':
        base_table.description = form.description.data
        base_table.serial = form.serial.data
        base_table.type_id = form.type_id.data
        base_table.macaddress = form.macaddress.data
        base_table.ipaddress = form.ipaddress.data
        base_table.params = form.params.data
        base_table.status = form.status.data
    elif table_name == 'location':
        base_table.description = form.description.data
        base_table.shortname = form.shortname.data
        base_table.instrument_id = form.instrument_id.data
        base_table.status = form.status.data

    if new:
        # Add the new type to the database
        db_session.add(base_table)

    # commit the data to the database
    db_session.commit()
Exemple #5
0
def plano_new():
    if request.method == 'GET':
        return render_template('plano_new.html')
    if request.method == 'POST':
        form = plano_form(request.form)
        db_session.add(plano_convert(plano(), form))
        db_session.commit()
        return redirect('/plano_list')
Exemple #6
0
def register():
    form = CategoryForm(request.form)
    if request.method == 'POST' and form.validate():
        # auto generate category id in betwen 10 - 20000
        category = Category(randint(10, 20000), form.name.data)
        db_session.add(category)
        return redirect('/home')
    return render_template('category_create.html', form=form)
Exemple #7
0
def sheetnew():
    form = SheetsForm(request.form)
    if request.method == 'POST' and form.validate():
        sheet = SheetsConvert(Sheets(), form)
        db_session.add(sheet)
        db_session.commit()
        flash('created successfully!')
        return redirect('/sheetlist')
    return render_template('sheetform.html', form=form)
Exemple #8
0
def projectnew():
    form = ProjectsForm(request.form)
    if request.method == 'POST' and form.validate():
        project = ProjectsConvert(Projects(), form)
        db_session.add(project)
        db_session.commit()
        flash('created successfully!')
        return redirect('/projectlist')
    return render_template('projectform.html', form=form)
Exemple #9
0
def foldernew():
    form = FoldersForm(request.form)
    if request.method == 'POST' and form.validate():
        folder = FoldersConvert(Folders(), form)
        db_session.add(folder)
        db_session.commit()
        flash('created successfully!')
        return redirect('/folderlist')
    return render_template('folderform.html', form=form)
Exemple #10
0
def floorplannew():
    form = FloorplansForm(request.form)
    if request.method == 'POST' and form.validate():
        floorplan = FloorplansConvert(Floorplans(), form)
        db_session.add(floorplan)
        db_session.commit()
        flash('created successfully!')
        return redirect('/floorplanlist')
    return render_template('floorplanform.html', form=form)
Exemple #11
0
def attachmentnew():
    form = AttachmentsForm(request.form)
    if request.method == 'POST' and form.validate():
        attachment = AttachmentsConvert(Attachments(), form)
        db_session.add(attachment)
        db_session.commit()
        flash('created successfully!')
        return redirect('/attachmentlist')
    return render_template('attachmentform.html', form=form)
Exemple #12
0
def save_entry(raw_grid, move_str, time):
    m_moves = MarioMoves()
    m_moves.id = datetime.datetime.now()
    m_moves.grid = raw_grid
    m_moves.moves = move_str
    m_moves.time = time

    db_session.add(m_moves)
    db_session.commit()
Exemple #13
0
def save_changes(userdata, form, new=False):

    userdata.username = form.username.data
    userdata.password = form.password.data

    if new:

        db_session.add(userdata)

    db_session.commit()
Exemple #14
0
def funcrandom():
    fake = Faker()
    for i in range(300):
        datedata = fake.date_between(start_date='-1y', end_date='today')
        nodata = random.randint(1,500)
        codebaseobject = Codebase()
        codebaseobject.date = datedata
        codebaseobject.code_count = nodata
        db_session.add(codebaseobject)
        db_session.commit()
Exemple #15
0
def save_item(item, form, new=True):
    item.product = form.product.data
    item.seller = form.seller.data
    item.price = form.price.data
    item.quantity = True

    if new:
        db_session.add(item)

    db_session.commit()
Exemple #16
0
def save_spe(spend, form, new=False):

	spend.date = form.date.data
	spend.value = form.value.data
	spend.item = form.item.data

	if new:
		db_session.add(spend)			        

	db_session.commit()
Exemple #17
0
def save_changes(stats, form, new=False):
  company = Company()
  company.name = form.company.data

  stats.company = company
  stats.board = form.board.data
  stats.ticker = form.ticker.data #Name
  if new:
    db_session.add(stats)

  db_session.commit()
Exemple #18
0
def save_changes(produto, form, new=False):
    #gravar os dados do formulario na base de dados criada
    #utilizar os dados do formulario e atribuilos aos cmapos correspondentes da base de dados
    produto.nome = form.nome.data
    produto.preco = form.preco.data
    produto.quantidade = form.quantidade.data

    if new:
        #adiciona o novo produto a base de dados
        db_session.add(produto)
    db_session.commit()
Exemple #19
0
def save_product(product, form, new=True):
    product.name = form.name.data.lower()
    product.category = form.category.data.lower()
    product.width = form.width.data
    product.height = form.height.data
    product.length = form.length.data
    product.weight = form.weight.data

    if new:
        db_session.add(product)

    db_session.commit()
Exemple #20
0
def save_res(reservation, form, new=False):

	reservation.room = form.room.data
	reservation.checkin = form.checkin.data
	reservation.checkout = form.checkout.data
	reservation.value = form.value.data
	reservation.client = form.client.data

	if new:
		db_session.add(reservation)			        

	db_session.commit()
Exemple #21
0
def save_user(user, form, new=True):
    user.name = form.name.data
    user.street = form.street.data
    user.city = form.city.data
    user.state = form.state.data
    user.country = form.country.data
    user.user_type = form.user_type.data

    if new:
        db_session.add(user)

    db_session.commit()
Exemple #22
0
def add():
    if request.method == "GET":
        course_num = request.args['courseNum']
        return render_template("addAssignment.html", course_num=course_num)

    name = request.form.get('assignment')
    course_num = request.form.get('courseNum')
    newAssignment = Assignment(name=name, class_id=course_num)
    db_session.add(newAssignment)
    db_session.commit()
    db_session.add(Grade(grade=0, assignment_id=newAssignment.id))
    db_session.commit()
    return redirect(url_for('search', courseNum=course_num))
Exemple #23
0
def save_changes(hotel, form):
    """
    Save the changes to the database
    """
    hotel.pname = form.pname.data
    hotel.hsr_layout = form.hsr_layout.data
    hotel.location = form.location.data
    hotel.cordinates = form.cordinates.data
    hotel.s_room = form.s_room.data
    hotel.p_room = form.p_room.data

    db_session.add(hotel)
    db_session.commit()
Exemple #24
0
def save_changes(article_info, form, new=False):

    article = Article()
    article.name = form.article.data

    article_info.article = article
    article_info.url = form.url.data
    article_info.release_date = form.release_date.data
    article_info.publisher = form.publisher.data

    if new:
        db_session.add(article_info)
    db_session.commit()
Exemple #25
0
def save_changes(booksdb,form,new=False):
	booksdb.book_title = form.book_title.data
	booksdb.book_type  =form.book_type.data
	booksdb.authors  = form.authors.data
	booksdb.UID  = form.UID.data
	booksdb.publisher  = form.publisher.data
	booksdb.publish_date= form.publish_date.data
	booksdb.edition  = form.edition.data
	booksdb.binding= form.binding.data

	if new :
		db_session.add(booksdb)

	db_session.commit()
Exemple #26
0
def book():
    form = BookForm(request.form)
    print(form)
    catgories = db_session.query(Category).all()
    # create category list
    catgories_list = [(category.id, category.name) for category in catgories]
    form.category.choices = catgories_list
    if request.method == 'POST' and form.validate():
        # auto generate category id in bettwen 10 - 20000
        book = Book(randint(10, 20000), form.category.data, form.name.data,
                    form.author.data, form.price.data, form.description.data,
                    form.image.data)
        db_session.add(book)
        return redirect('/home')
    return render_template('book_create.html', form=form)
def new_product():
    # add a new product
    form = ProductForm(request.form)

    if request.method == 'POST' and form.validate():
        # saving new product
        product = Master()
        save_changes(product, form, new=True)
        file = request.files['inputFile']
        newFile = FileContents(name=file.filename, data=file.read())
        db_session.add(newFile)
        db_session.commit()
        flash('New product added successfully!')
        return redirect('/')

    return render_template('new_product.html', form=form)
Exemple #28
0
def save_changes(data):
    """
    Save the changes to the database
    """
    # import pdb; pdb.set_trace()
    qry = db_session.query(Codebase).filter(Codebase.date==data)
    qry = qry.first()
    if qry:
        qry.code_count += 1
        db_session.commit()
        return "ok"
    
    codebaseobject = Codebase()
    codebaseobject.code_count = 1
    db_session.add(codebaseobject)
    db_session.commit()
    return "ook"
Exemple #29
0
def save_changes(album, form, new=False):
    """ Save the changes to the database """
    # Get data from form and assign it to the correct attributes
    # of the SQLAlchemy table object
    artist = Artist()
    artist.name = form.artist.data

    album.artist = artist
    album.title = form.title.data
    album.release_date = form.release_date.data
    album.publisher = form.publisher.data
    album.media_type = form.media_type.data

    if new:
        # Add the new album to the database
        db_session.add(album)

    db_session.commit()
Exemple #30
0
def save_changes(bin, form, new=False):
    """
    Save the changes to the database
    """
    # Get data from form and assign it to the correct attributes
    # of the SQLAlchemy table object
    tool = Tool()
    tool.name = form.partnumber.data

    bin.partnumber = tool
    bin.location = form.location.data

    if new:
        # Add the new album to the database
        db_session.add(bin)

    # commit the data to the database
    db_session.commit()