def get_members(self, filters=None): """Get members with filter :filters: dict containing query parameters. Eg. {'fields': 'all', 'filter': 'admins'} More info on possible filters: https://developers.trello.com/advanced-reference/board#get-1-boards-board-id-members :rtype: list of Member """ json_obj = self.client.fetch_json( '/boards/' + self.id + '/members', query_params=filters) members = list() for obj in json_obj: m = Member(self.client, obj['id']) m.status = obj.get('status', '') m.id = obj.get('id', '') m.bio = obj.get('bio', '') m.url = obj.get('url', '') m.username = obj['username'] m.full_name = obj['fullName'] m.initials = obj.get('initials', '') m.member_type = obj.get('memberType', '') members.append(m) return members
def clean(self): cleaned_data = super(TrelloSignUpForm, self).clean() # Get Trello remote data trello_client = TrelloClient( api_key=self.cleaned_data["api_key"], api_secret="xxx", token=self.cleaned_data["token"], token_secret=self.cleaned_data["token_secret"]) trello_member = TrelloMember(client=trello_client, member_id="me") try: trello_member.fetch() except Exception: raise ValidationError( u"Exception when dealing with Trello connection. Are your credentials right?" ) self.cleaned_data["uuid"] = trello_member.id self.cleaned_data["trello_username"] = trello_member.username self.cleaned_data["initials"] = trello_member.initials # Check if the user is already registered in the system. # To do so, we have to check if this Trello Member Profile has already an associated user if TrelloMemberProfile.objects.filter( trello_id=self.cleaned_data["uuid"], member__user__isnull=False).exists(): raise ValidationError( u"This Trello username already has an user in this system") return self.cleaned_data
def list_members_from_card(card): members = [] if not _INCLUDE_MEMBERS or not card.member_id: return members for mid in card.member_id: if mid not in MEMBERS_CACHE: member = Member(CLIENT, mid) member.fetch() MEMBERS_CACHE[mid] = member.full_name members.append(MEMBERS_CACHE[mid]) return members
def printTeams(client, teams): print("TEAM;SPEND;EXPECTED;") for member_id in sorted(members): name = "" if trellovariables.MEMBERS.has_key(member_id): name = trellovariables.MEMBERS.get(member_id) else: p = Member(client, member_id) m = p.fetch() name = m.full_name print( "Warning: Hem d'afegir aquesta persona a la llista de MEMBERS: " + m.full_name + " : " + member_id) #Only print IT Teams if trellovariables.ITTEAMS.has_key(member_id): print("\"" + name + "\";" + str(teams.get(member_id)[0]) + ";" + str(teams.get(member_id)[1]) + ";")
def get_members(self): json_obj = self.client.fetch_json('/organizations/' + self.id + '/members', query_params={'filter': 'all'}) return [ Member.from_json(trello_client=self.client, json_obj=obj) for obj in json_obj ]
def get_members(self, filters=None): """Get members with filter :rtype: list of Member """ json_obj = self.client.fetch_json('/boards/' + self.id + '/members', query_params=filters) members = list() for obj in json_obj: m = Member(self.client, obj['id']) m.status = obj.get('status', '') m.id = obj.get('id', '') m.bio = obj.get('bio', '') m.url = obj.get('url', '') m.username = obj['username'] m.full_name = obj['fullName'] m.initials = obj.get('initials', '') m.member_type = obj.get('memberType', '') members.append(m) return members
def get_members(self): json_obj = self.client.fetch_json('/organizations/' + self.id + '/members', query_params={ 'filter': 'all', 'fields': 'id,fullName,username,initials' }) return [ Member.from_json(trello_client=self.client, json_obj=obj) for obj in json_obj ]
def clean(self): cleaned_data = super(TrelloMemberProfileForm, self).clean() # Get Trello remote data trello_client = TrelloClient( api_key=self.cleaned_data["api_key"], api_secret=self.cleaned_data["api_secret"], token=self.cleaned_data["token"], token_secret=self.cleaned_data["token_secret"]) trello_member = TrelloMember(client=trello_client, member_id="me") try: trello_member.fetch() except Exception: raise ValidationError( u"Exception when dealing with Trello connection. Are your credentials right?" ) self.cleaned_data["uuid"] = trello_member.id self.cleaned_data["username"] = trello_member.username self.cleaned_data["initials"] = trello_member.initials return self.cleaned_data
def get_members(self, filters=None): """Get members with filter :rtype: list of Member """ json_obj = self.client.fetch_json( '/boards/' + self.id + '/members', query_params=filters) members = list() for obj in json_obj: m = Member(self.client, obj['id']) m.status = obj.get('status', '') m.id = obj.get('id', '') m.bio = obj.get('bio', '') m.url = obj.get('url', '') m.username = obj['username'] m.full_name = obj['fullName'] m.initials = obj.get('initials', '') members.append(m) return members
] for label in card.idLabels: if labels.has_key(label): labels[label] = [ labels.get(label)[0] + spend, labels.get(label)[1] + estimated ] else: labels[label] = [spend, estimated] for member in card.idMembers: if not trellovariables.ITMEMBERS.has_key( member) and not trellovariables.ITTEAMS.has_key( member) and not trellovariables.MEMBERS.has_key( member): p = Member(client, member) m = p.fetch() name = m.full_name print( "Warning: Hem d'afegir aquesta persona a la llista de MEMBERS: " + m.full_name + " : " + member) if members.has_key(member): members[member] = [ members.get(member)[0] + spend, members.get(member)[1] + estimated ] else: members[member] = [spend, estimated] print("======= MEMBERS =========") printMembers(client, members)
def get_members(self): json_obj = self.client.fetch_json( '/organizations/' + self.id + '/members', query_params={'filter': 'all', 'fields': 'id,fullName,username,initials'}) return [Member.from_json(trello_client=self.client, json_obj=obj) for obj in json_obj]
def get_member(self, member_id): '''Get member :rtype: Member ''' return Member(self, member_id).fetch()
def search(self, query, partial_match=False, models=[], board_ids=[], org_ids=[], card_ids=[], cards_limit=10): """ Search trello given a query string. :param str query: A query string up to 16K characters :param bool partial_match: True means that trello will look for content that starts with any of the words in your query. :param list models: Comma-separated list of types of objects to search. This can be 'actions', 'boards', 'cards', 'members', or 'organizations'. The default is 'all' models. :param list board_ids: Comma-separated list of boards to limit search :param org_ids: Comma-separated list of organizations to limit search :param card_ids: Comma-separated list of cards to limit search :param cards_limit: The maximum number of cards to return (up to 1000) :return: All objects matching the search criterial. These can be Cards, Boards, Organizations, and Members. The attributes of the objects in the results are minimal; the user must call the fetch method on the resulting objects to get a full set of attributes populated. :rtype list: """ query_params = {'query': query} if partial_match: query_params['partial'] = 'true' # Limit search to one or more object types if models: query_params['modelTypes'] = models # Limit search to a particular subset of objects if board_ids: query_params['idBoards'] = board_ids if org_ids: query_params['idOrganizations'] = org_ids if card_ids: query_params['idCards'] = card_ids query_params['cards_limit'] = cards_limit # Request result fields required to instantiate class objects query_params['board_fields'] = ['name,url,desc,closed'] query_params['member_fields'] = ['fullName,initials,username'] query_params['organization_fields'] = ['name,url,desc'] json_obj = self.fetch_json('/search', query_params=query_params) if not json_obj: return [] results = [] board_cache = {} for board_json in json_obj.get('boards', []): # Cache board objects if board_json['id'] not in board_cache: board_cache[board_json['id']] = Board.from_json( self, json_obj=board_json) results.append(board_cache[board_json['id']]) for card_json in json_obj.get('cards', []): # Cache board objects if card_json['idBoard'] not in board_cache: board_cache[card_json['idBoard']] = Board( self, card_json['idBoard']) # Fetch the board attributes as the Board object created # from the card initially result lacks a URL and name. # This Board will be stored in Card.parent board_cache[card_json['idBoard']].fetch() results.append(Card.from_json(board_cache[card_json['idBoard']], card_json)) for member_json in json_obj.get('members', []): results.append(Member.from_json(self, member_json)) for org_json in json_obj.get('organizations', []): org = Organization.from_json(self, org_json) results.append(org) return results
def search(self, query, partial_match=False, models=[], board_ids=[], org_ids=[], card_ids=[]): """ Search trello given a query string. :param str query: A query string up to 16K characters :param bool partial_match: True means that trello will look for content that starts with any of the words in your query. :param list models: Comma-separated list of types of objects to search. This can be 'actions', 'boards', 'cards', 'members', or 'organizations'. The default is 'all' models. :param list board_ids: Comma-separated list of boards to limit search :param org_ids: Comma-separated list of organizations to limit search :param card_ids: Comma-separated list of cards to limit search :return: All objects matching the search criterial. These can be Cards, Boards, Organizations, and Members. The attributes of the objects in the results are minimal; the user must call the fetch method on the resulting objects to get a full set of attributes populated. :rtype list: """ query_params = {'query': query} if partial_match: query_params['partial'] = 'true' # Limit search to one or more object types if models: query_params['modelTypes'] = models # Limit search to a particular subset of objects if board_ids: query_params['idBoards'] = board_ids if org_ids: query_params['idOrganizations'] = org_ids if card_ids: query_params['idCards'] = card_ids # Request result fields required to instantiate class objects query_params['board_fields'] = ['name,url,desc,closed'] query_params['member_fields'] = ['fullName,initials,username'] query_params['organization_fields'] = ['name,url,desc'] json_obj = self.fetch_json('/search', query_params=query_params) if not json_obj: return [] results = [] board_cache = {} for board_json in json_obj.get('boards', []): # Cache board objects if board_json['id'] not in board_cache: board_cache[board_json['id']] = Board.from_json( self, json_obj=board_json) results.append(board_cache[board_json['id']]) for card_json in json_obj.get('cards', []): # Cache board objects if card_json['idBoard'] not in board_cache: board_cache[card_json['idBoard']] = Board( self, card_json['idBoard']) # Fetch the board attributes as the Board object created # from the card initially result lacks a URL and name. # This Board will be stored in Card.parent board_cache[card_json['idBoard']].fetch() results.append( Card.from_json(board_cache[card_json['idBoard']], card_json)) for member_json in json_obj.get('members', []): results.append(Member.from_json(self, member_json)) for org_json in json_obj.get('organizations', []): org = Organization.from_json(self, org_json) results.append(org) return results
def get_member(self, member_id): """Get member :rtype: Member """ return Member(self, member_id).fetch()
def get_members(self): json_obj = self.client.fetch_json( '/organizations/' + self.id + '/members', query_params={'filter': 'all'}) return [Member.from_json(trello_client=self.client, json_obj=obj) for obj in json_obj]
def getMemberName(client, member_id): m = Member(client, member_id) return m.fetch()