コード例 #1
0
ファイル: api.py プロジェクト: millerns/csse483
 def assignment_insert(self, assignment):
     """ Add or update an assignment owned by the given user """
     if assignment.from_datastore:
         assignment_with_parent = assignment
     else: assignment_with_parent = Assignment(parent = main.get_parent_key(endpoints.get_current_user()), 
                                               name = assignment.name)
     assignment_with_parent.put()
     return assignment_with_parent
コード例 #2
0
ファイル: api.py プロジェクト: oakesja/csse483
 def assignment_insert(self, assignment):
     if assignment.from_datastore:
         assignment_with_parent = assignment
     else:
         assignment_with_parent = Assignment(parent=main.get_parent_key(endpoints.get_current_user()), 
                                             name=assignment.name)
     assignment_with_parent.put()
     return assignment_with_parent
コード例 #3
0
 def note_insert(self, note):
     if note.from_datastore:
         note_with_parent = note
     else:
         note_with_parent = Note(parent=main.get_parent_key(endpoints.get_current_user()),
                                 note = note.note, company_entity_key = note.company_entity_key)
          
     note_with_parent.put()
     return note_with_parent
コード例 #4
0
 def favorite_insert(self, favorite):
     if favorite.from_datastore:
         favorite_with_parent = favorite
     else:
         favorite_with_parent = Favorite(parent=main.get_parent_key(endpoints.get_current_user()),
                                 company_entity_key = favorite.company_entity_key)
          
     favorite_with_parent.put()
     return favorite_with_parent
コード例 #5
0
    def favorite_insert(self, favorite):
        if favorite.from_datastore:
            favorite_with_parent = favorite
        else:
            favorite_with_parent = Favorite(
                parent=main.get_parent_key(endpoints.get_current_user()),
                company_entity_key=favorite.company_entity_key)

        favorite_with_parent.put()
        return favorite_with_parent
コード例 #6
0
 def note_for_company(self, request):
     user = endpoints.get_current_user()
     query = Note.query(ancestor=main.get_parent_key(user)).filter(Note.company_entity_key == request.company_entity_key)
     
     returnNote = Note(note="", company_entity_key=request.company_entity_key)
     
     for note in query:
         returnNote = note
         break
     
     return returnNote
コード例 #7
0
    def note_insert(self, note):
        if note.from_datastore:
            note_with_parent = note
        else:
            note_with_parent = Note(parent=main.get_parent_key(
                endpoints.get_current_user()),
                                    note=note.note,
                                    company_entity_key=note.company_entity_key)

        note_with_parent.put()
        return note_with_parent
コード例 #8
0
 def favorite_for_company(self, request):
     user = endpoints.get_current_user()
     query = Favorite.query(ancestor=main.get_parent_key(user)).filter(Favorite.company_entity_key == request.company_entity_key)
     
     returnFavorite = Favorite(message="null")
     
     for favorite in query:
         returnFavorite = favorite
         break
     
     return returnFavorite
コード例 #9
0
    def favorite_for_company(self, request):
        user = endpoints.get_current_user()
        query = Favorite.query(ancestor=main.get_parent_key(user)).filter(
            Favorite.company_entity_key == request.company_entity_key)

        returnFavorite = Favorite(message="null")

        for favorite in query:
            returnFavorite = favorite
            break

        return returnFavorite
コード例 #10
0
    def company_insert_favorite(self, request):
        user = endpoints.get_current_user()
        favBool = request.favorite
        key = ndb.Key(urlsafe=request.entityKey)

        query_favorite = Favorite.query(
            ancestor=main.get_parent_key(user)).filter(
                Favorite.company_entity_key == key)

        my_favorite = Favorite(parent=main.get_parent_key(user),
                               company_entity_key=key)

        found = False

        logging.info(favBool)

        for item in query_favorite:
            logging.info("favorite logged")
            my_favorite = item
            found = True

        logging.info(my_favorite)

        if favBool:

            logging.info("favorite bool = True")

            if not found:

                logging.info("creating favorite")
                #                 my_favorite = Favorite(parent=main.get_parent_key(user), company_entity_key=key)
                my_favorite.put()
        else:

            if found:
                logging.info("delete")
                my_favorite.key.delete()

        return request
コード例 #11
0
    def note_for_company(self, request):
        user = endpoints.get_current_user()
        query = Note.query(ancestor=main.get_parent_key(user)).filter(
            Note.company_entity_key == request.company_entity_key)

        returnNote = Note(note="",
                          company_entity_key=request.company_entity_key)

        for note in query:
            returnNote = note
            break

        return returnNote
コード例 #12
0
 def profile_insert(self, request):
     """ insert or update profile """
     if request.from_datastore:
         my_profile_with_parent = request
     else:
         my_profile_with_parent = Profile(parent = main.get_parent_key(endpoints.get_current_user()), 
                                          first_name=request.first_name, 
                                          last_name=request.last_name,
                                          phone_number=request.phone_number, 
                                          friends=request.friends,
                                          events=request.events)
     my_profile_with_parent.put()
     return my_profile_with_parent
コード例 #13
0
 def company_list_favorite(self, query):
     # list of companies with favorite boolean attached to favorites
     user = endpoints.get_current_user()
     
     for company in query:
         company.favorite = False
         
         key = ndb.Key(urlsafe=company.entityKey)
         favQuery = Favorite.query(ancestor=main.get_parent_key(user)).filter(Favorite.company_entity_key == key)
         
         for favorite in favQuery:
             company.favorite = True
        
     return query
コード例 #14
0
 def profile_insert(self, request):
     """ insert or update profile """
     if request.from_datastore:
         my_profile_with_parent = request
     else:
         my_profile_with_parent = Profile(parent=main.get_parent_key(
             endpoints.get_current_user()),
                                          first_name=request.first_name,
                                          last_name=request.last_name,
                                          phone_number=request.phone_number,
                                          friends=request.friends,
                                          events=request.events)
     my_profile_with_parent.put()
     return my_profile_with_parent
コード例 #15
0
    def company_insert_favorite(self, request):
        user = endpoints.get_current_user()
        favBool = request.favorite
        key = ndb.Key(urlsafe=request.entityKey)
        
        query_favorite = Favorite.query(ancestor=main.get_parent_key(user)).filter(Favorite.company_entity_key == key)
        
        my_favorite = Favorite(parent=main.get_parent_key(user), company_entity_key=key)
        
        found = False
        
        logging.info(favBool)
        
        for item in query_favorite:
            logging.info("favorite logged")
            my_favorite = item
            found = True
        
        logging.info(my_favorite)
        
        if favBool:
            
            logging.info("favorite bool = True")
            
            if not found:
                
                logging.info("creating favorite")
#                 my_favorite = Favorite(parent=main.get_parent_key(user), company_entity_key=key)
                my_favorite.put()
        else:
            
            if found:
                logging.info("delete")
                my_favorite.key.delete()
            
        return request
コード例 #16
0
    def company_list_favorite(self, query):
        # list of companies with favorite boolean attached to favorites
        user = endpoints.get_current_user()

        for company in query:
            company.favorite = False

            key = ndb.Key(urlsafe=company.entityKey)
            favQuery = Favorite.query(
                ancestor=main.get_parent_key(user)).filter(
                    Favorite.company_entity_key == key)

            for favorite in favQuery:
                company.favorite = True

        return query
コード例 #17
0
 def student_list(self, query):
     """ List all the students for a given user """
     user = endpoints.get_current_user()
     students = Student.query(ancestor=main.get_parent_key(user)).order(Student.rose_username)
     return students
コード例 #18
0
ファイル: api.py プロジェクト: oakesja/csse483
 def assignments_list(self, query):
     user = endpoints.get_current_user()
     assignments = Assignment.query(ancestor=main.get_parent_key(user)).order(Assignment.name)
     return assignments
コード例 #19
0
 def profile_get(self, query):
     """ get the current user's profile """
     user = endpoints.get_current_user()
     profile = Profile.query(ancestor=main.get_parent_key(user)).order(
         Profile.first_name)
     return profile
コード例 #20
0
 def profile_get(self, query):
     """ get the current user's profile """
     user = endpoints.get_current_user()
     profile=Profile.query(ancestor=main.get_parent_key(user)).order(Profile.first_name)
     return profile
コード例 #21
0
 def assignment_list(self, query):
     """ List all the assignments owned by the given user """
     user = endpoints.get_current_user()
     assignments = Assignment.query(ancestor=main.get_parent_key(user)).order(Assignment.name)
     return assignments
コード例 #22
0
ファイル: api.py プロジェクト: oakesja/csse483
 def student_list(self, query):
     user = endpoints.get_current_user()
     students = Student.query(ancestor=main.get_parent_key(user)).order(Student.rose_username)
     return students