def search(query, page=None): data = listTorrents(None, None, query, page) return render_template("list.html", urls=data['urls'], title=getPageTitle(None, None, query), pagination=data['pagination'] )
def bad_request(e): content = { "title": "Bad Request", "status": "400 - Bad Request", "description": "Zhopa koroche" } return render_template("error.html", content=content), 400
def recent(page=None): data = listTorrents(None, None, 'added:7d', page) return render_template("list.html", urls=data['urls'], title=getPageTitle(None, None, 'added:7d'), pagination=data['pagination'] )
def csvviresult(): global table # data = request.form['text'] # table = TableFu.from_file('app/vi-csv.csv') table = TableFu.from_file('app/vi-csv.csv') # return render_template('vi-template.html', table=table) return render_template('vi-template.html', table=table)
def signin(): if request.method == 'POST': info = u"Неверный логин или пароль" username = request.form['username'] password = request.form['password'] if username and password: user = get_user(username, password) if user: session['username'] = username session['password'] = password return redirect('/') else: return render_template("signin.html", info=info) else: return render_template("signin.html", info=info) else: return render_template("signin.html")
def edit(OrmForm, model): form = OrmForm(request.form, model) if form.validate_on_submit(): form.populate_obj(model) model.put() flash("MyModel updated") return redirect(url_for("index")) return render_template("editor.html", form=form)
def listBy(peer_seeds=None, tv_movies=None, page=None): if peer_seeds is None: peer_seeds = 'P' if tv_movies is None: tv_movies = 'tv' data = listTorrents(peer_seeds,tv_movies, None, page) return render_template("list.html", urls=data['urls'], title=getPageTitle(peer_seeds, tv_movies, None), pagination=data['pagination'] )
def not_found(e): if 'username' in session: content = { "title": "Not found", "status": "404 - Not found", "description": "This request did not found" } return render_template("error.html", content=content), 404 else: return redirect("/signin")
def highlights(): #get text from textarea, split it up DOIS into a list doiLIST = str(request.form['text']) global myDOIs myDOIs = doiLIST.split('\r\n') # run python process results = processDOI(myDOIs) return render_template('results.html', results=results)
def virtualissueautomate(): myDOIs = str(request.form["text"]).split('\r\n') # run python process createVI(myDOIs) global table # data = request.form['text'] table = TableFu.from_file('vi-csv.csv') return render_template('vi-template.html', table=table, results=results)
def podcastupload(): if request.method == 'POST': # Get the name of uploaded file file = request.files['file'] # Check if the file is an allowed extension if file and allowed_file(file.filename): # Make the filename safe - remove unsupported characters filename = secure_filename(file.filename) # # Move the file from the temp folder to the upload folder file.save(os.path.join(app.config["UPLOAD_FOLDER"], filename)) # Use tablefu to template out the uploaded CSV file global table table = TableFu.from_file('app/static/uploads/' + filename) return render_template('podcastresults.html', table=table)
def add_olympiad(): title = "Добавление олимпиады" form = EditorOlympiad() if form.validate_on_submit(): new_olympiad = Olympiad(name=form.name.data, max_balls=form.max_balls.data, description=form.description.data) db.session.add(new_olympiad) db.session.commit() flash('Добавлена Олимпиада!') return redirect(url_for("hierarchy")) flash(flash_editor_errors(form)) return render_template("editor.html", form=form, action='/add/olympiad', title=title)
def highlights(): # get text from textarea, split it up DOIS into a list doiLIST = str(request.form['text']) global myDOIs myDOIs = doiLIST.split('\r\n') # run python process results = processDOI(myDOIs) #save results to db saved_results = db.highlights.insert_one({"data": results, "datetime": datetime.datetime.utcnow() }) return render_template('results.html', results=results)
def virtualissueautomate(): # get checkbox multiJournal = request.form.get('checkbox', default=False, type=bool) # get tracking code trackingCode = request.form["vi-tracking"] # get vi-short-name shortName = request.form['vi-short-name'] # get DOIs myDOIs = str(request.form["DOIs"]).split('\r\n') # run python process results = createVI(myDOIs, multiJournal, trackingCode, shortName) #save results to db saved_results = db.virtualissues.insert_one({"data": results, "datetime": datetime.datetime.utcnow() }) return render_template('vi-template.html', results=results)
def feedback(self): items = [] items.append( { "date": "13/11/2015", "user_choice_time": "9.00", "arival_time": "8.37", "wakeup_time": "8.02", "is_late": "No", } ) items.append( { "date": "14/11/2015", "user_choice_time": "9.00", "arival_time": "8.42", "wakeup_time": "8.07", "is_late": "No", } ) items.append( { "date": "15/11/2015", "user_choice_time": "9.00", "arival_time": "8.45", "wakeup_time": "8.10", "is_late": "No", } ) items.append( { "date": "16/11/2015", "user_choice_time": "9.00", "arival_time": "8.43", "wakeup_time": "8.10", "is_late": "No", } ) return render_template("feedback.html", {"items": items})
def withdrawal(): user = get_current_user() try: if not user.gazalkent_admin and not user.director and not user.xojakent_admin: return redirect(url_for('home')) except AttributeError: return redirect(url_for('home')) if request.method == "POST": who = request.form.get('who') why = request.form.get('why') sum = int(request.form.get('amount')) add = Withdrawal(who=who, why=why, amount=sum, date=now) db.session.add(add) witdh = All_withdrawal.query.filter_by(id=1).first() all = witdh.total_sum + sum All_withdrawal.query.filter_by(id=1).update({'total_sum': all}) db.session.commit() return redirect(url_for('withdrawal')) withdrawals = Withdrawal.query.order_by('id').all() all_withdrawal = All_withdrawal.query.order_by('id').all() return render_template('payment/withdrawal.html', user=user, withdrawals=withdrawals, all_withdrawal=all_withdrawal)
def reg_prestado(id): urlrev = URLBASE username = CONFIG['TYPE_USER']['ROOT'] connect=Model(username) wid = id TSSServicioPtado = dict() TSSServicioPtado = {'TABLE':'servicio', 'Col1':'id', 'Col2':'tipo', 'Col3':'costo', 'Whe4':'id=%s' } Data = (wid,) DatosServicioPtado = connect.SW_TABLE(username,TSSServicioPtado, Data) TSSClient = dict() TSSClient = {'TABLE':'clientes', 'Col1':'id', 'Col2':'nombre' } DatosClient = connect.SSP_TABLE(username,TSSClient) return render_template("/lavasplash/form_registro_servicio.html", url = urlrev, servicios = DatosServicioPtado, clientes=DatosClient)
def All_Servicios(): urlrev = URLBASE username = CONFIG['TYPE_USER']['ROOT'] connect = Model(username) Tabla_All_Servicios = dict() Tabla_All_Servicios = { 'TABLE': 'products ORDER BY name', 'Col1': 'id_product', 'Col2': 'id_proveedor', 'Col3': 'id_categoria', 'Col4': 'name', 'Col5': 'precio', 'Col6': 'descripcion', 'Col7': 'media' } DatosAllServicios = connect.SSP_TABLE(username, Tabla_All_Servicios) print(DatosAllServicios) return render_template("/home/All_Servicios.html", url=urlrev, Oferta_Servicio=DatosAllServicios)
def login(): return render_template('login.html')
from app import app,render_template, redirect, url_for, request @app.route('/') @app.route('/index') def index(): return "Hello, World!" app.route('/login',methods=['GET','POST']) def login(): error=none if request=='POST': if request.form['username'] !='admin' or request.form['password'] !='admin': error= 'Please enter correct name or password' else: return redirect(url_for('home')) return render_template ('login.html', error=error)
def profile(): return render_template('profile.html')
def index(): if 'username' in session: return render_template("index.html") else: return render_template("signin.html")
def csvvi(): return render_template('csvindex.html')
def index_gp(): Urlbase = URLBASE username = CONFIG['TYPE_USER']['ROOT'] connect = Model(username) TSSServicioPtado = { 'TABLE': 'servicio', 'Col1': 'id', 'Col2': 'tipo', 'Col3': 'costo', } DatosServicioPtado = connect.SSP_TABLE(username, TSSServicioPtado) data_calendar = [] data_week = {} today = date.today() year_req = today.year month_req = today.month month_next = month_req + 1 month_back = month_req - 1 if month_next == 13: month_next = 1 year_req = year_req + 1 if month_next == 0: month_back = 12 year_req = year_req - 1 meses = { 1: "Enero", 2: "Febrero", 3: "Marzo", 4: "Abril", 5: "Mayo", 6: "Junio", 7: "Julio", 8: "Agosto", 9: "Septiembre", 10: "Octubre", 11: "Noviembre", 12: "Diciembre" } Datos_function = {} Datos_function["num_month_ant"] = "mes_anterior(" + str( month_back) + "," + str(year_req) + ")" Datos_function["num_month_act"] = "mes_actual(" + str( month_req) + "," + str(year_req) + ")" Datos_function["num_month_sig"] = "mes_siguiente(" + str( month_next) + "," + str(year_req) + ")" Datos_function["name_month_ant"] = meses[month_back] + "-" + str(year_req) Datos_function["name_month_act"] = meses[month_req] + " " + str(year_req) Datos_function["name_month_sig"] = meses[month_next] + "-" + str(year_req) Datos_function["month"] = month_req Datos_function["year"] = year_req fecha_recibida = procesar_fechas.proc_fecha() day_month = fecha_recibida.days_month(year_req, month_req) num_day_first_week = { "domingo": 1, "lunes": 2, "martes": 3, "miercoles": 4, "jueves": 5, "viernes": 6, "sabado": 7 } day_weekx = { 1: "sem1_d1", 2: "sem1_d2", 3: "sem1_d3", 4: "sem1_d4", 5: "sem1_d5", 6: "sem1_d6", 7: "sem1_d7", 8: "sem2_d1", 9: "sem2_d2", 10: "sem2_d3", 11: "sem2_d4", 12: "sem2_d5", 13: "sem2_d6", 14: "sem2_d7", 15: "sem3_d1", 16: "sem3_d2", 17: "sem3_d3", 18: "sem3_d4", 19: "sem3_d5", 20: "sem3_d6", 21: "sem3_d7", 22: "sem4_d1", 23: "sem4_d2", 24: "sem4_d3", 25: "sem4_d4", 26: "sem4_d5", 27: "sem4_d6", 28: "sem4_d7", 29: "sem5_d1", 30: "sem5_d2", 31: "sem5_d3", 32: "sem5_d4", 33: "sem5_d5", 34: "sem5_d6", 35: "sem5_d7", 36: "sem6_d1", 37: "sem6_d2", 38: "sem6_d3", 39: "sem6_d4", 40: "sem6_d5", 41: "sem6_d6", 42: "sem6_d7" } day_of_week = {} first_day = num_day_first_week[day_month[1]] for item in day_month: name_number_week = day_weekx[first_day] day_of_week[name_number_week] = item first_day += 1 cont = 0 data_insert = 0 num_semana = 0 for item in day_weekx: x = day_weekx[item] print(x) cont += 1 if day_of_week.get(x) == None: value = "" if cont < 7: data_week[x] = value data_insert += 1 cont += 1 if cont == 7: data_week[x] = value data_insert += 1 cont = 0 else: if cont < 7: data_week[x] = day_of_week[x] data_insert += 1 cont += 1 if cont == 7: data_week[x] = day_of_week[x] data_insert += 1 cont = 0 if data_insert == 7: data_calendar.append(data_week) data_week = {} data_insert = 0 # print(data_calendar) #print(Datos_function) return render_template("/gastos/gestion_gastos.html", url=Urlbase, servicios=DatosServicioPtado, month=day_of_week, datos=Datos_function, data_calendar=data_calendar)
def index(self): return render_template("index.html", {})
def issuemedicine(ssn): if (current_user.role != 'pharm'): return render_template('auth/accessDenied.html') allMeds = Med.query.all() return render_template('pharmacist/issuemedicine.html', meds=allMeds,ssn=ssn)
def allmedicines(): if(current_user.role != 'pharm'): return render_template('auth/accessDenied.html') medicines=Med.query.all() return render_template('pharmacist/medicines.html', medicines=medicines)
def alltests(): if (current_user.role != 'diag'): return render_template('auth/accessDenied.html') dTestsList = Diagnosistests.query.all() return render_template('diagnostic/tests.html', dTestList=dTestsList)
def show_users(): return render_template('show_users.html', users=User.query.all())
def get(): form = MainForm() return render_template('index.html', title='Sign In', form=form)
def get_index_view(): portalusers = PortalUser.query.all() return render_template(index_template, portalusers=portalusers)
def calc_js(): return render_template('/projects/calc/calc_js.html')
def py_interpreter(): return render_template('/projects/py_interpreter.html')
def plot_data_pca(): result = get_plot_pca(df) return render_template('plot_pca.html', result=result.decode('utf8'))
def docs(): if 'username' in session: return render_template("docs.html") else: return redirect("/signin")
def csvViewer(): path = './app/static/data/titanic.csv' df = pd.read_csv(path) records = df.head() return render_template('show.html', records=records)
def page_not_found(error): return render_template('page_not_found.html'), 404
def diag(): if (current_user.role != 'diag'): return render_template('auth/accessDenied.html') allPatients = Patient.query.all() return render_template('diagnostic/searchPatientDiagnostic.html', patients=allPatients)
def status(self): global string1, string2 return render_template("uwu.html", {"string1": string1, "string2": string2})
def senduser(): return render_template('auth/login.html')
def registro(): return render_template("/registro/registro.html")
def Careers_page(): return render_template("aniamls.html", z=packed)
def podcast(): return render_template('podcastindex.html')
def magnet(url): return render_template("magnet.html", link=getMagnetLink(url), title='Download' )
def index(): return render_template('index.html')
def Contact_page(): return render_template("aniamls.html", z=packed)
def virtualissue(): return render_template('virtualissue.html')
def cloud(): return render_template("cloud.html", urls=getTagCloud(), title='Tag Cloud' )
def image_app(environ, start_response): method = environ['REQUEST_METHOD'] path = environ['PATH_INFO'] query_string = environ['QUERY_STRING'] redirect = False # Set up jinja2 loader = jinja2.FileSystemLoader('./templates') env = jinja2.Environment(loader=loader) vars = dict() if path == '/image_upload': # Get content content_type = environ['CONTENT_TYPE'] content_length = int(environ['CONTENT_LENGTH']) content = environ['wsgi.input'].read(content_length) headers = {} for key, val in environ.iteritems(): headers[key.lower().replace('_', '-')] = val fs = cgi.FieldStorage(fp=StringIO.StringIO(content), headers = headers, environ = environ) filename = fs['file'].filename image_type = filename.split('.')[-1] if image_type in {'png', 'jpg', 'tiff', 'jpeg'}: # connect to the already existing database db = sqlite3.connect('images.sqlite') # configure to allow binary insertions db.text_factory = bytes # data to be inserted into database r = fs['file'].value f = fs['file'].filename d = fs['description'].value u = 1 # insert db.execute('INSERT INTO image_store (image, name, description, user_id) VALUES (?, ?, ?, ?)', (r, f, d, u)) db.commit() start_response('302 Moved Temporarily', [('Content-type', 'text/plain'), ('Location', '/')]) redirect = True if path == '/': db = sqlite3.connect('images.sqlite') # configure to retrieve bytes, not text db.text_factory = bytes # get a query handle (or "cursor") c = db.cursor() # select all of the images c.execute('SELECT iid, name, description, user_id FROM image_store ORDER BY iid DESC LIMIT 1') iid, name, description, user_id = c.fetchone() vars['name'] = name vars['description'] = description vars['time'] = time.time() start_response('200 OK', [('Content-type', 'text/html')]) ret = render_template(env, 'imageapp.html', vars) elif path == 'imageapp_list': db = sqlite3.connect('images.sqlite') db.text_factory = bytes c = db.cursor() c.execute('SELECT iid, name, description, user_id FROM image_store ORDER BY iid DESC LIMIT 1') iid, name, description, user_id = c.fetchone() vars['iid'] = iid vars['name'] = name vars['description'] = description vars['time'] = time.time() start_response('200 OK', [('Content-type', 'text/html')]) ret = render_template(env, 'imageapp.html', vars) elif path.startswith('/latest_image'): db = sqlite3.connect('images.sqlite') # configure to retrieve bytes, not text db.text_factory = bytes # get a query handle (or "cursor") c = db.cursor() # select all of the images c.execute('SELECT iid FROM image_store ORDER BY iid DESC LIMIT 1') iid, = c.fetchone() start_response('302 Moved Temporarily', [('Content-type', 'text/plain'), ('Location', '/image_raw/' + str(iid))]) redirect = True elif path.startswith('/image_raw/'): image_no = path.lstrip('/image_raw/') db = sqlite3.connect('images.sqlite') # configure to retrieve bytes, not text db.text_factory = bytes # get a query handle (or "cursor") c = db.cursor() # select image with iid=image_no c.execute('SELECT image, name FROM image_store WHERE iid=?', (image_no,)) image, name = c.fetchone() start_response('200 OK', [('Content-type', 'image/' + name.split('.')[-1])]) ret = image else: start_response('200 OK', [('Content-type', 'text/html')]) ret = render_template(env, '404.html', vars) # Needs to be a single-entry list for wsgi compliance if redirect: return [''] else: return [ret]
def issuetest(ssn): if current_user.role != 'diag': return render_template('auth/accessDenied.html') allTests = Diagnosistests.query.all() return render_template('diagnostic/new_test.html', tests=allTests, ssn=ssn)
def pharm(): #Checks if user is Pharmacist. If not,deny access to further pages. if(current_user.role != 'pharm'): return render_template('auth/accessDenied.html') allPatients = Patient.query.filter_by(status="Active").all() return render_template('pharmacist/searchpatient.html', patients=allPatients)
def podcastresult(): global table table = TableFu.from_file('app/chembio.csv') return render_template('podcastresultsnano.html', table=table)
def home(): for i in iter_file: list_titanic.append(i.strip().split(',')) return render_template('table.html', for_i=list_titanic)
def company_view(companyId): company = Company.query.filter(Company.id == companyId)[0] if companyId == session['company_id']: return render_template('company/company.html', company=company) else: return render_template('students/company.html', company=company)
def plot_data_age(): result = get_plot_data('Age', list_data) return render_template('plot_age.html', result=result.decode('utf8'))
def sector_view(sectorId): return render_template( 'students/sector.html', sector=Sector.query.filter(Sector.id == sectorId)[0], companies=Company.query.filter( Company.sector_id == sectorId).all())
def searchresult(result, name='', searchfield='', imagefolder='', query='', searchtype='equals', title='', authorinfo=False, lang='', show_lang_switch=True, cache=True): set_language_switch_link("%s_index" % name, result) try: result = result.encode("UTF-8") pagename = name + '_' + urllib.quote(result) art = check_cache(pagename, lang) if art is not None: return art show = ','.join( ['name', 'url', 'undertitel', 'lifespan', 'undertitel_eng']) if query: hits = karp_query('minientry', {'q': query, 'show': show}) else: hits = karp_query( 'minientry', { 'q': "extended||and|%s.search|%s|%s" % (searchfield, searchtype, result), 'show': show }) title = title or result.decode("UTF-8") no_hits = hits['hits']['total'] if no_hits > 0: picture = None if os.path.exists(app.config.root_path + '/static/images/%s/%s.jpg' % (imagefolder, result)): picture = '/static/images/%s/%s.jpg' % (imagefolder, result) page = render_template('list.html', picture=picture, alphabetic=True, title=title, headline=title, hits=hits["hits"], authorinfo=authorinfo, show_lang_switch=show_lang_switch) if no_hits >= app.config['CACHE_HIT_LIMIT']: try: with mc_pool.reserve() as client: client.set(cache_name(pagename, lang), page, time=app.config['CACHE_TIME']) except: # TODO what to do? pass return page else: return render_template( 'page.html', content=gettext('Contents could not be found!')) except Exception as e: return render_template( 'page.html', content="%s\n%s: extended||and|%s.search|%s|%s" % (e, app.config['KARP_BACKEND'], searchfield, searchtype, result))
def profile(): company = Company.query.filter(Company.id == session['company_id'])[0] return render_template('company/profile.html', company=company)
def create_group(): teacher = get_current_teacher() user = get_current_user() try: if not user.xojakent_admin and not user.gazalkent_admin and not user.director: return redirect(url_for('home')) except AttributeError: return redirect(url_for('home')) if request.method == 'POST': name = request.form.get("name") teachers = request.form.get("teacher") group_location = request.form.get('location') type_of_course = request.form.get('type_of_course') cost = request.form.get('cost') if group_location == "xojakent": group_location = 1 num = 1 groups_num = All_groups.all_groups + num All_groups.query.filter_by(id=1).update({'all_groups': groups_num}) db.session.commit() teach = Teachers.query.filter_by(id=teachers).first() total = teach.number_groups + num Teachers.query.filter_by(id=teachers).update( {'number_groups': total}) db.session.commit() elif group_location == "gazalkent": group_location = 2 num = 1 groups_num = All_groups.all_groups + num All_groups.query.filter_by(id=1).update({'all_groups': groups_num}) db.session.commit() teach = Teachers.query.filter_by(id=teachers).first() total = teach.number_groups + num Teachers.query.filter_by(id=teachers).update( {'number_groups': total}) db.session.commit() teacher_id = Teachers.query.filter_by(id=teachers).first() teacher_name = Teachers.query.filter_by(id=teachers).first() teacher_surname = Teachers.query.filter_by(id=teachers).first() if user.director: add = Groups(name=name, teacher_1=teacher_id.id, location=group_location, subject=teacher_id.subject, cost=cost, teacher_name=teacher_name.name, teacher_surname=teacher_surname.surname, type_of_course=type_of_course) db.session.add(add) else: add = Groups(name=name, teacher_1=teacher_id.id, location=user.locations, subject=teacher_id.subject, cost=cost, teacher_name=teacher_name.name, teacher_surname=teacher_surname.surname, type_of_course=type_of_course) db.session.add(add) show = Groups.query.filter_by(name=name).all() teachers1 = Teachers.query.filter_by(id=teachers).all() query_teacher = Teachers.query.filter_by(id=teachers).first() for i in show: if query_teacher.group1 is None and query_teacher.group2 is None and query_teacher.group3 is None and \ query_teacher.group4 is None and query_teacher.group5 is None and \ query_teacher.group6 is None and query_teacher.group7 is None and \ query_teacher.group8 is None and query_teacher.group9 is None and query_teacher.group10 is None: Teachers.query.filter_by(id=teachers).update({'group1': i.id}) elif query_teacher.group1 is not None and query_teacher.group2 is None and query_teacher.group3 is None \ and query_teacher.group4 is None and query_teacher.group5 is None and \ query_teacher.group6 is None and query_teacher.group7 is None and \ query_teacher.group8 is None and query_teacher.group9 is None and query_teacher.group10 is None: if query_teacher.group1 == i.id: return 'Bu grda ustoz uje bor' else: Teachers.query.filter_by(id=teachers).update( {'group2': i.id}) elif query_teacher.group1 is not None and query_teacher.group2 is not None and query_teacher.group3 is None \ and query_teacher.group4 is None and query_teacher.group5 is None and \ query_teacher.group6 is None and query_teacher.group7 is None and \ query_teacher.group8 is None and query_teacher.group9 is None and query_teacher.group10 is None: if query_teacher.group1 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group2 == i.id: return 'Bu grda ustoz uje bor' else: Teachers.query.filter_by(id=teachers).update( {'group3': i.id}) elif query_teacher.group1 is not None and query_teacher.group2 is not None and query_teacher.group3 is not None \ and query_teacher.group4 is None and query_teacher.group5 is None and \ query_teacher.group6 is None and query_teacher.group7 is None and \ query_teacher.group8 is None and query_teacher.group9 is None and query_teacher.group10 is None: if query_teacher.group1 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group2 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group3 == i.id: return 'Bu grda ustoz uje bor' else: Teachers.query.filter_by(id=teachers).update( {'group4': i.id}) elif query_teacher.group1 is not None and query_teacher.group2 is not None and query_teacher.group3 is not None \ and query_teacher.group4 is not None and query_teacher.group5 is None and \ query_teacher.group6 is None and query_teacher.group7 is None and \ query_teacher.group8 is None and query_teacher.group9 is None and query_teacher.group10 is None: if query_teacher.group1 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group2 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group3 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group4 == i.id: return 'Bu grda ustoz uje bor' else: Teachers.query.filter_by(id=teachers).update( {'group5': i.id}) elif query_teacher.group1 is not None and query_teacher.group2 is not None and query_teacher.group3 is not None \ and query_teacher.group4 is not None and query_teacher.group5 is not None and \ query_teacher.group6 is None and query_teacher.group7 is None and \ query_teacher.group8 is None and query_teacher.group9 is None and query_teacher.group10 is None: if query_teacher.group1 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group2 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group3 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group4 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group5 == i.id: return 'Bu grda ustoz uje bor' else: Teachers.query.filter_by(id=teachers).update( {'group6': i.id}) elif query_teacher.group1 is not None and query_teacher.group2 is not None and query_teacher.group3 is not None \ and query_teacher.group4 is not None and query_teacher.group5 is not None and \ query_teacher.group6 is not None and query_teacher.group7 is None and \ query_teacher.group8 is None and query_teacher.group9 is None and query_teacher.group10 is None: if query_teacher.group1 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group2 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group3 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group4 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group5 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group6 == i.id: return 'Bu grda ustoz uje bor' else: Teachers.query.filter_by(id=teachers).update( {'group7': i.id}) elif query_teacher.group1 is not None and query_teacher.group2 is not None and query_teacher.group3 is not None \ and query_teacher.group4 is not None and query_teacher.group5 is not None and \ query_teacher.group6 is not None and query_teacher.group7 is not None and \ query_teacher.group8 is None and query_teacher.group9 is None and query_teacher.group10 is None: if query_teacher.group1 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group2 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group3 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group4 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group5 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group6 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group7 == i.id: return 'Bu grda ustoz uje bor' else: Teachers.query.filter_by(id=teachers).update( {'group8': i.id}) elif query_teacher.group1 is not None and query_teacher.group2 is not None and query_teacher.group3 is not None \ and query_teacher.group4 is not None and query_teacher.group5 is not None and \ query_teacher.group6 is not None and query_teacher.group7 is not None and \ query_teacher.group8 is not None and query_teacher.group9 is None and query_teacher.group10 is None: if query_teacher.group1 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group2 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group3 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group4 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group5 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group6 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group7 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group8 == i.id: return 'Bu grda ustoz uje bor' else: Teachers.query.filter_by(id=teachers).update( {'group9': i.id}) elif query_teacher.group1 is not None and query_teacher.group2 is not None and query_teacher.group3 is not None \ and query_teacher.group4 is not None and query_teacher.group5 is not None and \ query_teacher.group6 is not None and query_teacher.group7 is not None and \ query_teacher.group8 is not None and query_teacher.group9 is not None and query_teacher.group10 is None: if query_teacher.group1 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group2 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group3 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group4 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group5 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group6 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group7 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group8 == i.id: return 'Bu grda ustoz uje bor' elif query_teacher.group9 == i.id: return 'Bu grda ustoz uje bor' else: Teachers.query.filter_by(id=teachers).update( {'group10': i.id}) calc = Student.query.filter_by(for_group=True).all() calculate = len(calc) Groups.query.filter_by(name=name).update( {'number_students': calculate}) query = Student.query.filter_by(for_group=True).first() for q in teachers1: for i in show: if query.group1 is None and query.group2 is None and query.group3 is None: if q.subject == query.subject_1: Student.query.filter_by(for_group=True).update({ 'group1': i.id, 'for_group': False, 'subject_1': None }) elif q.subject == query.subject_2: Student.query.filter_by(for_group=True).update({ 'group1': i.id, 'for_group': False, 'subject_2': None }) elif q.subject == query.subject_3: Student.query.filter_by(for_group=True).update({ 'group1': i.id, 'for_group': False, 'subject_3': None }) elif query.group1 is not None and query.group2 is None and query.group3 is None: if query.group1 == i.id: return 'Bu gruppa band' else: if q.subject == query.subject_1: Student.query.filter_by(for_group=True).update({ 'group2': i.id, 'for_group': False, 'subject_1': None }) elif q.subject == query.subject_2: Student.query.filter_by(for_group=True).update({ 'group2': i.id, 'for_group': False, 'subject_2': None }) elif q.subject == query.subject_3: Student.query.filter_by(for_group=True).update({ 'group2': i.id, 'for_group': False, 'subject_3': None }) elif query.group1 is not None and query.group2 is not None and query.group3 is None: if query.group1 == i.id: return 'Bu gruppa band' elif query.group2 == i.id: return 'Bu gruppa band' else: if q.subject == query.subject_1: Student.query.filter_by(for_group=True).update({ 'group3': i.id, 'for_group': False, 'subject_1': None }) elif q.subject == query.subject_2: Student.query.filter_by(for_group=True).update({ 'group3': i.id, 'for_group': False, 'subject_2': None }) elif q.subject == query.subject_3: Student.query.filter_by(for_group=True).update({ 'group3': i.id, 'for_group': False, 'subject_3': None }) experts = Teachers.query.filter_by(teacher=True).all() student1 = Student.query.filter_by(for_group=True).all() student = Student.query.filter_by(for_group=True).first() db.session.commit() return render_template('Groups/create group.html', user=user, teachers=experts, student1=student1, teacher=teacher, student=student)