Exemplo n.º 1
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
Exemplo n.º 2
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
Exemplo n.º 3
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
Exemplo n.º 4
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