示例#1
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()
示例#2
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
示例#3
0
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)
            }
示例#4
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()
示例#5
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()
示例#6
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()
示例#7
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()
示例#8
0
def get_user_events(urlsafe):
    user = User.get(urlsafe)
    return user.events
示例#9
0
def get_user_tags(urlsafe):
    user = User.get(urlsafe)
    return user.tags