add new func
This commit is contained in:
80
app.py
80
app.py
@@ -1,18 +1,14 @@
|
|||||||
from flask import Flask, render_template, redirect, url_for, request, jsonify
|
from flask import Flask, render_template, redirect, url_for, request, jsonify
|
||||||
from models import db, CommissionPersons
|
from models import db, CommissionPersons
|
||||||
from flask_migrate import Migrate
|
from flask_migrate import Migrate
|
||||||
|
import json
|
||||||
|
|
||||||
app = Flask(__name__)
|
app = Flask(__name__)
|
||||||
|
|
||||||
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///project.db"
|
app.config["SQLALCHEMY_DATABASE_URI"] = "sqlite:///project.db"
|
||||||
app.jinja_env.auto_reload = True
|
app.jinja_env.auto_reload = True
|
||||||
app.config['TEMPLATES_AUTO_RELOAD'] = True
|
app.config['TEMPLATES_AUTO_RELOAD'] = True
|
||||||
db.init_app(app)
|
db.init_app(app)
|
||||||
migrate = Migrate(app, db)
|
migrate = Migrate(app, db)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app.secret_key = '6523e58bc0eec42c31b9635d5e0dfc23b6d119b73e633bf3a5284c79bb4a1edeaskldj'
|
app.secret_key = '6523e58bc0eec42c31b9635d5e0dfc23b6d119b73e633bf3a5284c79bb4a1edeaskldj'
|
||||||
|
|
||||||
|
|
||||||
@@ -20,21 +16,89 @@ app.secret_key = '6523e58bc0eec42c31b9635d5e0dfc23b6d119b73e633bf3a5284c79bb4a1e
|
|||||||
def index():
|
def index():
|
||||||
return "22222"
|
return "22222"
|
||||||
|
|
||||||
|
|
||||||
@app.route("/settings", methods=["GET", "POST"])
|
@app.route("/settings", methods=["GET", "POST"])
|
||||||
def settings():
|
def settings():
|
||||||
return render_template('settnigs.html')
|
return render_template('settnigs.html')
|
||||||
|
|
||||||
|
|
||||||
@app.route("/addperson", methods=["GET", "POST"])
|
@app.route("/addperson", methods=["GET", "POST"])
|
||||||
def addperson():
|
def addperson():
|
||||||
if request.method == "GET":
|
if request.method == "GET":
|
||||||
fio = request.args.get("fio")
|
fio = request.args.get("fio")
|
||||||
predsed = request.args.get("predsed")
|
predsed = request.args.get("predsed")
|
||||||
recent = request.args.get("recent")
|
recent = request.args.get("recent")
|
||||||
print(fio)
|
secretar = request.args.get("secretar")
|
||||||
print(predsed)
|
|
||||||
print(recent)
|
ispred = False
|
||||||
|
isrecenz = False
|
||||||
|
issecretar = False
|
||||||
|
|
||||||
|
if predsed == "true":
|
||||||
|
ispred = True
|
||||||
|
|
||||||
|
if recent == "true":
|
||||||
|
isrecenz = True
|
||||||
|
|
||||||
|
if secretar == "true":
|
||||||
|
issecretar = True
|
||||||
|
|
||||||
|
db.session.add(CommissionPersons(fio=fio,
|
||||||
|
ispredsedatel=ispred,
|
||||||
|
isrecenzent=isrecenz,
|
||||||
|
issecretar=issecretar))
|
||||||
|
db.session.commit()
|
||||||
return jsonify({'success': True}, 200, {'ContentType': 'application/json'})
|
return jsonify({'success': True}, 200, {'ContentType': 'application/json'})
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/createcommision", methods=["GET", "POST"])
|
||||||
|
def createcommision():
|
||||||
|
return render_template("createCommision.html")
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/1", methods=["GET", "POST"])
|
||||||
|
def one():
|
||||||
|
if request.method == "GET":
|
||||||
|
return "111111"
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/gu", methods=["GET", "POST"])
|
||||||
|
def getuchastniki():
|
||||||
|
if request.method == "GET":
|
||||||
|
data = db.session.query(CommissionPersons).all()
|
||||||
|
data_dct = []
|
||||||
|
for item in data:
|
||||||
|
data_dct.append(
|
||||||
|
{
|
||||||
|
'fio': item.fio,
|
||||||
|
'predsed': item.ispredsedatel,
|
||||||
|
'recent': item.isrecenzent,
|
||||||
|
'secretar': item.issecretar
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
return jsonify(data_dct)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/addcommision", methods=["GET", "POST"])
|
||||||
|
def addcommision():
|
||||||
|
if request.method == "GET":
|
||||||
|
predsdatel = request.args.get("predsdatel")
|
||||||
|
uchastnik1 = request.args.get("uchastnik1")
|
||||||
|
uchastnik2 = request.args.get("uchastnik2")
|
||||||
|
uchastnik3 = request.args.get("uchastnik3")
|
||||||
|
uchastnik4 = request.args.get("uchastnik4")
|
||||||
|
secretar = request.args.get("secretar")
|
||||||
|
|
||||||
|
pred = db.session.query(CommissionPersons).filter(CommissionPersons.fio == predsdatel).first()
|
||||||
|
uch1 = db.session.query(CommissionPersons).filter(CommissionPersons.fio == uchastnik1).first()
|
||||||
|
uch2 = db.session.query(CommissionPersons).filter(CommissionPersons.fio == uchastnik2).first()
|
||||||
|
uch3 = db.session.query(CommissionPersons).filter(CommissionPersons.fio == uchastnik3).first()
|
||||||
|
uch4 = db.session.query(CommissionPersons).filter(CommissionPersons.fio == uchastnik4).first()
|
||||||
|
secr = db.session.query(CommissionPersons).filter(CommissionPersons.fio == secretar).first()
|
||||||
|
|
||||||
|
return jsonify({'success': True}, 200, {'ContentType': 'application/json'})
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app.run(debug=True, host="0.0.0.0", port=3800)
|
app.run(debug=True, host="0.0.0.0", port=3800)
|
||||||
|
|||||||
@@ -9,4 +9,5 @@ class CommissionPersons(db.Model):
|
|||||||
fio = db.Column(db.String(80), unique=True, nullable=False)
|
fio = db.Column(db.String(80), unique=True, nullable=False)
|
||||||
ispredsedatel = db.Column(db.Boolean, nullable=False, default=False)
|
ispredsedatel = db.Column(db.Boolean, nullable=False, default=False)
|
||||||
isrecenzent = db.Column(db.Boolean, nullable=False, default=False)
|
isrecenzent = db.Column(db.Boolean, nullable=False, default=False)
|
||||||
|
issecretar = db.Column(db.Boolean, nullable=False, default=False)
|
||||||
|
|
||||||
|
|||||||
83
static/js/createcommision.js
Normal file
83
static/js/createcommision.js
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
let numbergak = document.getElementById("gaknumber")
|
||||||
|
let predsel = document.getElementById('predesdatel')
|
||||||
|
let uch1 = document.getElementById('uchgak1')
|
||||||
|
let uch2 = document.getElementById('uchgak2')
|
||||||
|
let uch3 = document.getElementById('uchgak3')
|
||||||
|
let uch4 = document.getElementById('uchgak4')
|
||||||
|
let addcom = document.getElementById("addcom")
|
||||||
|
|
||||||
|
let secretar = document.getElementById('secretar')
|
||||||
|
|
||||||
|
let preds = []
|
||||||
|
let alluchs = []
|
||||||
|
let secretars = []
|
||||||
|
|
||||||
|
$(document).ready(function () {
|
||||||
|
console.log("page Load!!")
|
||||||
|
|
||||||
|
$.getJSON("/gu", function (data) {
|
||||||
|
data.forEach(function (element) {
|
||||||
|
if (element.secretar == 0) {
|
||||||
|
alluchs.push(element.fio)
|
||||||
|
} else {
|
||||||
|
secretars.push(element.fio)
|
||||||
|
}
|
||||||
|
if (element.predsed == 1) {
|
||||||
|
preds.push(element.fio)
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
for (i = 0; i < preds.length; i++) {
|
||||||
|
let newOption = new Option(preds[i], preds[i])
|
||||||
|
predsel.appendChild(newOption)
|
||||||
|
}
|
||||||
|
|
||||||
|
alluchs.forEach(function (item) {
|
||||||
|
let newOption = new Option(item, item)
|
||||||
|
uch1.appendChild(newOption);
|
||||||
|
})
|
||||||
|
alluchs.forEach(function (item) {
|
||||||
|
let newOption = new Option(item, item)
|
||||||
|
uch2.appendChild(newOption);
|
||||||
|
})
|
||||||
|
alluchs.forEach(function (item) {
|
||||||
|
let newOption = new Option(item, item)
|
||||||
|
uch3.appendChild(newOption);
|
||||||
|
})
|
||||||
|
alluchs.forEach(function (item) {
|
||||||
|
let newOption = new Option(item, item)
|
||||||
|
uch4.appendChild(newOption);
|
||||||
|
})
|
||||||
|
secretars.forEach(function (item) {
|
||||||
|
let newOption = new Option(item, item)
|
||||||
|
secretar.appendChild(newOption)
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
addcom.onclick = function () {
|
||||||
|
console.log('PRESSEDD')
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
url: "/addcommision",
|
||||||
|
type: "get",
|
||||||
|
contentType: "application/json",
|
||||||
|
dataType: "json",
|
||||||
|
data: {
|
||||||
|
'predsdatel': predsel.value,
|
||||||
|
'uchastnik1': uch1.value,
|
||||||
|
'uchastnik2': uch2.value,
|
||||||
|
'uchastnik3': uch3.value,
|
||||||
|
'uchastnik4': uch4.value,
|
||||||
|
'secretar': secretar.value
|
||||||
|
},
|
||||||
|
error: function (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -6,11 +6,8 @@ btnadd.onclick = function (){
|
|||||||
fio = document.getElementById("fio").value;
|
fio = document.getElementById("fio").value;
|
||||||
predsed = document.getElementById("predsedatel").checked;
|
predsed = document.getElementById("predsedatel").checked;
|
||||||
recent = document.getElementById("recentzent").checked;
|
recent = document.getElementById("recentzent").checked;
|
||||||
|
secretar = document.getElementById("secretar").checked;
|
||||||
|
|
||||||
|
|
||||||
console.log(fio);
|
|
||||||
console.log(predsed);
|
|
||||||
console.log(recent);
|
|
||||||
$.ajax(
|
$.ajax(
|
||||||
{
|
{
|
||||||
url: "/addperson",
|
url: "/addperson",
|
||||||
@@ -21,6 +18,7 @@ btnadd.onclick = function (){
|
|||||||
'fio': fio,
|
'fio': fio,
|
||||||
'predsed': predsed,
|
'predsed': predsed,
|
||||||
'recent': recent,
|
'recent': recent,
|
||||||
|
'secretar': secretar
|
||||||
},
|
},
|
||||||
error: function(error){
|
error: function(error){
|
||||||
console.log(error);
|
console.log(error);
|
||||||
|
|||||||
68
templates/createCommision.html
Normal file
68
templates/createCommision.html
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Создать комиссию</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<label>ГЭК №</label>
|
||||||
|
<input type="text" name="myInput" size="30" required id="gaknumber">
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<label>Председатель</label>
|
||||||
|
<select id="predesdatel">
|
||||||
|
<option>--Выбери--</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<label>Участник</label>
|
||||||
|
<select id="uchgak1">
|
||||||
|
<option>--Выбери--</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<label>Участник</label>
|
||||||
|
<select id="uchgak2">
|
||||||
|
<option>--Выбери--</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<label>Участник</label>
|
||||||
|
<select id="uchgak3">
|
||||||
|
<option>--Выбери--</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<label>Участник</label>
|
||||||
|
<select id="uchgak4">
|
||||||
|
<option>--Выбери--</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="row">
|
||||||
|
<label>Секретарь</label>
|
||||||
|
<select id="secretar">
|
||||||
|
<option>--Выбери--</option>
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<button type="button" id="addcom">
|
||||||
|
Добавить ГЭК
|
||||||
|
</button>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
</body>
|
||||||
|
<script src="{{url_for('static', filename='js/jquery-3.7.1.js')}}"></script>
|
||||||
|
<script src="{{url_for('static', filename='js/createcommision.js')}}"></script>
|
||||||
|
</html>
|
||||||
@@ -17,6 +17,10 @@
|
|||||||
<input type="checkbox" value="yes" id="recentzent">
|
<input type="checkbox" value="yes" id="recentzent">
|
||||||
Рецензент
|
Рецензент
|
||||||
</label>
|
</label>
|
||||||
|
<label>
|
||||||
|
<input type="checkbox" value="yes" id="secretar">
|
||||||
|
Секретарь
|
||||||
|
</label>
|
||||||
<button type="button" name="AddChlenKom" id="addbtn">
|
<button type="button" name="AddChlenKom" id="addbtn">
|
||||||
Добавить
|
Добавить
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
Reference in New Issue
Block a user