Skip to content

Feature/add rendering image attachments from trello cards #20

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 24 commits into
base: master
Choose a base branch
from

Conversation

Tomasz-Kluczkowski
Copy link

Add rendering of attachments from trello cards to HipChat.

  • Modified code base to save attachment type in CallbackEvent's payload.
  • Added get_attachment_type method to CallbackEvent to obtain file's mime signature.
  • Added custom filter is_image to confirm that the attachment is of image type when rendering a template.
  • Overridden addAttachmentToCard.html template to accept images and render them.
  • Added add_attachment_type admin method to add missing attachment types to already existing CallbackEvents in admin view.
  • Added necessary tests.
  • Added tests for CallbackEvent model to increase test coverage (from 52% initial coverage of models.py to 57%)

Added .idea/ to .gitignore.
Added requirements_dev.txt with initial requirements. Had to change psycopg2 version to 2.7.4 as it
was not compatible with postgres version.
Changed deps / requirements.txt to requirements_dev.txt and run tox.
Added coverage_reports folder produced by tox to .gitignore.
Added get_attachment_type method to Callbackevent. We are using requests
to obtain the initial chunk of the file (preventing downloading the
entire attachment). New dependencies were added - requests and
python-magic which helps to get the mime type. My assumption is that the
attachment's mime type signature is within the first 1024 bytes fo the
file (seems to be the case for almost all files but .iso).
Added python-magic and requests to requirements_dev.txt.
Added python-magic==0.4.15 to tox.ini and ran basic tests to confirm
base code works after adding get_attachment_type method to CallbackEvent.
Added addAttachmentToCard.json - json file produced by Trello with txt
attachment.
Added addAttachmentToCardImageType.json - json file produced by Trello
with image attachment.
Added tests for get_attachment_type method in test_models.py.
Had to mock out response object and file object to avoid relying on the
internet connection. This obviously means that the attachment types are
fed manually through use of mocks and we only test the logic of the
get_attachment_type method not the actual working of the
get / from_buffer.
Added logic confirming if event's payload data contains an attachment
key. If so the attachment type is added to payload using CallbackEvent's
get_attachment_type method and then event object is saved to the
database.
…saved.

Added test confirming that for events with attachment present the
attachment type is properly saved in the event's payload data.
To avoid connecting to the internet get_attachment_type is mocked out.
Added templatetags folder to test_app with:
__init_.py - standard for packages
test_app_tags.py - file containing new filter.
Added is_image filter which takes value passed from the template and
returns a bool (True for image attachments, false otherwise.)
Created tests folder in test_app with:
__init__.py - standard for packages
test_templatetags.py - file to put in template tags' tests for test_app.
Created tests folder in test_app with:
__init__.py - standard for packages
test_templatetags.py - file to put in template tags' tests for test_app.
Created addAttachmentToCard.html in test_app/templates/trello_webhooks
which will override the default one in trello_webhooks app.
Added conditional displaying of attached image if is_image template
filter returns True.
Added tests of CallbackEvent render method for modified
addAttachmentToCard.html template with image attachment and text
attachment.
To override template also during the test test_app must be above
trello_webhooks in the list of installed apps.
…Events.

Introduced add_attachment_type admin method for CallbackEvents allowing
easily add missing attachment types for events generated in the past.
Currently the method assumes only addAttachmentToCard event types
contain an attachment and hence the filtering of queryset with that
parameter. This can be extended if other events also contain attachments.
Added test for add_attachment admin method in test_admin.py.
Added test of human readable representations of CallbackEvent model.
Tested: __unicode__ (with object saved and not), __str__ and __repr__.
Added .flake8 - config file for flake8 linter.
Used 100 chars maximum line setting as per YunoJuno code style guide
online.
Fixed wrong indentation in send_to_hipchat method.
….py.

Fixed wrong indentation in urlpatterns.
…n.py.

Fixed missing 2 empty line separation.
…s/test_models.py.

Removed unused trello import.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant