This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def repair_cost_calculator(hours_worked=0.00, cost_of_parts=0.00): | |
total_charge = 0.00 | |
inspection_charge = 7500.00 | |
if hours_worked > 0: | |
labour_charge = hours_worked * 7500.00 | |
total_charge = labour_charge + cost_of_parts | |
if total_charge < 12000.00: | |
return 12000.00 | |
else: | |
return total_charge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def send_slack_message(slack_channel_id, message): | |
bot_client.chat_postMessage(channel=slack_channel_id, text=message) | |
bot_message = ':wave: Hello I am a bot' | |
general_channel_id = 'CXXXXXX' | |
send_slack_message(slack_channel_id=general_channel_id, message=bot_message) | |
# get_channel_messages(channel_id=channel_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_channel_messages(channel_id): | |
messages = bot_client.conversations_history( | |
channel=channel_id | |
) | |
print(messages) | |
general_channel_id = 'Cxxxxxxx' | |
get_channel_messages(channel_id=channel_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from slack_sdk import WebClient | |
bot_token = os.getenv('SLACK_BOT_TOKEN') | |
bot_client = WebClient(token=bot_token) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TENANT_APPS = ( | |
'django.contrib.contenttypes', | |
'pollsapi.polls' | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
INSTALLED_APPS = [ | |
'tenant_schemas', | |
..... | |
'pollsapi.tenant' | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SHARED_APPS = ( | |
'tenant_schemas', | |
'pollsapi.tenant', | |
... | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework import serializers | |
class ClientSerializer(serializers.Serializer): | |
tenant_uuid = serializers.UUIDField() | |
tenant_name = serializers.CharField() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SECRET_KEY=<your-very-secret-key> | |
DB_NAME=pollsapi | |
DB_USER=<your-db-user> | |
DB_PASSWORD=<your-db-password> | |
HOST=localhost | |
DEBUG=True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DATABASES = { | |
'default': { | |
'ENGINE': 'tenant_schemas.postgresql_backend', | |
'NAME': os.getenv('DB_NAME', 'pollsapi'), | |
'USER': os.getenv('DB_USER', 'postgres'), | |
'PASSWORD': os.getenv('DB_PASSWORD', 'postgres'), | |
'HOST': os.getenv('HOST', 'localhost'), | |
'PORT': os.getenv('PORT', 5432), | |
} | |
} |
NewerOlder