Ejemplo n.º 1
0
    def autocomplete_mentions(self, text: str, prefix_string: str
                              ) -> List[str]:
        # Handles user mentions (@ mentions and silent mentions)
        # and group mentions.
        group_typeahead = ['@*{}*'.format(group_name)
                           for group_name in self.model.user_group_names
                           if match_group(group_name, text[1:])]

        users_list = self.view.users
        user_typeahead = [prefix_string+'**{}**'.format(user['full_name'])
                          for user in users_list
                          if match_user(user, text[len(prefix_string):])]
        combined_typeahead = group_typeahead + user_typeahead

        return combined_typeahead
Ejemplo n.º 2
0
    def autocomplete_mentions(
            self, text: str,
            prefix_string: str) -> Tuple[List[str], List[str]]:
        # Handles user mentions (@ mentions and silent mentions)
        # and group mentions.
        groups = [
            group_name for group_name in self.model.user_group_names
            if match_group(group_name, text[1:])
        ]
        group_typeahead = format_string(groups, '@*{}*')

        users_list = self.view.users
        users = [
            user['full_name'] for user in users_list
            if match_user(user, text[len(prefix_string):])
        ]
        user_typeahead = format_string(users, prefix_string + '**{}**')

        combined_typeahead = group_typeahead + user_typeahead
        combined_names = groups + users

        return combined_typeahead, combined_names