Example #1
0
def equipment_delete(id):
    eqpm = Equipment.query.filter_by(id=id).first()
    if eqpm in current_user.get_equipment():
        db.session().delete(eqpm)
        db.session().commit()

    return redirect(url_for("index"))
Example #2
0
def prodct_removeSubcomponent(model_id, target_id):
    m = Product.query.get(model_id)
    t = Product.query.get(target_id)

    m.remove_ref(t)
    db.session().commit()
    return ('', 204)
Example #3
0
def equipment_break(id):
    eqpm = Equipment.query.filter_by(id=id).first()
    if eqpm in current_user.get_equipment():
        eqpm.isbroken = not eqpm.isbroken
        db.session().commit()

    return redirect(url_for("index"))
Example #4
0
def model_setEol(model_id):
    m = Product.query.get(model_id)

    if m.eol:
        m.eol = False
    else:
        m.eol = True
    db.session().commit()

    return redirect(url_for("models_index"))
Example #5
0
def manufacturers_create():
    form = ManufacturerForm(request.form)
    if not form.validate():
        return render_template(url_for('manufacturers_index'), form=form)

    t = Manufacturer(request.form.get("name"))
    db.session().add(t)
    db.session().commit()

    return redirect(url_for("manufacturers_index"))
Example #6
0
def auth_create():
    form = UserCreateForm(request.form)
    if form.validate_on_submit():
        t = User(
            form.name.data, form.username.data,
            bcrypt.generate_password_hash(form.password.data).decode('utf-8'))
        db.session().add(t)
        db.session().commit()
        return redirect(url_for("auth_login"))
    return render_template('auth/new.html', form=form)
Example #7
0
def auth_register():
    if request.method == "GET":
        return render_template("auth/new.html", form=RegisterForm())

    form = RegisterForm(request.form)

    item = User(form.email.data, form.password.data)
    db.session().add(item)
    db.session().commit()

    return redirect(url_for("databases_index"))
Example #8
0
def tables_create():
    form = TableForm(request.form)
  
    if not form.validate():
        return render_template("tables/new.html", form = form)

    item = Table(form.name.data, form.columns.data)
    
    db.session().add(item)
    db.session().commit()

    return redirect(url_for("tables_index"))
Example #9
0
def databases_create():
    form = DatabaseForm(request.form)

    if not form.validate():
        return render_template("databases/new.html", form=form)

    item = Database(form.name.data)
    item.account_id = current_user.id

    db.session().add(item)
    db.session().commit()

    return redirect(url_for("databases_index"))
Example #10
0
def database_item(database_id):
    if request.method == "GET":
        return render_template("databases/details.html",
                               database=Database.query.get(database_id))
    elif request.method == "POST":
        form = DatabaseForm(request.form)
        if not form.validate():
            return render_template("databases/new.html", form=form)
        name = form.name.data
        item = Database.query.get(database_id)
        item.name = name
        db.session().commit()
    return redirect(url_for("databases_index"))
Example #11
0
def models_create():
    form = ModelForm(request.form)

    if not form.validate():
        return render_template("models/list.html", form=form, models=Product.query.all(), manufExists=Manufacturer.query.count() > 0, listeroo=Product.listByBrokenPercent())

    t = Product(form.name.data)
    t.manufacturer = form.manufacturer.data
    t.eol = False

    db.session().add(t)
    db.session().commit()

    return redirect(url_for("models_index"))
Example #12
0
def equipment_add():
    form = EquipmentAddForm(request.form)
    if not form.validate():
        return render_template("index.html", form=form, modelsExist=Product.query.count() > 0)

    eqpm = Equipment(form.serialnumber.data)
    eqpm.model = form.model.data
    eqpm.isbroken = False

    eqpm.person_id = current_user.id

    db.session().add(eqpm)
    db.session().commit()

    return redirect(url_for("index"))
Example #13
0
def manufacturers_index():
    if request.method == "GET":
        return render_template("manufacturers/list.html",
                               manufacturers=Manufacturer.query.all(),
                               listeroo=Manufacturer.listByModel(),
                               form=ManufacturerForm())
    if not current_user.is_authenticated:
        return redirect(url_for("auth_login"))

    form = ManufacturerForm(request.form)

    if not form.validate():
        return render_template("manufacturers/list.html",
                               form=form,
                               manufacturers=Manufacturer.query.all(),
                               listeroo=Manufacturer.listByModel())

    t = Manufacturer(request.form.get("name"))
    db.session().add(t)
    db.session().commit()

    return redirect(url_for("manufacturers_index"))
Example #14
0
def database_delete(database_id):
    item = Database.query.filter_by(id=database_id).delete()
    db.session().commit()
    return redirect(url_for("databases_index"))