Example #1
0
    def _post_put_hook(self, future):
        """Post put hook, adds user's username and real name to search index. This fires every time a user
         instance is saved
        """
        #TODO: this doesn't fire when user is registered, only on profile edit
        try:

            doc_id = find_users(self.username).results[0].doc_id
        except IndexError:
            doc_id = None

        if self.searchable:
            doc = create_user_search_document(self.username, self.real_name, self.gravatar, doc_id)
            add_to_index(doc, 'users')
        elif not self.searchable and doc_id:
            remove_from_index(doc_id, 'users')

        available_chat_rooms(self.username, self.get_all_courses())
Example #2
0
 def chat_rooms(self):
     rooms = memcache.get('chat_rooms', namespace=self.username)
     if not rooms:
         rooms = available_chat_rooms(self.username, self.get_all_courses())
     return rooms