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()
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
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) }
def remove_event_from_user(user_urlsafe, key): user = User.get(user_urlsafe) if key in user.events: user.events.remove(key) user.put()
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()
def remove_tag_from_user(user_urlsafe, key): user = User.get(user_urlsafe) if key in user.tags: user.tags.remove(key) user.put()
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()
def get_user_events(urlsafe): user = User.get(urlsafe) return user.events
def get_user_tags(urlsafe): user = User.get(urlsafe) return user.tags