Beispiel #1
0
def get_suggestions_dict(querier):
    from models_indexes import SuggestionFollowersIndex
    
    indexes = SuggestionFollowersIndex.all(keys_only=True).filter('keys =', querier.key()).order('-created').run()
    suggs = model_plus.fetch_parentsKeys([s for s in indexes])
    if isinstance(suggs, list) and any(suggs):
        suggestions = []
        for s in suggs: # convertir entidades
            setattr(s, 'lists', [])
            suggestions.append(s)
        suggestions = model_plus.prefetch(suggestions, Suggestion.user, Suggestion.poi) 
        return suggestions
    return []
Beispiel #2
0
            return event
        if event._is_public():
            lists = ListSuggestion.objects.get_by_suggestion(event, querier)
            setattr(event, 'lists', lists)
            return event
        elif event._is_shared() and event.user_invited(querier):
            lists = ListSuggestion.objects.get_by_suggestion(event, querier)
            setattr(event, 'lists', lists)
            return event
        return None

    def get_by_user_following(self, user, page=1, query_id=None, async=False):
        if not isinstance(user, User):
            raise TypeError
        from models_indexes import SuggestionFollowersIndex
        q = SuggestionFollowersIndex.all().filter('keys =', user.key())
        p = PagedQuery(q, id=query_id)
        if async:
            return p.id, q.run()
        from georemindme.funcs import fetch_parents
        suggestions = fetch_parents(p.fetch_page(page))
        return [p.id, suggestions]

    def load_suggestions_by_user_following(self, query_id, suggestions):
        from georemindme.funcs import fetch_parents
        suggestions = fetch_parents(suggestions)
        return [query_id, suggestions]

    def get_nearest(self, location, radius=5000, querier=None):
        if not isinstance(location, db.GeoPt):
            location = db.GeoPt(location)