Example #1
0
    def remove(self, user_id, aspect_ids):
        """Remove user from aspects of given ids.

        :param user_id: user guid
        :type user_id: str
        :param aspect_ids: list of aspect ids
        :type aspect_ids: list
        """
        for aid in aspect_ids:
            Aspect(self._connection, aid).removeUser(user_id)
Example #2
0
    def add(self, user_id, aspect_ids):
        """Add user to aspects of given ids.

        :param user_id: user guid
        :type user_id: str
        :param aspect_ids: list of aspect ids
        :type aspect_ids: list
        """
        for aid in aspect_ids:
            Aspect(self._connection, aid).addUser(user_id)
Example #3
0
    def add(self, aspect_name, visible=0):
        """This function adds a new aspect.
        Status code 422 is accepted because it is returned by D* when
        you try to add aspect already present on your aspect list.

        :returns: Aspect() object of just created aspect
        """
        data = {
            'authenticity_token': self._connection.get_token(),
            'aspect[name]': aspect_name,
            'aspect[contacts_visible]': visible
        }

        request = self._connection.post('aspects', data=data)
        if request.status_code not in [200, 422]:
            raise Exception('wrong status code: {0}'.format(
                request.status_code))

        id = self.getAspectID(aspect_name)
        return Aspect(self._connection, id)
Example #4
0
    def add(self, user_id, aspect_ids):
        """Add user to aspects of given ids.

		:param user_id: user id (not guid)
		:type user_id: str
		:param aspect_ids: list of aspect ids
		:type aspect_ids: list
		:returns: dict
		"""
        # TODO update self.contacts
        for aid in aspect_ids:
            new_aspect_membership = Aspect(self._connection,
                                           aid).addUser(user_id)

            # user.
            if new_aspect_membership:
                for user in self.contacts:
                    if int(user.data['person_id']) == int(user_id):
                        user.data['aspect_memberships'].append(
                            new_aspect_membership)
                        return new_aspect_membership