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
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.')
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.')
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.')
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.')
def __delete_relationship(self, research, user): relationship = ResearchRelationship.get(research.key, user.email) relationship.key.delete()
def __relationship_exists(self, research, recipient): return ResearchRelationship.get(research.key, recipient)
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): relationships = ResearchRelationship.by_email_and_type(current_user.email, RelationshipType.INVITED) researches = map(lambda r: r.research_key.get(), relationships) return ListMyInvitations(researches).js()