Skip to content
Snippets Groups Projects
Commit c5dd8cec authored by Todd Dembrey's avatar Todd Dembrey
Browse files

Make sure we can configure the room and URL in production

parent a7dd884f
No related branches found
No related tags found
No related merge requests found
......@@ -106,7 +106,8 @@ class SlackAdapter(AdapterBase):
def __init__(self):
super().__init__()
self.destination = settings.SLACK_DESTINATION
self.destination = settings.SLACK_DESTINATION_URL
self.target_room = settings.SLACK_DESTINATION_ROOM
def message(self, message_type, **kwargs):
user = kwargs['user']
......@@ -128,11 +129,11 @@ class SlackAdapter(AdapterBase):
return f'<{user.slack}>'
def send_message(self, message, **kwargs):
if not self.destination:
if not self.destination and not self.target_room:
return
data = {
"room": "CBQUCH458",
"room": self.target_room,
"message": message,
}
requests.post(self.destination, data=data)
......
......@@ -5,6 +5,8 @@ Django settings for opentech project.
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
env = os.environ.copy()
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(PROJECT_DIR)
......@@ -351,5 +353,6 @@ HIJACK_DECORATOR = 'opentech.apply.users.decorators.superuser_decorator'
# Messaging Settings
SEND_MESSAGES = False
SLACK_DESTINATION = None
SEND_MESSAGES = env.get('SEND_MESSAGES', 'false').lower() == 'true'
SLACK_DESTINATION_URL = env.get('SLACK_DESTINATION_URL', None)
SLACK_DESTINATION_ROOM = env.get('SLACK_DESTINATION_ROOM', None)
......@@ -144,11 +144,6 @@ if 'LOG_DIR' in env:
LOGGING['loggers']['django.security']['handlers'].append('errors_file')
# Messaging Settings
SEND_MESSAGES = env.get('SEND_MESSAGES', 'false').lower() == 'true'
SLACK_DESTINATION = env.get('SLACK_DESTINATION', None)
try:
from .local import * # noqa
except ImportError:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment