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.
99
app.py
99
app.py
@@ -175,44 +175,23 @@ def zamsearch():
|
||||
p = request.form.get('srch')
|
||||
|
||||
searchedZam = db.session.query(Zametki).filter(
|
||||
Zametki.txtzam.contains(p)).all()
|
||||
|
||||
Zametki.txtzam.contains(p)).ll()
|
||||
zam = []
|
||||
|
||||
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)
|
||||
|
||||
# ==================================================================================
|
||||
|
||||
# Выгрузка в пдф
|
||||
|
||||
@app.route('/pdfexport')
|
||||
def pdfexport():
|
||||
auds = db.session.query(Auditory).all()
|
||||
print(auds)
|
||||
for aud in auds:
|
||||
q = db.session.query(Auditory, Oboruds).filter(
|
||||
Auditory.id == Oboruds.aud_id
|
||||
).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 ranomraspr():
|
||||
with app.app_context():
|
||||
while len(db.session.query(Oboruds).filter(Oboruds.aud_id == None).all()) > 0:
|
||||
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 createdb():
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
@@ -247,22 +226,15 @@ def createdb():
|
||||
|
||||
db.session.commit()
|
||||
|
||||
#with open('inventMavrin.csv', encoding='cp1251') as csv_file:
|
||||
# csv_reader = csv.reader(csv_file, delimiter=';')
|
||||
# for row in csv_reader:
|
||||
# db.session.add(
|
||||
# Oboruds(invNumber=row[0], nazvanie=row[1], typeBalanse='баланс'))
|
||||
#db.session.commit()
|
||||
with open('inventMavrin.csv', encoding='cp1251') as csv_file:
|
||||
csv_reader = csv.reader(csv_file, delimiter=';')
|
||||
for row in csv_reader:
|
||||
db.session.add(
|
||||
Oboruds(invNumber=row[0], nazvanie=row[1], typeBalanse='баланс'))
|
||||
|
||||
|
||||
def updateOborud():
|
||||
with app.app_context():
|
||||
db.session.query(Oboruds).update({Oboruds.typeBalanse: 'баланс'})
|
||||
db.session.commit()
|
||||
|
||||
|
||||
def addZabalans():
|
||||
with app.app_context():
|
||||
"""
|
||||
with open('zabalans.csv', encoding='utf-8') as csv_file:
|
||||
csv_reader = csv.reader(csv_file, delimiter=';')
|
||||
for row in csv_reader:
|
||||
@@ -270,43 +242,12 @@ def addZabalans():
|
||||
db.session.add(
|
||||
Oboruds(invNumber=row[0], nazvanie=row[1], typeBalanse="забаланс"))
|
||||
|
||||
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()
|
||||
|
||||
# ==================================
|
||||
db.session.commit()
|
||||
"""
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
app.run(debug=True, host='0.0.0.0', port='3800')
|
||||
#ranomraspr()
|
||||
#createdb()
|
||||
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 =""
|
||||
|
||||
data.forEach(element => {
|
||||
|
||||
tr += '<tr onclick="tableclick(this)">'
|
||||
tr += '<td>' + element.inv_number + '</td>'
|
||||
tr += '<td>' + element.oboruds_id + '</td>'
|
||||
tr += '<td class="no-print">' + element.auditory_name + '</td>'
|
||||
tr += '<td>' + '\n' + '</td>'
|
||||
|
||||
tr += '</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/searchonaud.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="card col-md-10 col-10">
|
||||
<form method="POST" action="/addoborudtodb">
|
||||
<div class="card-body">
|
||||
<h3 class="card-title no-print"> Поаудиторно </h3>
|
||||
|
||||
@@ -40,11 +39,9 @@
|
||||
<td class="no-print"> {{item[2]}} </td>
|
||||
<td id="proverka"> Проверено </td>
|
||||
|
||||
|
||||
{% endfor %}
|
||||
</table>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user