diff --git a/.gitignore b/.gitignore index cd420b7..d42868d 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,5 @@ project.db c*.txt +__pycache__/app.cpython-312.pyc +__pycache__/models.cpython-312.pyc diff --git a/app.py b/app.py index 75793c3..e51a222 100644 --- a/app.py +++ b/app.py @@ -114,20 +114,26 @@ def addoborudtodb(): @app.route('/all') def alloborud(): + return render_template('all.html') - result = db.session.query(Oboruds).order_by(Oboruds.invNumber).all() - res = [] +@app.route('/getall') +def getall(): + oboruds = Oboruds.query.all() + oboruds_json = [{ + 'id': oborud.id, + 'invNumber': oborud.invNumber, + 'nazvanie': oborud.nazvanie, + 'raspologenie': oborud.raspologenie, + 'numberved': oborud.numberved, + 'balancenumber': oborud.balancenumber, + 'kolichestvo': oborud.kolichestvo, + 'balancenumber': oborud.balancenumber, + 'aud_id': oborud.aud_id + } for oborud in oboruds] - for ob in result: - if ob.aud_id is not None: - aud = db.session.query(Auditory).filter_by(id=ob.aud_id).first() - res.append([ob.invNumber, ob.nazvanie, aud.audnazvanie]) - else: - res.append([ob.invNumber, ob.nazvanie]) - - return render_template('all.html', res=res) + return jsonify(oboruds_json) @app.route('/updateduplicate', methods=['GET', 'POST']) def updateduplicate(): diff --git a/migrations/versions/885bdd7b5161_.py b/migrations/versions/885bdd7b5161_.py new file mode 100644 index 0000000..c1ac071 --- /dev/null +++ b/migrations/versions/885bdd7b5161_.py @@ -0,0 +1,32 @@ +"""empty message + +Revision ID: 885bdd7b5161 +Revises: be7c94c549e5 +Create Date: 2024-04-02 23:03:59.401369 + +""" +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision = '885bdd7b5161' +down_revision = 'be7c94c549e5' +branch_labels = None +depends_on = None + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('oboruds', schema=None) as batch_op: + batch_op.add_column(sa.Column('kolichestvo', sa.Integer(), nullable=True)) + + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + with op.batch_alter_table('oboruds', schema=None) as batch_op: + batch_op.drop_column('kolichestvo') + + # ### end Alembic commands ### diff --git a/migrations/versions/__pycache__/885bdd7b5161_.cpython-312.pyc b/migrations/versions/__pycache__/885bdd7b5161_.cpython-312.pyc new file mode 100644 index 0000000..a89cef4 Binary files /dev/null and b/migrations/versions/__pycache__/885bdd7b5161_.cpython-312.pyc differ diff --git a/migrations/versions/__pycache__/be7c94c549e5_.cpython-312.pyc b/migrations/versions/__pycache__/be7c94c549e5_.cpython-312.pyc index ea0aa62..27b782a 100644 Binary files a/migrations/versions/__pycache__/be7c94c549e5_.cpython-312.pyc and b/migrations/versions/__pycache__/be7c94c549e5_.cpython-312.pyc differ diff --git a/models.py b/models.py index 24c2840..3f9a363 100644 --- a/models.py +++ b/models.py @@ -19,10 +19,13 @@ class Oboruds(db.Model): balancenumber = db.Column(db.String(30)) raspologenie = db.Column(db.String(200)) numberved = db.Column(db.String(100)) + kolichestvo = db.Column(db.Integer) aud_id = db.Column(db.Integer, db.ForeignKey(Auditory.id)) + + class Zametki(db.Model): id = db.Column(db.Integer, primary_key=True, autoincrement=True) txtzam=db.Column(db.String(10000)) diff --git a/static/css/index.css b/static/css/index.css index 6bc3fb1..72385ec 100644 --- a/static/css/index.css +++ b/static/css/index.css @@ -100,6 +100,15 @@ nav{ margin-left: 20px; } +.datatable{ + background-color: whitesmoke; +} + + + + + + @media print { *{ diff --git a/static/js/allmatc.js b/static/js/allmatc.js new file mode 100644 index 0000000..c9e2668 --- /dev/null +++ b/static/js/allmatc.js @@ -0,0 +1,35 @@ +function getAllData(){ + $.ajax({ + + url: "/getall", + type: "get", + contentType: 'application/json', + dataType: 'json', + + success: function(response){ + console.log(response) + let data = response; + $('#datatable tbody').empty(); + $.each(response, function(index, item) { + $('#datatable tbody').append( + '
| № п/п | +№ п/п вед | +Инв. номер | +Название | +Кол-во | +Счёт | +Аудитория | +
|---|