card = trello_api.get_card_by_id(note.id)
 new_card = False
 if card:
     # update the card
     card_title = note.content
     if len(card_title) == 0 or media.link == card_title:
         card_title = "[no description]"
     trello_api.update_card(note.id, card_title, new_desc)
 else:
     # create the card
     new_card = True
     n = n + 1
     note.status = str(note.created_at.date())
     db.session.commit()
     if len(note.content) == 0:
         card = trello_api.add_card_with_attachment(note.id, media.link, new_desc, note.status, media.get_url())
     else:
         card = trello_api.add_card_with_attachment(note.id, note.content, new_desc, note.status, media.get_url())
 # updating comments
 for comment in feedbacks_comment:
     account = Account.query.filter_by(id=comment.account_id).first()
     name = 'The Design Team'
     if account:
         name = account.username
     if new_card:
         print "Adding comment to a new card."
         trello_api.add_comment_card(note.id, card.name, "[" + name + "] " + comment.content)
     else:
         e = trello_api.comment_exists(card, comment.content)
         if not e:
             print "Adding comment to an existing card."
Example #2
0

import trello_api
from db_def import Note
from db_def import Media

print trello_api.KEY

print "Testing: add a card with attachment."

trello_api.create_client()
note = Note.query.get(194)
media = Media.query.filter_by(note_id=194).first()
trello_api.add_card_with_attachment(194, note.content, note.to_trello_desc(), note.status,
                                    media.get_url())

print "Done."