Skip to content

Commit

Permalink
User settings configured
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchagrins committed Aug 7, 2017
1 parent 24c6c1b commit 7502e85
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions settings.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[SLACK-SETTINGS]
slack-team=TEAM NAME
slack-url=TEAM-NAME.slack.com
slack-token=<enter slack token>
SLACK_TEAM=Team Name
SLACK_URL=TEAM-NAME.slack.com
SLACK_TOKEN=<enter slack token>
22 changes: 11 additions & 11 deletions slack_invite/slack_invite/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@

import os
import configparser
from django.core.exceptions import ImproperlyConfigured

# SECURITY WARNING: Keep you slack token private in production
def get_env_variable(var_name):
try:
return os.environ[var_name]
except KeyError:
error_msg = "Set the %s environment variable" % var_name
raise ImproperlyConfigured(error_msg)
if var_name in os.environ:
return os.environ.get(var_name)
else:
return config['SLACK-SETTINGS'][var_name]

slack_token = get_env_variable('SLACK_TOKEN')
path = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
config = configparser.ConfigParser()
print(path+'/settings.cfg')
config.read(path + '/settings.cfg')

# Set your community name and slack_url below
community = 'Team-Name'
slack_url = 'django-slackinvite.slack.com'
slack_url = get_env_variable('SLACK_URL')
slack_team = get_env_variable('SLACK_TEAM')
slack_token = get_env_variable('SLACK_TOKEN')
2 changes: 1 addition & 1 deletion slack_invite/slack_invite/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def home(request):
return HttpResponseRedirect('/thanks')
else:
form = InviteForm()
community = config.community
community = config.slack_team
return render(request, "slack_invite/index.html", {'form': form, 'community': community})

def home_files(request, filename):
Expand Down

0 comments on commit 7502e85

Please sign in to comment.