add get data func
This commit is contained in:
BIN
__pycache__/app.cpython-312.pyc
Normal file
BIN
__pycache__/app.cpython-312.pyc
Normal file
Binary file not shown.
BIN
__pycache__/models.cpython-312.pyc
Normal file
BIN
__pycache__/models.cpython-312.pyc
Normal file
Binary file not shown.
93
app.py
93
app.py
@@ -175,44 +175,23 @@ def zamsearch():
|
|||||||
p = request.form.get('srch')
|
p = request.form.get('srch')
|
||||||
|
|
||||||
searchedZam = db.session.query(Zametki).filter(
|
searchedZam = db.session.query(Zametki).filter(
|
||||||
Zametki.txtzam.contains(p)).all()
|
Zametki.txtzam.contains(p)).ll()
|
||||||
|
|
||||||
zam = []
|
zam = []
|
||||||
|
|
||||||
for item in searchedZam:
|
for item in searchedZam:
|
||||||
zam.append([item.txtzam, item.created_date])
|
zam.append([item.txtzam, item.created_date])
|
||||||
|
|
||||||
return render_template('zametki.html', zam=zam)
|
return render_template('zametki.html', zam=zam)
|
||||||
|
|
||||||
# ==================================================================================
|
# ==================================================================================
|
||||||
|
|
||||||
# Выгрузка в пдф
|
|
||||||
|
|
||||||
@app.route('/pdfexport')
|
def ranomraspr():
|
||||||
def pdfexport():
|
with app.app_context():
|
||||||
auds = db.session.query(Auditory).all()
|
while len(db.session.query(Oboruds).filter(Oboruds.aud_id == None).all()) > 0:
|
||||||
print(auds)
|
audid = random.choice(db.session.query(Auditory).all())
|
||||||
for aud in auds:
|
oborud = random.choice(db.session.query(Oboruds).filter(Oboruds.aud_id == None).all())
|
||||||
q = db.session.query(Auditory, Oboruds).filter(
|
oborud.aud_id = audid.id
|
||||||
Auditory.id == Oboruds.aud_id
|
db.session.commit()
|
||||||
).filter(Auditory.id == aud.id
|
|
||||||
).order_by(Oboruds.invNumber).all()
|
|
||||||
print(q)
|
|
||||||
|
|
||||||
results = []
|
|
||||||
for auditory, oboruds in q:
|
|
||||||
results.append({
|
|
||||||
'auditory_id': auditory.id,
|
|
||||||
'auditory_name': auditory.audnazvanie,
|
|
||||||
'inv_number': oboruds.invNumber,
|
|
||||||
'oboruds_id': oboruds.nazvanie,
|
|
||||||
})
|
|
||||||
html = render_template('searchonaud.html', aud=auds, res=results)
|
|
||||||
|
|
||||||
return render_pdf(HTML(string=html))
|
|
||||||
|
|
||||||
|
|
||||||
# ==================================================================================
|
|
||||||
def createdb():
|
def createdb():
|
||||||
with app.app_context():
|
with app.app_context():
|
||||||
db.create_all()
|
db.create_all()
|
||||||
@@ -247,22 +226,15 @@ def createdb():
|
|||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
#with open('inventMavrin.csv', encoding='cp1251') as csv_file:
|
with open('inventMavrin.csv', encoding='cp1251') as csv_file:
|
||||||
# csv_reader = csv.reader(csv_file, delimiter=';')
|
csv_reader = csv.reader(csv_file, delimiter=';')
|
||||||
# for row in csv_reader:
|
for row in csv_reader:
|
||||||
# db.session.add(
|
db.session.add(
|
||||||
# Oboruds(invNumber=row[0], nazvanie=row[1], typeBalanse='баланс'))
|
Oboruds(invNumber=row[0], nazvanie=row[1], typeBalanse='баланс'))
|
||||||
#db.session.commit()
|
|
||||||
|
|
||||||
|
|
||||||
def updateOborud():
|
|
||||||
with app.app_context():
|
|
||||||
db.session.query(Oboruds).update({Oboruds.typeBalanse: 'баланс'})
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
|
||||||
|
"""
|
||||||
def addZabalans():
|
|
||||||
with app.app_context():
|
|
||||||
with open('zabalans.csv', encoding='utf-8') as csv_file:
|
with open('zabalans.csv', encoding='utf-8') as csv_file:
|
||||||
csv_reader = csv.reader(csv_file, delimiter=';')
|
csv_reader = csv.reader(csv_file, delimiter=';')
|
||||||
for row in csv_reader:
|
for row in csv_reader:
|
||||||
@@ -271,42 +243,11 @@ def addZabalans():
|
|||||||
Oboruds(invNumber=row[0], nazvanie=row[1], typeBalanse="забаланс"))
|
Oboruds(invNumber=row[0], nazvanie=row[1], typeBalanse="забаланс"))
|
||||||
|
|
||||||
db.session.commit()
|
db.session.commit()
|
||||||
|
"""
|
||||||
|
|
||||||
def randomraspr():
|
|
||||||
with app.app_context():
|
|
||||||
while db.session.query(Oboruds).filter(Oboruds.aud_id == None).all():
|
|
||||||
audid = random.choice(db.session.query(Auditory).all())
|
|
||||||
oborud = random.choice(db.session.query(
|
|
||||||
Oboruds).filter(Oboruds.aud_id == None).all())
|
|
||||||
oborud.aud_id = audid.id
|
|
||||||
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
|
|
||||||
def randomzam():
|
|
||||||
files = ['cf.txt', 'ci.txt', 'co.txt']
|
|
||||||
|
|
||||||
fio = []
|
|
||||||
for i in range(20):
|
|
||||||
tmp = []
|
|
||||||
for file in files:
|
|
||||||
f = open(file, "r", encoding="utf-8").readlines()
|
|
||||||
tmp.append(random.choice(f))
|
|
||||||
|
|
||||||
fio.append((''.join(tmp)).replace('\n', ' ').replace('\t', ''))
|
|
||||||
|
|
||||||
print(fio)
|
|
||||||
|
|
||||||
for item in fio:
|
|
||||||
timeadd = datetime.now(timezone.utc)
|
|
||||||
with app.app_context():
|
|
||||||
db.session.add(Zametki(txtzam=item, created_date=timeadd))
|
|
||||||
db.session.commit()
|
|
||||||
|
|
||||||
# ==================================
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
|
|
||||||
|
#ranomraspr()
|
||||||
|
#createdb()
|
||||||
app.run(debug=True, host='0.0.0.0', port='3800')
|
app.run(debug=True, host='0.0.0.0', port='3800')
|
||||||
|
|||||||
Binary file not shown.
BIN
migrations/versions/__pycache__/256c3a3e91a2_.cpython-312.pyc
Normal file
BIN
migrations/versions/__pycache__/256c3a3e91a2_.cpython-312.pyc
Normal file
Binary file not shown.
BIN
migrations/versions/__pycache__/4f95d12a8352_.cpython-312.pyc
Normal file
BIN
migrations/versions/__pycache__/4f95d12a8352_.cpython-312.pyc
Normal file
Binary file not shown.
BIN
migrations/versions/__pycache__/50f85881169e_.cpython-312.pyc
Normal file
BIN
migrations/versions/__pycache__/50f85881169e_.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
BIN
migrations/versions/__pycache__/b24baa0d98e6_.cpython-312.pyc
Normal file
BIN
migrations/versions/__pycache__/b24baa0d98e6_.cpython-312.pyc
Normal file
Binary file not shown.
BIN
migrations/versions/__pycache__/b2a61aef79e9_.cpython-312.pyc
Normal file
BIN
migrations/versions/__pycache__/b2a61aef79e9_.cpython-312.pyc
Normal file
Binary file not shown.
Binary file not shown.
0
static/js/modal.js
Normal file
0
static/js/modal.js
Normal file
@@ -24,21 +24,29 @@
|
|||||||
var tr =""
|
var tr =""
|
||||||
|
|
||||||
data.forEach(element => {
|
data.forEach(element => {
|
||||||
|
tr += '<tr onclick="tableclick(this)">'
|
||||||
tr += '<td>' + element.inv_number + '</td>'
|
tr += '<td>' + element.inv_number + '</td>'
|
||||||
tr += '<td>' + element.oboruds_id + '</td>'
|
tr += '<td>' + element.oboruds_id + '</td>'
|
||||||
tr += '<td class="no-print">' + element.auditory_name + '</td>'
|
tr += '<td class="no-print">' + element.auditory_name + '</td>'
|
||||||
tr += '<td>' + '\n' + '</td>'
|
tr += '<td>' + '\n' + '</td>'
|
||||||
|
|
||||||
tr += '</tr>'
|
tr += '</tr>'
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
table.innerHTML += tr
|
table.innerHTML += tr
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
function tableclick(x){
|
||||||
|
let roww = x.rowIndex
|
||||||
|
let data = document.getElementById(x.rowIndex)
|
||||||
|
|
||||||
|
let datas = x.innerText.split('\t')
|
||||||
|
|
||||||
|
console.log(datas[0])
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|||||||
@@ -9,3 +9,4 @@
|
|||||||
<script src="{{url_for('static', filename='js/zametki.js') }}"></script>
|
<script src="{{url_for('static', filename='js/zametki.js') }}"></script>
|
||||||
<script src="{{url_for('static', filename='js/searchonaud.js') }}"></script>
|
<script src="{{url_for('static', filename='js/searchonaud.js') }}"></script>
|
||||||
<script src="{{url_for('static', filename='js/print.js') }}"></script>
|
<script src="{{url_for('static', filename='js/print.js') }}"></script>
|
||||||
|
<script src="{{url_for('static', filename='js/modal.js') }}"></script>
|
||||||
@@ -23,7 +23,6 @@
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="card col-md-10 col-10">
|
<div class="card col-md-10 col-10">
|
||||||
<form method="POST" action="/addoborudtodb">
|
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<h3 class="card-title no-print"> Поаудиторно </h3>
|
<h3 class="card-title no-print"> Поаудиторно </h3>
|
||||||
|
|
||||||
@@ -40,11 +39,9 @@
|
|||||||
<td class="no-print"> {{item[2]}} </td>
|
<td class="no-print"> {{item[2]}} </td>
|
||||||
<td id="proverka"> Проверено </td>
|
<td id="proverka"> Проверено </td>
|
||||||
|
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user