def get(self, current_user): cursor = request.args.get('cursor') keyword = request.args.get('keyword') users, cursor, _ = User.find_all(cursor, keyword) return ok(ListUsers(users, cursor))
def get(self, current_user): relationship_types = get_relationship_types(current_user) cursor = request.args.get('cursor') researches, cursor, _ = Research.all(cursor) return ok(ListResearchesJson(researches, relationship_types, cursor))
def post(self): email = request.json['email'] hashed_pass = hash_password(request.json['password']) user = User.by_email_and_password(email, hashed_pass) if not user: return unauthorized('User not found.') return ok(Token(user.key.id()).json())
def get(self): args = request.args logging.info(args) keyword = args.get('keyword') status = args.get('status', StatusType.ACTIVE) tag = args.get('tag') page = args.get('page', 0) researches = ResearchIndex.find(keyword, status, tag, page) return ok(ResearchesSearchResultJson(researches))
def get(self, current_user): return ok( { 'user': { '_id': current_user.key.id(), 'name': current_user.name, 'email': current_user.email, 'role': 'admin' if current_user.is_admin else 'user', 'provider': 'local' } } )
def put(self, research, current_user): json = request.json research.title = json.get('title', research.title) research.tags = json.get('tags', research.tags) research.tags = json.get('tags', research.tags) research.area = json.get('area', research.area) research.status = json.get('status', research.status) research.image_url = json.get('image_url', research.image_url) description = json.get('description', {}) research.brief_desc = description.get('brief', research.brief_desc) research.detailed_desc = description.get('detailed', research.detailed_desc) research_key = research.put() add_task(research_key) return ok(ResearchIdJson(research_key).js())
def get(self, research, current_user): relationship_types = self.__get_relationship_type(current_user, research) return ok(ResearchDetailsJson(research, relationship_types))
def get(self): tags = Research.all_tags() return ok(TagsJson(tags))
def get(self): about_page = AboutPage.get(1) return ok({'content': about_page.content})
def get(self, current_user, user): cursor = request.args.get('cursor') forums, cursor, _ = Forum.by_creator(user.key, cursor) return ok(ListForumsJson(forums, cursor))
def get(self, current_user, forum): cursor = request.args.get('cursor') messages, cursor, _ = Message.by_forum(forum.key, cursor) return ok(ListMessagesJson(messages, cursor))
def get(self, research, current_user): relationships = ResearchRelationship.by_research_and_type(research.key, RelationshipType.WANTS_TO_JOIN) users = map(lambda r: User.by_email(r.user_email), relationships) return ok(ListReqToJoin(users).js())
def get(self, current_user, user): relationship_types = get_relationship_types(user) cursor = request.args.get('cursor') users, cursor, _ = Research.by_user(user.key, cursor) return ok(ListUserResearchesJson(users, relationship_types, cursor))
def get(self, current_user, user): supervisor_of = Research.by_supervisor(user.key) researcher_in = Research.by_researcher(user.key) return ok(UserDetailsJson(user, supervisor_of, researcher_in))
def get(self, current_user, user): cursor = request.args.get('cursor') messages, cursor, _ = Message.by_creator(user.key, cursor) return ok(ListMessagesJson(messages, cursor))
def get(self, current_user, research): cursor = request.args.get('cursor') forums, cursor, _ = Forum.by_research(research.key, cursor) return ok(ListForumsJson(forums, cursor))
def get(self, current_user, forum): return ok(ForumJson(forum))
def get(self): cursor = request.args.get('cursor') result, cursor, _ = News.all(cursor) return ok(ListNewsJson(result, cursor))