def delete(): content = request.get_json() if 'tasks_id' in content: TasksDB.delete_data_from_db(tasks_id=content['tasks_id']) elif 'users_id' in content: UsersDB.delete_user(users_id=content['users_id']) return jsonify({'transaction': 'successfully', 'deleted': content})
def put(): content = request.get_json() if 'update' in content: if content['update']: UsersDB.update_users_to_admin(login=content['admin']) else: UsersDB.remove_from_admins(login=content['admin']) return jsonify({'transaction': 'successfully', 'updated': content}) else: TasksDB.update_data_in_db(new_description=content['description'], tasks_id=content['tasks_id']) return jsonify({'transaction': 'successfully', 'updated': content})
def get(self): if users.is_current_user_admin(): userp = int(self.request.get('user_name')) userdb = UsersDB.get_by_id(userp) userdb.blok = False blokdb = BlokUserDB.gql("WHERE user = '******'" % userdb.user) blokdb = blokdb.get() blokdb.delete() userdb.put() self.redirect('/userslist')
def post(self): if users.get_current_user(): reg = True user = users.get_current_user().nickname() userdb = UsersDB.gql("WHERE user = '******'" % user).get() if userdb.login != '': return self.redirect('/') tryag = u'<div><a href="/createlogin">Попробуйте ещё раз</a></div>' login = self.request.get('login') if login == '': return self.redirect('/createlogin') login = escape(login) no_valid = False for c in login: if c in self._valid_chars: pass else: no_valid = True if no_valid: reg = False self.response.out.write(u'<div>Введённый логин содержит запрещённые символы.</div>') return self.response.out.write(tryag) numchars = login.__len__() if numchars < 4 or numchars >= 15: reg = False self.response.out.write(u'<div>Логин должен содержать от 4 до 15 символов.</div>') return self.response.out.write(tryag) login_low = str.lower(str(login)) loginindb = GqlQuery("SELECT * FROM UsersDB WHERE login_low = :login_low", login_low = login_low).get() if loginindb is not None: reg = False self.response.out.write(u'<div>Пользователь под таким логином уже зарегистрирован.</div>') return self.response.out.write(tryag) if reg: userdb.login = login userdb.login_low = login_low userdb.put() memcache.delete('user_filter_%s' % users.get_current_user().nickname()) self.response.out.write(u'<div>Логин Зарегистрирован.</div><div>Можете перейти на <a href="/">Сайт</a></div>') else: pass else: return self.redirect('/')
def get(self): if users.get_current_user(): self.response.out.write(self.form) if users.get_current_user(): user = users.get_current_user().nickname() userdb = UsersDB.gql("WHERE user = '******'" % user).get() if userdb.login != '': return self.redirect('/') else: print 'error' else: return self.redirect('/')
def post(): global UsersID content = request.get_json() if 'user' in content: if content['user']: UsersDB.registration(login=content['login'].strip(), password=content['password'].strip(), user=content['user']) return jsonify({ 'registration': True, 'user': content['login'] }), 201 else: # достаем юзера и смотрим админ ли он, чтобы в registr.js отправить его на нужный сайт data = UsersDB.select_user(login=content['login'].strip(), password=content['password'].strip()) UsersID = data[0] if data is not None else None return jsonify({'data': data}), 201 elif 'get' in content: if content['get']: data = TasksDB.select_data_from_db(users_id=UsersID) return jsonify({ 'data': [tasks for tasks in data], 'users_id': UsersID }), 201 else: TasksDB.insert_data_in_db(description=content['description'], users_id=content['users_id']) return jsonify({'transaction': 'successfully'}), 201 elif 'users_list' in content: data = UsersDB.select_all_users(UsersID) return jsonify({ 'users': [users for users in data], 'users_id': UsersID }), 201 elif 'return_task' in content: data = TasksDB.select_data_from_db(users_id=content['users_id']) return jsonify({'data': [tasks for tasks in data]}), 201
def post(self): if users.is_current_user_admin(): cadmin = users.get_current_user().nickname() userp = int(self.request.get('user_name')) text = self.request.get('text') userdb = UsersDB.get_by_id(userp) if userdb.user == users.get_current_user: self.redirect('/userslist') else: userdb.blok = True blokdb = BlokUserDB() blokdb.user = userdb.user blokdb.text = text blokdb.admin = cadmin blokdb.put() userdb.put() self.redirect('/userslist')
def get_user(self): user = users.get_current_user() if user: dbuser = UsersDB.gql("WHERE user = '******'" % user.nickname()) if dbuser.count() == 0: insetuser = UsersDB() insetuser.user = user.nickname() insetuser.login = '' insetuser.name = '' insetuser.soname = '' insetuser.about = '' insetuser.avatar = None insetuser.blok = False insetuser.put() self.redirect("/") else: test_blok = Blok().testblock(user) if test_blok: return self.redirect(users.create_logout_url("/")) dbuser = dbuser.get() if dbuser.login == '': self.take_user = False return self.redirect('/createlogin') self.count_users_refresh() return user
# If no faces are found, then the display will sleep. # If a face is found, then the monitor will wake. # Press Q to exit from recognizer import Recognizer from database import UsersDB from flask import Flask, render_template, Response, make_response from multiprocessing import Process import time import threading import cv2 db = UsersDB() training_data_path = "training-data/" db.new_user("Seth", "Y", training_data_path+"Seth/") db.new_user("Sam", "Y", training_data_path+"Sam/") db.new_user("Seth Rogen", "Y", training_data_path+"Seth Rogen/") subjects = db.query_subjects() db.__del__() subjects = dict(subjects) recognizer = Recognizer() #viewer.start() app = Flask(__name__) @app.route('/') def index():