Beispiel #1
0
    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))
Beispiel #2
0
    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))
Beispiel #3
0
    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())
Beispiel #4
0
    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))
Beispiel #5
0
Datei: me.py Projekt: szkocka/api
 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'
                 }
         }
     )
Beispiel #6
0
    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())
Beispiel #7
0
 def get(self, research, current_user):
     relationship_types = self.__get_relationship_type(current_user, research)
     return ok(ResearchDetailsJson(research, relationship_types))
Beispiel #8
0
 def get(self):
     tags = Research.all_tags()
     return ok(TagsJson(tags))
Beispiel #9
0
 def get(self):
     about_page = AboutPage.get(1)
     return ok({'content': about_page.content})
Beispiel #10
0
    def get(self, current_user, user):
        cursor = request.args.get('cursor')
        forums, cursor, _ = Forum.by_creator(user.key, cursor)

        return ok(ListForumsJson(forums, cursor))
Beispiel #11
0
 def get(self, current_user, forum):
     cursor = request.args.get('cursor')
     messages, cursor, _ = Message.by_forum(forum.key, cursor)
     return ok(ListMessagesJson(messages, cursor))
Beispiel #12
0
    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())
Beispiel #13
0
    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))
Beispiel #14
0
    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))
Beispiel #15
0
    def get(self, current_user, user):
        cursor = request.args.get('cursor')
        messages, cursor, _ = Message.by_creator(user.key, cursor)

        return ok(ListMessagesJson(messages, cursor))
Beispiel #16
0
    def get(self, current_user, research):
        cursor = request.args.get('cursor')
        forums, cursor, _ = Forum.by_research(research.key, cursor)

        return ok(ListForumsJson(forums, cursor))
Beispiel #17
0
 def get(self, current_user, forum):
     return ok(ForumJson(forum))
Beispiel #18
0
    def get(self):
        cursor = request.args.get('cursor')
        result, cursor, _ = News.all(cursor)

        return ok(ListNewsJson(result, cursor))