Table of Contents

django-entity-event-slack Documentation

Django Entity Event Slack provides a pushable Slack medium for Django-Entity-Event.

Setup

To setup the Slack medium, you must create a Slack medium and associated it with the Slack API token and channel you want to post to.

from entity_event_slack.models import SlackMedium

slack_medium = SlackMedium.objects.create_slack_medium(
    channel='#my-slack-channel', api_token='my-slack-api-token')

In order for rendering to be performed correctly, context renderers with the appropriate style must be set up in accordance with the documentation of Django Entity Event. Assuming that your rendering style is set up, associated it with the slack medium.

from entity_event.models import RenderingStyle

style = RenderingStyle.objects.get(name='my_slack_style')
slack_medium.rendering_style = style
slack_medium.save()

Once this is done, subscriptions can be made for sources to the slack medium

# Subscribe sources to the slack medium
from entity_event.models import Source, Subscription

my_source = Source.objects.get(name='my_source')
Subscription.objects.create(medium=m, source=my_source)

A Celery task is provided with Django Entity Event Slack. It is called SendUnseenSlackNotificationsTask and can be configured to run at whatever interval you wish. When this is configured, you will start receiving Slack notifications.

Installation

To install the latest release, type:

pip install django-entity-event-slack

To install the latest code directly from source, type:

pip install git+git://github.com/ambitioninc/django-entity-event-slack.git

Code documentation

Contributing

Contributions and issues are most welcome! All issues and pull requests are handled through github on the ambitioninc repository. Also, please check for any existing issues before filing a new one. If you have a great idea but it involves big changes, please file a ticket before making a pull request! We want to make sure you don’t spend your time coding something that might not fit the scope of the project.

Running the tests

To get the source source code and run the unit tests, run:

git clone git://github.com/ambitioninc/django-entity-event-slack.git
cd django-entity-event-slack
virtualenv env
. env/bin/activate
python setup.py install
coverage run setup.py test
coverage report --fail-under=100

While 100% code coverage does not make a library bug-free, it significantly reduces the number of easily caught bugs! Please make sure coverage is at 100% before submitting a pull request!

Code Quality

For code quality, please run flake8:

pip install flake8
flake8 .

Code Styling

Please arrange imports with the following style

# Standard library imports
import os

# Third party package imports
from mock import patch
from django.conf import settings

# Local package imports
from entity_event_slack.version import __version__

Please follow Google’s python style guide wherever possible.

Building the docs

When in the project directory:

pip install -r requirements/docs.txt
python setup.py build_sphinx
open docs/_build/html/index.html

Release Checklist

Before a new release, please go through the following checklist:

  • Bump version in entity_event_slack/version.py

  • Add a release note in docs/release_notes.rst

  • Git tag the version

  • Upload to pypi:

    pip install wheel
    python setup.py sdist bdist_wheel upload
    

Vulnerability Reporting

For any security issues, please do NOT file an issue or pull request on github! Please contact security@ambition.com with the GPG key provided on Ambition’s website.

Release Notes

v0.2.0

  • Dropped Django 1.6 support
  • Added Python 3.4 support

v0.1.1

  • Made the slack API call be one call instead of multiple calls per push
  • Added the ability to configure an icon url for the slack bot
  • Added the ability to configure the user name for the slack bot

v0.1

  • This is the initial release of django-entity-event-slack.