Skip to content

mtlpy/django-slackin-public

 
 

Repository files navigation

django-slackin-public

Version License PythonVersions Build

Slack invitation page for Django (like https://github.com/rauchg/slackin)

Installation & setup

Install django-slackin-public

# pip install django-slackin-public

Add to your INSTALLED_APPS

INSTALLED_APPS = (
    ...
    'django_slackin_public',
)

Include the django-slackin-public URLconf in your project urls.py like this

url(r'^slackin/', include('django_slackin_public.urls')),

Update your settings.py

SLACKIN_TOKEN = 'YOUR-SLACK-TOKEN' # create a token at https://api.slack.com/web
SLACKIN_SUBDOMAIN = 'your-team'    # if https://your-team.slack.com

Visit http://localhost:8000/slackin/ to send an invite to your Slack team.

Using signals

Use signals to listen for invite events. Available signals are:

  • email_address_already_invited
  • email_address_already_in_team
  • sent_invite_to_email_address

To listen for a signal:

from slackin.signals import sent_invite_to_email_address

@receiver(sent_invite_to_email_address)
def my_invite_handler(sender, email_address):
    print 'SIGNAL RECEIVED: {}'.format(email_address)

Custom templates

To use custom templates, add the either of following files to your app's template directory depending on what you want to customize. See templates/slackin for more details.

  • slackin/invite/page.html: the surrounding body, head, and inlined styles
  • slackin/invite/content.html: the text and form

Templates have access to the following slackin-specific context variables:

  • slackin.team_name: slack team name
  • slackin.team_image: slack team image
  • slackin.users_online: number of team members currently online
  • slackin.users_total: total number of team members
  • slackin_invite_form: invite form object
  • slackin_invite_form_success: True if slackin_invite_form.is_valid()

Development

Using Dad

$ dad clone mtlpy/django-slackin-public
...

$ dad up
...

$ dad lint
...

Release

  • Change the version in setup.py
  • Commit with message like Release vX.X.X
  • Run dad upload-release