예제 #1
0
    def from_json(cls, parent, json_obj):
        """
        Deserialize the card json object to a Card object

        :trello_list: the list object that the card belongs to
        :json_obj: json object
        """
        if 'id' not in json_obj:
            raise Exception("key 'id' is not in json_obj")
        card = cls(parent,
                   json_obj['id'],
                   name=json_obj['name'])
        card.desc = json_obj.get('desc', '')
        card.due = json_obj.get('due', '')
        card.closed = json_obj['closed']
        card.url = json_obj['url']
        card.pos = json_obj['pos']
        card.shortUrl = json_obj['shortUrl']
        card.idMembers = json_obj['idMembers']
        card.member_ids = json_obj['idMembers']
        card.idLabels = json_obj['idLabels']
        card.idBoard = json_obj['idBoard']
        card.idList = json_obj['idList']
        card.idShort = json_obj['idShort']
        card.labels = Label.from_json_list(card.board, json_obj['labels'])
        card.dateLastActivity = dateparser.parse(json_obj['dateLastActivity'])
        return card
예제 #2
0
    def fetch(self, eager=True):
        """
        Fetch all attributes for this card
        :param eager: If eager is true comments and checklists will be fetched immediately, otherwise on demand
        """
        json_obj = self.client.fetch_json(
            '/cards/' + self.id,
            query_params={'badges': False})
        self.id = json_obj['id']
        self.name = json_obj['name'].encode('utf-8')
        self.desc = json_obj.get('desc', '')
        self.closed = json_obj['closed']
        self.url = json_obj['url']
        self.shortUrl = json_obj['shortUrl']
        self.idMembers = json_obj['idMembers']
        self.idShort = json_obj['idShort']
        self.idList = json_obj['idList']
        self.idBoard = json_obj['idBoard']
        self.idLabels = json_obj['idLabels']
        self.labels = Label.from_json_list(self.board, json_obj['labels'])
        self.badges = json_obj['badges']
        self.pos = json_obj.get('pos', None)
        if json_obj.get('due', ''):
            self.due = json_obj.get('due', '')
        else:
            self.due = ''
        self.checked = json_obj['checkItemStates']
        self.dateLastActivity = dateparser.parse(json_obj['dateLastActivity'])

        self._checklists = self.fetch_checklists() if eager else None
        self._comments = self.fetch_comments() if eager else None
        self._attachments = self.fetch_attachments() if eager else None
예제 #3
0
파일: card.py 프로젝트: ivo-me/py-trello
    def from_json(cls, parent, json_obj):
        """
        Deserialize the card json object to a Card object

        :parent: the list object that the card belongs to
        :json_obj: json object

        :rtype: Card
        """
        if 'id' not in json_obj:
            raise Exception("key 'id' is not in json_obj")
        card = cls(parent, json_obj['id'], name=json_obj['name'])
        card.desc = json_obj.get('desc', '')
        card.due = json_obj.get('due', '')
        card.is_due_complete = json_obj['dueComplete']
        card.closed = json_obj['closed']
        card.url = json_obj['url']
        card.pos = json_obj['pos']
        card.shortUrl = json_obj['shortUrl']
        card.idMembers = json_obj['idMembers']
        card.member_ids = json_obj['idMembers']
        card.idLabels = json_obj['idLabels']
        card.idBoard = json_obj['idBoard']
        card.idList = json_obj['idList']
        card.idShort = json_obj['idShort']
        card.labels = Label.from_json_list(card.board, json_obj['labels'])
        card.dateLastActivity = dateparser.parse(json_obj['dateLastActivity'])
        if "attachments" in json_obj:
            card._attachments = []
            for attachment_json in json_obj["attachments"]:
                card._attachments.append(attachment_json)
        if 'actions' in json_obj:
            card.actions = json_obj['actions']
        return card
예제 #4
0
파일: card.py 프로젝트: ivo-me/py-trello
    def fetch(self, eager=True):
        """
        Fetch all attributes for this card

        :param eager: If eager, comments, checklists and attachments will be fetched immediately, otherwise on demand
        """
        json_obj = self.client.fetch_json('/cards/' + self.id,
                                          query_params={'badges': False})
        self.id = json_obj['id']
        self.name = json_obj['name']
        self.desc = json_obj.get('desc', '')
        self.closed = json_obj['closed']
        self.url = json_obj['url']
        self.shortUrl = json_obj['shortUrl']
        self.idMembers = json_obj['idMembers']
        self.idShort = json_obj['idShort']
        self.idList = json_obj['idList']
        self.idBoard = json_obj['idBoard']
        self.idLabels = json_obj['idLabels']
        self.labels = Label.from_json_list(self.board, json_obj['labels'])
        self.badges = json_obj['badges']
        self.pos = json_obj['pos']
        if json_obj.get('due', ''):
            self.due = json_obj.get('due', '')
        else:
            self.due = ''
        self.checked = json_obj['checkItemStates']
        self.dateLastActivity = dateparser.parse(json_obj['dateLastActivity'])

        self._plugin_data = self.fetch_plugin_data() if eager else None
        self._checklists = self.fetch_checklists() if eager else None
        self._comments = self.fetch_comments() if eager else None
        self._attachments = self.fetch_attachments() if eager else None
예제 #5
0
파일: card.py 프로젝트: rnwolf/py-trello
    def from_json(cls, parent, json_obj):
        """
        Deserialize the card json object to a Card object

        :trello_list: the list object that the card belongs to
        :json_obj: json object
        """
        if 'id' not in json_obj:
            raise Exception("key 'id' is not in json_obj")
        card = cls(parent, json_obj['id'], name=json_obj['name'])
        card.desc = json_obj.get('desc', '')
        card.due = json_obj.get('due', '')
        card.closed = json_obj['closed']
        card.url = json_obj['url']
        card.pos = json_obj['pos']
        card.shortUrl = json_obj['shortUrl']
        card.idMembers = json_obj['idMembers']
        card.member_ids = json_obj['idMembers']
        card.idLabels = json_obj['idLabels']
        card.idBoard = json_obj['idBoard']
        card.idList = json_obj['idList']
        card.idShort = json_obj['idShort']
        card.labels = Label.from_json_list(card.board, json_obj['labels'])
        card.dateLastActivity = dateparser.parse(json_obj['dateLastActivity'])
        return card
예제 #6
0
def printLabels(client, labels):
    print("LABEL;SPEND;EXPECTED;")
    for label_id in sorted(labels):
        name = ""
        if trellovariables.LABELS.has_key(label_id):
            name = trellovariables.LABELS.get(label_id)
        else:
            p = Label(client, label_id, "")
            m = p.fetch()
            name = m.name
            print(
                "Warning: Hem d'afegir aquesta etiqueta la llista de ITLABELS: "
                + str(m.name) + " : " + str(m.id))
        #Only print IT labels
        if trellovariables.ITLABELS.has_key(label_id):
            print("\"" + name + "\";" + str(labels.get(label_id)[0]) + ";" +
                  str(labels.get(label_id)[1]) + ";")
예제 #7
0
    def get_labels(self, fields='all', limit=50):
        """Get label

        :rtype: list of Label
        """
        json_obj = self.client.fetch_json(
              '/boards/' + self.id + '/labels',
              query_params={'fields': fields, 'limit': limit})
        return Label.from_json_list(self, json_obj)
예제 #8
0
파일: board.py 프로젝트: rnwolf/py-trello
    def get_labels(self, fields='all', limit=50):
        """Get label

        :rtype: list of Label
        """
        json_obj = self.client.fetch_json(
              '/boards/' + self.id + '/labels',
              query_params={'fields': fields, 'limit': limit})
        return Label.from_json_list(self, json_obj)
예제 #9
0
    def get_label(self, label_id, board_id):
        '''Get Label

        Requires the parent board id the label is on

        :rtype: Label
        '''
        board = self.get_board(board_id)
        label_json = self.fetch_json('/labels/' + label_id)
        return Label.from_json(board, label_json)
예제 #10
0
    def get_label(self, label_id, board_id):
        """Get Label

        Requires the parent board id the label is on

        :rtype: Label
        """
        board = self.get_board(board_id)
        label_json = self.fetch_json('/labels/' + label_id)
        return Label.from_json(board, label_json)
예제 #11
0
    def add_label(self, name, color):
        """Add a label to this board

        :name: name of the label
        :color: the color, either green, yellow, orange
            red, purple, blue, sky, lime, pink, or black
        :return: the label
        :rtype: Label
        """
        obj = self.client.fetch_json(
            '/labels',
            http_method='POST',
            post_args={'name': name, 'idBoard': self.id, 'color': color},)
        return Label.from_json(board=self, json_obj=obj)
예제 #12
0
파일: board.py 프로젝트: rnwolf/py-trello
    def add_label(self, name, color):
        """Add a label to this board

        :name: name of the label
        :color: the color, either green, yellow, orange
            red, purple, blue, sky, lime, pink, or black
        :return: the label
        :rtype: Label
        """
        obj = self.client.fetch_json(
            '/labels',
            http_method='POST',
            post_args={'name': name, 'idBoard': self.id, 'color': color},)
        return Label.from_json(board=self, json_obj=obj)
예제 #13
0
    def from_json(cls, parent, json_obj):
        """
        Deserialize the card json object to a Card object

        :trello_list: the list object that the card belongs to
        :json_obj: json object
        """
        if 'id' not in json_obj:
            raise Exception("key 'id' is not in json_obj")
        card = cls(parent,
                   json_obj['id'],
                   name=json_obj['name'].encode('utf-8'))
        card.desc = json_obj.get('desc', '')
        card.closed = json_obj['closed']
        card.url = json_obj['url']
        card.member_ids = json_obj['idMembers']
        card.idLabels = json_obj['idLabels']
        card.idList = json_obj['idList']
        card.labels = Label.from_json_list(card.board, json_obj['labels'])
        return card
예제 #14
0
    def from_json(cls, parent, json_obj):
        """
        Deserialize the card json object to a Card object

        :trello_list: the list object that the card belongs to
        :json_obj: json object
        """
        if 'id' not in json_obj:
            raise Exception("key 'id' is not in json_obj")
        card = cls(parent,
                   json_obj['id'],
                   name=json_obj['name'].encode('utf-8'))
        card.desc = json_obj.get('desc', '')
        card.closed = json_obj['closed']
        card.url = json_obj['url']
        card.member_ids = json_obj['idMembers']
        card.idLabels = json_obj['idLabels']
        card.idList = json_obj['idList']
        card.labels = Label.from_json_list(card.board, json_obj['labels'])
        return card
예제 #15
0
파일: card.py 프로젝트: sarumont/py-trello
    def from_json(cls, parent, json_obj):
        """
        Deserialize the card json object to a Card object

        :parent: the list object that the card belongs to
        :json_obj: json object

        :rtype: Card
        """
        if 'id' not in json_obj:
            raise Exception("key 'id' is not in json_obj")
        card = cls(parent,
                   json_obj['id'],
                   name=json_obj['name'])
        card._json_obj = json_obj
        card.desc = json_obj.get('desc', '')
        card.due = json_obj.get('due', '')
        card.is_due_complete = json_obj['dueComplete']
        card.closed = json_obj['closed']
        card.url = json_obj['url']
        card.pos = json_obj['pos']
        card.shortUrl = json_obj['shortUrl']
        card.idMembers = json_obj['idMembers']
        card.member_ids = json_obj['idMembers']
        card.idLabels = json_obj['idLabels']
        card.idBoard = json_obj['idBoard']
        card.idList = json_obj['idList']
        card.idShort = json_obj['idShort']
        card.badges = json_obj['badges']
        card.customFields = card.fetch_custom_fields(json_obj=json_obj)
        card._labels = Label.from_json_list(card.board, json_obj['labels'])
        card.dateLastActivity = dateparser.parse(json_obj['dateLastActivity'])
        if "attachments" in json_obj:
            card._attachments = []
            for attachment_json in json_obj["attachments"]:
                card._attachments.append(attachment_json)
        if 'actions' in json_obj:
            card.actions = json_obj['actions']
        return card
예제 #16
0
from trello.trellolist import List
from trello.label import Label

from . import enums as e

trello_client = TrelloClient(
    api_key='8c38f7619e8c0dbd0af427a6f145538f',
    api_secret='01d89258fa41a284468d9983eaec2a1f',
    token='46a437ceea33ce9c130d9ad4aea6bda1b7262225be966a858753d26f50bf4a8a',
    token_secret=
    '1af4d3041e6caa4165cfe1bace2115749db8d060d7e9dd67218a9e9667d0f8c3')

board = Board(client=trello_client, board_id=e.Board.INSTAGRAM.value)

list_complaints = List(board=board, list_id=e.List.COMPLAINTS.value)
list_on_progress = List(board=board, list_id=e.List.ON_PROGRESS.value)
list_done = List(board=board, list_id=e.List.DONE.value)

labels = {
    'transaksi': Label(trello_client, e.Label.TRANSAKSI.value, 'Transaksi'),
    'produk': Label(trello_client, e.Label.PRODUCT.value, 'Product'),
    'pengiriman': Label(trello_client, e.Label.PENGIRIMAN.value, 'Pengiriman'),
    'servis': Label(trello_client, e.Label.SERVICE.value, 'Service'),
    'pertanyaan': Label(trello_client, e.Label.PERTANYAAN.value, 'Pertanyaan'),
    'misuh': Label(trello_client, e.Label.MISUH.value, 'Misuh'),
    'lainnya': Label(trello_client, e.Label.LAINNYA.value, 'Lainnya')
}

from julid import settings as s
mongo_db = s.mongo_db
mongo_logs = s.mongo_logs