Django integration with a public slack organization (inspired by https://github.com/rauchg/slackin).
Install django-slackin
# (coming soon)
# pip install django-slackin
Add to your INSTALLED_APPS
INSTALLED_APPS = (
...
'slackin',
)
Include the django-slackin URLconf in your project urls.py like this
url(r'^slackin/', include('slackin.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
# optional settings
SLACKIN_LOGIN_REQUIRED = True # Redirect if user is not logged in. If False, the invite form will
# still be hidden for logged-out users.
SLACKIN_LOGIN_REDIRECT = '/' # Redirect URL for logged-out users; can be a URL or
# URLconf name (i.e. 'my_login_page')
SLACKIN_ULTRA_RESTRICTED_INVITES = True # only available for paid accounts
SLACKIN_SHOW_EMAIL_FORM = True # show/hide email form
Visit http://localhost:8000/slackin/ to send an invite to your Slack team.
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, user **kwargs):
print 'SIGNAL RECEIVED: {}, {}'.format(email_address, user)
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 surroundingbody
,head
, and inlined stylesslackin/invite/content.html
: the text and form
Templates have access to the following slackin-specific context variables:
slackin.team
: slack team info such as name, icons, etcslackin.users
: full list of team membersslackin.users_online
: number of team members currently onlineslackin.users_total
: total number of team membersslackin_invite_form
: invite form objectslackin_invite_form_success
:True
ifslackin_invite_form.is_valid()