コード例 #1
0
def add_user(username, password, email, phone_number):
    """Inserts new user to the database. Use for register purposes."""
    user = User(username=username,
                password=hash_password(password),
                email=email,
                type="user",
                tags=[],
                events=[])

    if phone_number:
        user.phone_numer = phone_number

    user.put()
コード例 #2
0
def remove_token(urlsafe):
    user = User.get(urlsafe)

    query = Token.query()
    query.add_filter('user', '=', user.key)
    query_list = list(query.fetch())

    if query_list:
        for token_entity in query_list:
            token_entity.remove()
コード例 #3
0
def get_user_role(urlsafe):
    user = User.get(urlsafe)

    if user.type == "user":
        return Roles.USER

    if user.type == "admin":
        return Roles.ADMIN

    return Roles.NEWBIE
コード例 #4
0
def exists_user(email, password):
    """Verify if the user exists in the datastore"""
    query = User.query()
    query.add_filter('email', '=', email)
    query_it = query.fetch()
    for ent in query_it:
        if ent is None:
            return None
        elif check_password(ent.password, password):
            return ent
    return None
コード例 #5
0
def get_user(username):
    """Verify if the user exists in the datastore"""
    query = User.query()
    query.add_filter('username', '=', username)
    query_it = query.fetch()
    for ent in query_it:
        if ent is None:
            return None
        else:
            return ent

    return None
コード例 #6
0
def sendSMSToAllUsers(nrEvents):
    if nrEvents > 1:
        allEvents = Event.all()
        for event in allEvents:
            if event.title != None and event.date != None and event.location != None:
                users = User.all()
                for user in users:
                    if user.phone_number != None:
                        sms.send_sms(
                            user.phone_number,
                            "Did you see the " + event.title + "It's on " +
                            event.date.strftime("%Y-%m-%d %H:%M") + " at " +
                            event.location +
                            "! Join our platform, there are " +
                            str(+nrEvents) + " new events!")
                return 'Mesaje trimise'
コード例 #7
0
ファイル: test.py プロジェクト: BotezMihai/Autonom
def get():
        req = list(RequestDB.all())
        if len(req) == 0:
            return {'status':'204','message': "No requests"}
        else:
            last = []
            for r in req:
                cerere = {}
                cerere['id']=r.urlsafe
                utilizator= User.get(  r.user )
                eveniment = Event.get(r.event)
                cerere['event']=eveniment.title
                cerere['user']= utilizator.username
                cerere['field']=r.field
                cerere['modification']=r.modification
                cerere['state']=r.state

                last.append(cerere)


            return {
                'status': '200',
                'links':json.dumps(last)
            }
コード例 #8
0
def remove_event_from_user(user_urlsafe, key):
    user = User.get(user_urlsafe)
    if key in user.events:
        user.events.remove(key)
    user.put()
コード例 #9
0
def add_event_to_user(user_urlsafe, key):
    user = User.get(user_urlsafe)
    if key not in user.events:
        user.events.append(key)
    user.put()
コード例 #10
0
def remove_tag_from_user(user_urlsafe, key):
    user = User.get(user_urlsafe)
    if key in user.tags:
        user.tags.remove(key)
    user.put()
コード例 #11
0
def add_tag_to_user(user_urlsafe, key):
    user = User.get(user_urlsafe)
    if key not in user.tags:
        user.tags.append(key)
    user.put()
コード例 #12
0
def get_user_events(urlsafe):
    user = User.get(urlsafe)
    return user.events
コード例 #13
0
def get_users():
    return User.all()
コード例 #14
0
def get_user_tags(urlsafe):
    user = User.get(urlsafe)
    return user.tags