Beispiel #1
0
def getProfileGeneral():
    new_user = User()
    new_user.load_dishes()

    art = request.args.get('art')
    if art == 'ILove':
        print(get_ilove())
        return Response(js.dumps(get_ilove()), mimetype='application/json')
    elif art == 'IHate':
        return Response(js.dumps(get_ihate()), mimetype='application/json')
    elif art == 'ICant':
        return Response(js.dumps(get_icant()), mimetype='application/json')
Beispiel #2
0
 def register_user(name, password, email, invite_code):
     email_patteren = re.compile(
         "(^[a-zA-Z0-9_.+-]+@[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+$)")
     if not email_patteren.match(email):
         raise ClientError(ClientError.INVALID_EMAIL)
     session = SessionManager.Session()
     try:
         code = session.query(InviteCode).filter(
             InviteCode.code == invite_code).one()
         if code.used_by is not None:
             raise ClientError(ClientError.INVALID_INVITE_CODE)
         user = User(name=name,
                     password=UserCredential.get_pass_hash(password),
                     email=email,
                     level=0)
         session.add(user)
         session.commit()
         code.used_by = user.id
         session.commit()
         return True
     except NoResultFound:
         raise ClientError(ClientError.INVALID_INVITE_CODE)
     except DataError:
         raise ClientError(ClientError.INVALID_INVITE_CODE)
     except IntegrityError as error:
         if error.diag.column_name == 'name':
             raise ClientError(ClientError.DUPLICATE_NAME)
         elif error.diag.column_name == 'email':
             raise ClientError(ClientError.DUPLICATE_EMAIL)
     except ClientError as error:
         raise error
     except Exception as error:
         raise ServerError(error.message)
     finally:
         SessionManager.Session.remove()
Beispiel #3
0
 def register_user(name, password, invite_code):
     session = SessionManager.Session()
     try:
         code = session.query(InviteCode).filter(
             InviteCode.code == invite_code).one()
         if code.used_by is not None:
             raise ClientError(ClientError.INVALID_INVITE_CODE)
         user = User(name=name,
                     password=generate_password_hash(password),
                     level=0)
         session.add(user)
         session.commit()
         code.used_by = user.id
         session.commit()
         return True
     except NoResultFound:
         raise ClientError(ClientError.INVALID_INVITE_CODE)
     except DataError:
         raise ClientError(ClientError.INVALID_INVITE_CODE)
     except IntegrityError:
         raise ClientError(ClientError.DUPLICATE_NAME)
     except ClientError as error:
         raise error
     except Exception as error:
         raise ServerError(error.message)
     finally:
         SessionManager.Session.remove()
Beispiel #4
0
def login():
    content = request.get_json()
    user = User(**content)

    userRepo = UtilitiesProvider.userRepo
    result = userRepo.verifyLogin(user)

    if result != None:
        return {'token': createToken(content)}

    return "Username or password are wrong"
Beispiel #5
0
 def sendReviewersListRequest(self):
     response = self.send_request(ReviewerListRequest())
     response.set_reviewers([
         PCMember(
             1, 'website', False,
             Author(1, None, False, [
                 Paper(1, 'paper1', 'metadata',
                       [str(Keyword(1, 'key1')),
                        str(Keyword(2, 'key2'))], [str(Topic(1, 'topic1'))],
                       'document.smthg')
             ], User(1, 'email', 'password', 'name', 'username')))
     ])
     return response
Beispiel #6
0
 def loadAll(self, user, cur, connection):
     try:
         cur.execute(
             """Select id, name, email, dateofbirth, password, access from USERS"""
         )
     except DatabaseError:
         return {"result": "Database Execute Error"}
     else:
         users = cur.fetchall()
         usersList = []
         for item in users:
             usersList.append(
                 User(item[1], item[2], item[3], item[4], item[5],
                      item[0]).__dict__)
         return usersList
 def current_user(self):
     
     if not hasattr(self, "_currentUser"):
         self._currentUser = None
         #check whether the user already exists in the BD
         user = User.get_by_key_name(BaseHandler._uid)
         #if no user is retrieved, this is the first time the user uses the app, we need to save the user data
         if not user:
             #get the user contacts list
             friends = Contacts.get(BaseHandler._token)
             graph = facebook.GraphAPI(BaseHandler._token)
             userProfile = graph.get_object("me")
             user = User(key_name=str(userProfile["id"]),id=str(userProfile["id"]),nombre=userProfile["name"],url_perfil=userProfile["link"],access_token=BaseHandler._token,contactos=friends)
             user.put()
             #check if the token is the same, otherwise we update it 
         elif user.access_token != BaseHandler._token:
             user.access_token = BaseHandler._token
             user.put()
             #set the user
         self._currentUser = user
 
     return self._currentUser
Beispiel #8
0
 def __generateUserObject(self, user):
     if user:
         return User(user[1], user[2], user[3], user[4], user[5], user[0])
     else:
         return None
Beispiel #9
0
        invite_code_list.append(invite_code)
        session.add(invite_code)

    session.commit()

    for invite_code in invite_code_list:
        print(invite_code.code)

    SessionManager.Session.remove()

elif args.user_add is not None:
    session = SessionManager.Session()
    username = args.user_add[0]
    password = args.user_add[1]
    user = User(name=username,
                password=generate_password_hash(password),
                level=User.LEVEL_DEFAULT)
    session.add(user)
    session.commit()
    print('Successfully create user, id is %s' % user.id)
    SessionManager.Session.remove()

elif args.user_del is not None:
    session = SessionManager.Session()
    username = args.user_del[0]
    session.query(User).filter(User.name == username).delete()
    session.commit()
    print('Delete successfully')
    SessionManager.Session.remove()

elif args.user_promote is not None:
Beispiel #10
0
from tinydb import TinyDB
from UtilitiesProvider import UtilitiesProvider
from domain.Product import Product
from domain.User import User

UtilitiesProvider.create()
repo = UtilitiesProvider.repo
userRepo = UtilitiesProvider.userRepo

repo.clear()

images = ['1610111869636.jpeg', '1610112228568.jpeg', '1610112264625.jpeg']

for i in range(3):
    product = Product(i.__str__(), "Lapte" + i.__str__(), "10", "200",
                      images[i], 44.87549767121354, 24.841699598127455)
    product.username = "******"
    repo.addProduct(product)

userRepo.addUser(User("a", "a"))
userRepo.addUser(User("b", "b"))
Beispiel #11
0
        invite_code = InviteCode()
        invite_code_list.append(invite_code)
        session.add(invite_code)

    session.commit()

    for invite_code in invite_code_list:
        print(invite_code.code)

    SessionManager.Session.remove()

elif args.user_add is not None:
    session = SessionManager.Session()
    username = args.user_add[0]
    password = args.user_add[1]
    user = User(name=username, password=generate_password_hash(password), level=User.LEVEL_DEFAULT)
    session.add(user)
    session.commit()
    print('Successfully create user, id is %s' % user.id)
    SessionManager.Session.remove()

elif args.user_del is not None:
    session = SessionManager.Session()
    username = args.user_del[0]
    session.query(User).filter(User.name==username).delete()
    session.commit()
    print('Delete successfully')
    SessionManager.Session.remove()

elif args.user_promote is not None:
    session = SessionManager.Session()
Beispiel #12
0
from domain.User import User
from util.Icons import get_icant
from util.Icons import get_ihate
from util.Icons import get_ilove
from util.Images import get_image_list
from util.Questions import get_final_flag
from util.Questions import get_first_question_response
from util.Questions import get_second_question_response
from util.Questions import get_third_question_response
from util.machine_learning import predict_choice
from util.text_mining import adventure_filter

app = Flask(__name__)
CORS(app)
dishes = []
new_user = User()
new_user.load_dishes()


@app.route('/profileGeneral', methods=['GET'])
def getProfileGeneral():
    new_user = User()
    new_user.load_dishes()

    art = request.args.get('art')
    if art == 'ILove':
        print(get_ilove())
        return Response(js.dumps(get_ilove()), mimetype='application/json')
    elif art == 'IHate':
        return Response(js.dumps(get_ihate()), mimetype='application/json')
    elif art == 'ICant':