Skip to content

Instantly share code, notes, and snippets.

View MainaKamau92's full-sized avatar
🪲

Maina Kamau MainaKamau92

🪲
View GitHub Profile
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
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)
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)
import os
from slack_sdk import WebClient
bot_token = os.getenv('SLACK_BOT_TOKEN')
bot_client = WebClient(token=bot_token)
TENANT_APPS = (
'django.contrib.contenttypes',
'pollsapi.polls'
)
INSTALLED_APPS = [
'tenant_schemas',
.....
'pollsapi.tenant'
]
SHARED_APPS = (
'tenant_schemas',
'pollsapi.tenant',
...
)
from rest_framework import serializers
class ClientSerializer(serializers.Serializer):
tenant_uuid = serializers.UUIDField()
tenant_name = serializers.CharField()
SECRET_KEY=<your-very-secret-key>
DB_NAME=pollsapi
DB_USER=<your-db-user>
DB_PASSWORD=<your-db-password>
HOST=localhost
DEBUG=True
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),
}
}