Beispiel #1
0
    def __get_relationship_type(self, current_user, research):
        relationship_types = {}
        if current_user:
            relationship = ResearchRelationship.get(research.key, current_user.email)
            if relationship:
                relationship_types[research.key.id()] = relationship.type

        return relationship_types
Beispiel #2
0
    def post(self, research, user, current_user):
        relationship = ResearchRelationship.get(research.key, user.email)

        if not relationship or relationship.type != RelationshipType.WANTS_TO_JOIN:
            return bad_request('User don\'t want to join.')

        relationship.type = RelationshipType.REJECTED
        relationship.put()

        return ok_msg('Researcher rejected.')
Beispiel #3
0
Datei: me.py Projekt: szkocka/api
    def post(self, current_user, research):
        relationship = ResearchRelationship.get(research.key, current_user.email)

        if not relationship or relationship.type != RelationshipType.INVITED:
            return bad_request('You not invited.')

        relationship.type = RelationshipType.REJECTED
        relationship.put()

        return ok_msg('Invitation rejected.')
Beispiel #4
0
    def post(self, research, user, current_user):
        relationship = ResearchRelationship.get(research.key, user.email)

        if not relationship or relationship.type != RelationshipType.WANTS_TO_JOIN:
            return bad_request('User don\'t want to join.')

        research.researchers_keys.append(user.key)
        research.put()

        relationship.type = RelationshipType.APPROVED
        relationship.put()

        user.researcher_in += 1
        user.put()

        return ok_msg('Researcher accepted.')
Beispiel #5
0
Datei: me.py Projekt: szkocka/api
    def post(self, current_user, research):
        relationship = ResearchRelationship.get(research.key, current_user.email)

        if not relationship or relationship.type != RelationshipType.INVITED:
            return bad_request('You not invited.')

        research.researchers_keys.append(current_user.key)
        research.put()

        relationship.type = RelationshipType.ACCEPTED
        relationship.put()

        current_user.researcher_in += 1
        current_user.put()

        return ok_msg('Invitation accepted.')
Beispiel #6
0
 def __delete_relationship(self, research, user):
     relationship = ResearchRelationship.get(research.key, user.email)
     relationship.key.delete()
Beispiel #7
0
 def __relationship_exists(self, research, recipient):
     return ResearchRelationship.get(research.key, recipient)
Beispiel #8
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 #9
0
Datei: me.py Projekt: szkocka/api
 def get(self, current_user):
     relationships = ResearchRelationship.by_email_and_type(current_user.email, RelationshipType.INVITED)
     researches = map(lambda r: r.research_key.get(), relationships)
     return ListMyInvitations(researches).js()